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

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:
startingGuide: {fileID: 8786490829224139677}
gameResultText: {fileID: 1003859323}
characterSweat: {fileID: 580170368}
characterFlower: {fileID: 785034261}
thermalControl: {fileID: 1870432535}
thermoMeter: {fileID: 1928679192}
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 HashCornBurn = Animator.StringToHash("CornBurn");
[SerializeField] private SpriteRenderer spriteRenderer;
[SerializeField] private Sprite cornSeedSprite;
[SerializeField] private Sprite cornSimpleSprite;

View File

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

View File

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

View File

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