仮スタート画面表示/ニワトリくんアニメーション対応

This commit is contained in:
kimura 2021-07-06 18:40:54 +09:00
parent 4218ffb09a
commit bcc1f6b7e7
5 changed files with 77 additions and 11 deletions

View File

@ -7924,6 +7924,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
startingGuide: {fileID: 8786490829224139677} startingGuide: {fileID: 8786490829224139677}
gameResultText: {fileID: 1003859323} gameResultText: {fileID: 1003859323}
characterSweat: {fileID: 580170368}
characterFlower: {fileID: 785034261}
thermalControl: {fileID: 1870432535} thermalControl: {fileID: 1870432535}
thermoMeter: {fileID: 1928679192} thermoMeter: {fileID: 1928679192}
cornManager: {fileID: 1870432536} cornManager: {fileID: 1870432536}

View File

@ -19,6 +19,7 @@ public class Corn : MonoBehaviour
{ {
private static readonly int HashCornGrow = Animator.StringToHash("CornGrow"); private static readonly int HashCornGrow = Animator.StringToHash("CornGrow");
private static readonly int HashCornBurn = Animator.StringToHash("CornBurn"); private static readonly int HashCornBurn = Animator.StringToHash("CornBurn");
[SerializeField] private SpriteRenderer spriteRenderer; [SerializeField] private SpriteRenderer spriteRenderer;
[SerializeField] private Sprite cornSeedSprite; [SerializeField] private Sprite cornSeedSprite;
[SerializeField] private Sprite cornSimpleSprite; [SerializeField] private Sprite cornSimpleSprite;

View File

@ -45,7 +45,9 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler
// 移動範囲を制限 // 移動範囲を制限
pos = targetBorder.bounds.ClosestPoint(pos); pos = targetBorder.bounds.ClosestPoint(pos);
delta = pos - targetPos; delta = pos - targetPos;
#if UNITY_EDITOR
deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}"; deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}";
#endif
target.position = pos; target.position = pos;
} }

View File

@ -32,21 +32,28 @@ public class ThermalControl : MonoBehaviour
[SerializeField] private float hotValue = 0.67f; [SerializeField] private float hotValue = 0.67f;
private float duration = 0.3f; private float duration = 0.3f;
private bool isMove;
private readonly ReactiveProperty<ThermalCondition> condition = new ReactiveProperty<ThermalCondition>(ThermalCondition.Cold);
public IReadOnlyReactiveProperty<ThermalCondition> Condition => condition; public IReadOnlyReactiveProperty<ThermalCondition> Condition => condition;
private readonly ReactiveProperty<ThermalCondition> condition = new ReactiveProperty<ThermalCondition>(ThermalCondition.Cold);
private void Start() private void Start()
{ {
condition.AddTo(this); condition.AddTo(this);
#if UNITY_EDITOR
condition.DistinctUntilChanged().Subscribe(x => condition.DistinctUntilChanged().Subscribe(x =>
{ {
Debug.Log($"cond :{x} temp: {temperature}"); Debug.Log($"cond :{x} temp: {temperature}");
}).AddTo(this); }).AddTo(this);
#endif
} }
private void Update() private void Update()
{ {
if (!isMove)
{
return;
}
panSpeed = panController.Delta.magnitude * panFactor; panSpeed = panController.Delta.magnitude * panFactor;
if (panSpeed > deadZone) if (panSpeed > deadZone)
{ {
@ -87,4 +94,14 @@ public class ThermalControl : MonoBehaviour
temperatureSpeed = 0f; temperatureSpeed = 0f;
thermoMeter.SetScale(coldValue, hotValue); thermoMeter.SetScale(coldValue, hotValue);
} }
public void StartMeter()
{
isMove = true;
}
public void StopMeter()
{
isMove = false;
}
} }

View File

@ -1,53 +1,97 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UniRx; using UniRx;
using UniRx.Triggers;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
public enum GameState
{
Guide,
Playing,
Result
}
public class PopcornGameManager : MonoBehaviour public class PopcornGameManager : MonoBehaviour
{ {
[SerializeField] private GameObject startingGuide; [SerializeField] private GameObject startingGuide;
// [SerializeField] private Text powerResultText; // [SerializeField] private Text powerResultText;
[SerializeField] private Text gameResultText; [SerializeField] private Text gameResultText;
[SerializeField] private GameObject characterSweat;
[SerializeField] private GameObject characterFlower;
[SerializeField] private ThermalControl thermalControl; [SerializeField] private ThermalControl thermalControl;
[SerializeField] private ThermoMeter thermoMeter; [SerializeField] private ThermoMeter thermoMeter;
[SerializeField] private CornManager cornManager; [SerializeField] private CornManager cornManager;
private Action tapAction; public IReadOnlyReactiveProperty<GameState> State => state;
private bool isProgress; private readonly ReactiveProperty<GameState> state = new ReactiveProperty<GameState>(GameState.Guide);
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
gameResultText.text = "";
// startingGuide.SetActive(true);
isProgress = false;
thermalControl.Condition.Subscribe(x => thermalControl.Condition.Subscribe(x =>
{ {
cornManager.ChangeGrowSpeed(x); cornManager.ChangeGrowSpeed(x);
switch (x)
{
case ThermalCondition.Cold:
characterFlower.gameObject.SetActive(false);
characterSweat.gameObject.SetActive(false);
break;
case ThermalCondition.Yellow:
characterFlower.gameObject.SetActive(true);
characterSweat.gameObject.SetActive(false);
break;
case ThermalCondition.Hot:
characterFlower.gameObject.SetActive(false);
characterSweat.gameObject.SetActive(true);
break;
default:
throw new ArgumentOutOfRangeException(nameof(x), x, null);
}
}).AddTo(this);
this.UpdateAsObservable().Where(_ => Input.GetMouseButton(0)).FirstOrDefault().Subscribe(_ =>
{
StartGame();
}).AddTo(this); }).AddTo(this);
ResetGame(); ResetGame();
// タップ後スタート // コーンマネージャからResultきたらStateもResult
StartGame();
} }
private void Update() private void Update()
{ {
} }
private void ResetUI()
{
startingGuide.SetActive(true);
thermoMeter.gameObject.SetActive(false);
gameResultText.text = "";
thermalControl.StopMeter();
characterFlower.gameObject.SetActive(false);
characterSweat.gameObject.SetActive(false);
}
private void ResetGame() private void ResetGame()
{ {
ResetUI();
thermalControl.ResetMeter(); thermalControl.ResetMeter();
cornManager.RespawnCorn(); cornManager.RespawnCorn();
} }
private void StartGame() private void StartGame()
{ {
startingGuide.SetActive(false);
thermoMeter.gameObject.SetActive(true);
thermalControl.StartMeter();
state.Value = GameState.Playing;
} }
} }