Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
# Conflicts: # popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity
This commit is contained in:
commit
36c36079c6
File diff suppressed because it is too large
Load Diff
|
|
@ -1,20 +1,45 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MyGame.Scenes.Main
|
||||
public class CornManager : MonoBehaviour
|
||||
{
|
||||
public class CornManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform cornSpawnTarget;
|
||||
[SerializeField] private Corn cornPrefab;
|
||||
[SerializeField] private int cornSpawnCount = 20;
|
||||
[SerializeField] private Transform cornSpawnTarget;
|
||||
[SerializeField] private Corn cornPrefab;
|
||||
[SerializeField] private int cornSpawnCount = 20;
|
||||
[SerializeField] private float cornGrowSpeed;
|
||||
[SerializeField] private float cornHotGrowSpeed;
|
||||
|
||||
private Corn[] cornArray;
|
||||
|
||||
private void Start()
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
cornArray = new Corn[cornSpawnCount];
|
||||
}
|
||||
|
||||
public void GenerateCorn()
|
||||
{
|
||||
for (int i = 0; i < cornSpawnCount; i++)
|
||||
{
|
||||
for (int i = 0; i < cornSpawnCount; i++)
|
||||
{
|
||||
Instantiate(cornPrefab, cornSpawnTarget);
|
||||
}
|
||||
cornArray[i] = Instantiate(cornPrefab, cornSpawnTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeGrowSpeed(ThermalCondition condition)
|
||||
{
|
||||
switch (condition)
|
||||
{
|
||||
case ThermalCondition.Cold:
|
||||
break;
|
||||
case ThermalCondition.Yellow:
|
||||
break;
|
||||
case ThermalCondition.Hot:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -29,17 +30,25 @@ public class ThermalControl : MonoBehaviour
|
|||
[SerializeField] private float coldValue = 0.32f;
|
||||
[SerializeField] private float hotValue = 0.67f;
|
||||
|
||||
public IReadOnlyReactiveProperty<ThermalCondition> Condition => condition;
|
||||
private ReactiveProperty<ThermalCondition> condition;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
temperature = 0f;
|
||||
condition = new ReactiveProperty<ThermalCondition>(ThermalCondition.Cold);
|
||||
thermoMeter.SetScale(coldValue, hotValue);
|
||||
|
||||
condition.DistinctUntilChanged().Subscribe(x =>
|
||||
{
|
||||
Debug.Log($"cond :{x} temp: {temperature}");
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private ThermalCondition prevCond;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var cond = GetCondition();
|
||||
{
|
||||
panSpeed = panController.Delta.magnitude * panFactor;
|
||||
if (panSpeed > deadZone)
|
||||
{
|
||||
|
|
@ -47,7 +56,7 @@ public class ThermalControl : MonoBehaviour
|
|||
}
|
||||
else
|
||||
{
|
||||
if (cond == ThermalCondition.Hot)
|
||||
if (condition.Value == ThermalCondition.Hot)
|
||||
{
|
||||
temperature += hotIncreaseSpeed * Time.deltaTime;
|
||||
}
|
||||
|
|
@ -58,12 +67,7 @@ public class ThermalControl : MonoBehaviour
|
|||
}
|
||||
temperature = Mathf.Clamp01(temperature);
|
||||
thermoMeter.SetValue(temperature);
|
||||
|
||||
if (cond != prevCond)
|
||||
{
|
||||
Debug.Log($"cond :{cond} temp: {temperature}");
|
||||
prevCond = cond;
|
||||
}
|
||||
condition.Value = GetCondition();
|
||||
}
|
||||
|
||||
public ThermalCondition GetCondition()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
|
@ -8,143 +9,45 @@ using UnityEngine.UI;
|
|||
public class PopcornGameManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject startingGuide;
|
||||
[SerializeField] private PowerMeter powerMeter;
|
||||
[SerializeField] private Text powerResultText;
|
||||
// [SerializeField] private Text powerResultText;
|
||||
[SerializeField] private Text gameResultText;
|
||||
[SerializeField] private PanController panController;
|
||||
|
||||
[SerializeField] private ThermalControl thermalControl;
|
||||
[SerializeField] private ThermoMeter thermoMeter;
|
||||
[SerializeField] private CornManager cornManager;
|
||||
|
||||
private Action tapAction;
|
||||
private bool isProgress;
|
||||
private int gameCount;
|
||||
private int failCount;
|
||||
private bool isPerfect;
|
||||
private readonly int maxGameCount = 3;
|
||||
private readonly int maxFailCount = 2;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
powerResultText.text = "";
|
||||
gameResultText.text = "";
|
||||
startingGuide.SetActive(true);
|
||||
powerMeter.StopMove();
|
||||
// startingGuide.SetActive(true);
|
||||
isProgress = false;
|
||||
panController.enabled = false;
|
||||
cornManager.Initialize();
|
||||
|
||||
// タップしたら案内非表示&ゲーム開始
|
||||
tapAction = () =>
|
||||
thermalControl.Condition.DistinctUntilChanged().Subscribe(x =>
|
||||
{
|
||||
startingGuide.SetActive(false);
|
||||
// panController.enabled = true;
|
||||
GameStart();
|
||||
};
|
||||
cornManager.ChangeGrowSpeed(x);
|
||||
}).AddTo(this);
|
||||
|
||||
GameReset();
|
||||
|
||||
// タップ後スタート
|
||||
GameStart();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
}
|
||||
|
||||
private void GameReset()
|
||||
{
|
||||
cornManager.GenerateCorn();
|
||||
}
|
||||
|
||||
private void GameStart()
|
||||
{
|
||||
gameCount = 0;
|
||||
failCount = 0;
|
||||
isPerfect = true;
|
||||
powerMeter.StartMove();
|
||||
tapAction = () =>
|
||||
{
|
||||
isProgress = true;
|
||||
powerMeter.StopMove();
|
||||
gameCount++;
|
||||
var pos = powerMeter.GetCurrentPosisiton();
|
||||
Debug.Log($"tap! {pos}");
|
||||
// 判定
|
||||
CheckQuality(pos);
|
||||
|
||||
this.CallWaitForSeconds(1f, () =>
|
||||
{
|
||||
powerResultText.text = "";
|
||||
// 失敗
|
||||
if (failCount >= maxFailCount)
|
||||
{
|
||||
gameResultText.text = "失敗!";
|
||||
powerMeter.gameObject.SetActive(false);
|
||||
tapAction = () => { };
|
||||
panController.enabled = false;
|
||||
this.CallWaitForSeconds(2f, () =>
|
||||
{
|
||||
gameResultText.text = "タップでリスタート";
|
||||
tapAction = () => {
|
||||
{
|
||||
SceneManager.LoadScene("Main");
|
||||
}};
|
||||
isProgress = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 成功
|
||||
if (gameCount >= maxGameCount)
|
||||
{
|
||||
gameResultText.text = "成功!";
|
||||
if (isPerfect)
|
||||
{
|
||||
gameResultText.text = "大成功!";
|
||||
}
|
||||
powerMeter.gameObject.SetActive(false);
|
||||
tapAction = () => { };
|
||||
panController.enabled = false;
|
||||
this.CallWaitForSeconds(2f, () =>
|
||||
{
|
||||
gameResultText.text = "タップでリスタート";
|
||||
tapAction = () => {
|
||||
{
|
||||
SceneManager.LoadScene("Main");
|
||||
}};
|
||||
isProgress = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
isProgress = false;
|
||||
powerMeter.StartMove();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private void CheckQuality(float pos)
|
||||
{
|
||||
//Perfect=0.45~0.5
|
||||
//Good=0.3
|
||||
if (pos <= 0.05f)
|
||||
{
|
||||
powerResultText.text = "パーフェクト";
|
||||
return;
|
||||
}
|
||||
if (pos <= 0.2)
|
||||
{
|
||||
powerResultText.text = "グッド";
|
||||
isPerfect = false;
|
||||
return;
|
||||
}
|
||||
powerResultText.text = "ミス!";
|
||||
isPerfect = false;
|
||||
failCount++;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (!isProgress)
|
||||
{
|
||||
tapAction.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckTap(Vector2 position){
|
||||
var eventSystem = EventSystem.current;
|
||||
var eventDataCurrentPosition = new PointerEventData(eventSystem);
|
||||
eventDataCurrentPosition.position = position;
|
||||
List<RaycastResult> raycastResults = new List<RaycastResult>();
|
||||
eventSystem.RaycastAll(eventDataCurrentPosition, raycastResults);
|
||||
return raycastResults.Count == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue