in, moveXMax); gameObject.transform.position = objPos; } } } InputUtillity.cs . using System.Collections; using System.Collections.Generic; using UnityEngine; public enum MyTouchPhase { // UnityEngine.TouchPhase で定義された内容 Began = 0, Moved = 1, Stationary = 2, Ended = 3, Canceled = 4, // 追加 None = 100, } public struct TouchInfo { public MyTouchPhase phase; public bool isMousePointer; public Touch touch; public TouchInfo(Touch _touch)
public void Play() { rigidbody2d.simulated = true; } } Ball の object に Script を適応しましょう。 Max Speed を書き換えることでボールのスピードを変更することが可能です。これは、 public で書かれた変数の初期値になります。 Player の操作と同じく、▶ボタンを押して実⾏してみましょう。壁や Player にぶつか って跳ね返るはずです。
に GameOver という C#ファイルを作 成し、以下のように記述します。 GameOver.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class GameOver : MonoBehaviour { private Rigidbody2D Ball; //public GameObject gameover; // Start is called before the first frame update void Start() { ////gameover.gameObject.SetActive(false); //GameObject.Find("Button").SetActive(false); //Debug.Log(gameObject.name); //GameObject.Find("GameOverText").SetActive(fa lse); } // Update is called once per frame
{ blocks.Remove(block); if (blocks.Count == 0) { Debug.Log("!全部消しました!"); GameSceneManager.Instance.CallStageClear(); } } } GameSceneManager.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameSceneManager : MonoBehaviour { private static GameSceneManager _Instance; public GameClear clear; public static GameSceneManager Instance { get { if (_Instance == null) // まだ未セット、もしくは Destroy されてた {
void OnDestroy() { _Instance = null; } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void CallGameOver() { } public void CallStageClear() { clear.Show(true); Debug.Log("!ステージクリアですです!"); } }
using System.Collections.Generic; using UnityEngine; public class GameClear : MonoBehaviour { // Start is called before the first frame update void Start() { } public UnityEngine.UI.Text scoreLabel; // Update is called once per frame void Update() { } public void Show(bool flag) { gameObject.SetActive(flag); } public void OnPushRetry() { Debug.Log("Next Stage"); } } GameOver と同じく、Show と言う関数で表示を管理しました。 そして、GameClear の条件はオブジェクトの数が 0 になる場合かつ、ゲームが終わっ ていない場合です。