Script移動/不要ファイル削除

This commit is contained in:
kimura 2021-07-13 17:36:42 +09:00
parent caaffaa5d9
commit a7e524bcfc
14 changed files with 6 additions and 2243 deletions

View File

@ -84,6 +84,12 @@ public class PopcornGameManager : MonoBehaviour
.ThrottleFirst(TimeSpan.FromSeconds(0.1f))
.Subscribe(_ => ResetGame())
.AddTo(this);
cornManager.Result
.SkipLatestValueOnSubscribe()
// .DistinctUntilChanged()
.Materialize()
.Subscribe(x => { Debug.Log(x); }).AddTo(this);
#endif
}

View File

@ -1,138 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class TimingGame : MonoBehaviour
{
[SerializeField] private PowerMeter powerMeter;
[SerializeField] private Text powerResultText;
[SerializeField] private PanController panController;
private Action tapAction;
private bool initialized;
private bool isReady;
private bool isProgress;
private int gameCount;
private int failCount;
private bool isPerfect;
private readonly int maxGameCount = 3;
private readonly int maxFailCount = 2;
// Update is called once per frame
void Update()
{
if (isProgress) return;
if(Input.GetMouseButtonDown(0))
{
tapAction.Invoke();
}
}
public void Initialize()
{
if (initialized) return;
isReady = false;
GameReset();
initialized = true;
}
private void GameReset()
{
if (isReady) return;
powerResultText.gameObject.SetActive(false);
powerMeter.gameObject.SetActive(true);
gameCount = 0;
failCount = 0;
panController.enabled = false;
powerMeter.StopMove();
isProgress = false;
isPerfect = true;
isReady = true;
}
public void GameStart()
{
GameReset();
isReady = false;
powerMeter.StartMove();
panController.enabled = true;
tapAction = () =>
{
powerMeter.StopMove();
isProgress = true;
gameCount++;
var pos = powerMeter.GetCurrentPosisiton();
Debug.Log($"tap! {pos}");
// 判定
CheckQuality(pos);
this.CallWaitForSeconds(1f, () =>
{
powerResultText.gameObject.SetActive(false);
// 失敗
if (failCount >= maxFailCount)
{
GameOver();
return;
}
// 成功
if (gameCount >= maxGameCount)
{
// 大成功
if (isPerfect)
{
GameOver();
return;
}
GameOver();
return;
}
powerMeter.StartMove();
isProgress = false;
});
};
}
private void GameOver()
{
tapAction = () => { };
powerMeter.gameObject.SetActive(false);
panController.enabled = false;
}
private void CheckQuality(float pos)
{
powerResultText.gameObject.SetActive(true);
//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++;
}
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;
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 2527953f37754598a05d509fe4b7bfde
timeCreated: 1624611253

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 93ba9dca3e4b9417ea96eca73109b419
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,51 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PowerMeter : MonoBehaviour
{
[SerializeField] private Slider slider;
public float Magnificate = 1f;
private int direction;
private bool isMove;
// Start is called before the first frame update
void Start()
{
direction = 1;
slider.value = 0.5f;
}
// Update is called once per frame
void Update()
{
if (!isMove) return;
if (Mathf.Approximately(0f, slider.value))
{
direction = 1;
}
if (Mathf.Approximately(1f, slider.value))
{
direction = -1;
}
slider.value += Time.deltaTime * direction * Magnificate;
}
public void StartMove()
{
isMove = true;
}
public void StopMove()
{
isMove = false;
}
// 中央を0として-0.5~0.5の範囲を返す
public float GetCurrentPosisiton()
{
return Mathf.Abs(slider.value - 0.5f);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6d46467b41f834a27b53dadeaccc6ea1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: