public static float lengthUnit = Screen.height / 73; //10 public override void ReactionPlayer(PlayerState playerState) { if (playerState.isDie) { status = GameStatues.GameOver; } }
// Update is called once per frame void Update() { switch (status) { case GameStatues.Loading: if (loadingTime > 0) { loadingTime -= Time.deltaTime; } else { status = GameStatues.Running; model.NewScene(gameInfo); gestureListener = CubeGestureListener.Instance; //Debug.Log(gestureListener.gestureInfo); } break; case GameStatues.Running: break; case GameStatues.GameOver: break; default: //Console.WriteLine("无效的成绩"); break; } }
// Start is called before the first frame update void Start() { Debug.Log("create a scene controller"); DontDestroyOnLoad(this); gameInfo.chapter = 0; gameInfo.section = 0; status = GameStatues.Help; { enemyNum[0] = new int[] { 0, 0, 0 }; enemyNum[1] = new int[] { 6, 6, 6 }; } { maxEnemyNum[0] = new int[] { 0, 0, 0 }; maxEnemyNum[1] = new int[] { 6, 6, 6 }; } { secNumPerChap = new int[] { 3, 6 }; } { sectionName[0] = new string[] { "prelude", "start", "help" }; sectionName[1] = new string[] { "chapaa" }; } model = gameObject.AddComponent <Model>() as Model; UI = gameObject.AddComponent <UIController>() as UIController; UI.SetGame(gameInfo); //model.getObserver(this); }
// Update is called once per frame void Update() { if (statues == GameStatues.Running) { if (restDisk > 0 && waitTime <= 0) { if (flyStyle) { diskmanager.FlyDisk(scoreKeeper.GetRound()); } else { diskmanager.FlyDiskByForce(scoreKeeper.GetRound()); } restDisk -= 1; waitTime = 4f; } else if (restDisk > 0 && waitTime > 0) { waitTime -= Time.deltaTime; } else if (restDisk <= 0) { if (scoreKeeper.GetRound() != MAX_ROUND) { restDisk = 5; statues = GameStatues.WaitingForNextRound; waitTime = 2; } else { statues = GameStatues.WaitingForGameOver; waitTime = 2; } } } else if (statues == GameStatues.WaitingForNextRound) { waitTime -= Time.deltaTime; if (waitTime <= 0) { statues = GameStatues.NextRound; } } else if (statues == GameStatues.WaitingForGameOver) { waitTime -= Time.deltaTime; if (waitTime <= 0) { statues = GameStatues.GameOver; } } }
public void StartGame() { model.getPlayer().GetComponent <Player>().Attach(UI); gameInfo.chapter = 1; gameInfo.section = 0; status = GameStatues.Loading; loadingTime = 1; #pragma warning disable CS0618 // 类型或成员已过时 Application.LoadLevel(sectionName[gameInfo.chapter][gameInfo.section]); #pragma warning restore CS0618 // 类型或成员已过时 GameObject.Find("Player").GetComponent <Player>().GetComponent <PlayerMove>().SetListener(); }
// Use this for initialization void Start() { scoreKeeper = gameObject.AddComponent <ScoreKeeper>() as ScoreKeeper; diskmanager = gameObject.AddComponent <DiskActionManager>() as DiskActionManager; diskmanager.GetScore(scoreKeeper); statues = GameStatues.Pause; fontstyle.fontSize = 50; fontstyle.normal.textColor = new Color(255, 255, 255); fontstyle.alignment = TextAnchor.MiddleCenter; GameObject player = Instantiate(Resources.Load("Prefabs/Player"), Vector3.up, Quaternion.identity) as GameObject; player.transform.rotation = Quaternion.Euler(0, 90, 0); player.transform.position = new Vector3(-5, -3, 0); }
public void NextSection() { Debug.Log("Perepare to turn to next section"); gameInfo.section++; if (gameInfo.section == secNumPerChap[gameInfo.chapter]) { gameInfo.section = 0; gameInfo.chapter++; } if (gameInfo.chapter == 5) { status = GameStatues.Win; } Debug.Log(sectionName[gameInfo.chapter][gameInfo.section]); #pragma warning disable CS0618 // 类型或成员已过时 Application.LoadLevel(sectionName[gameInfo.chapter][gameInfo.section]); #pragma warning restore CS0618 // 类型或成员已过时 }
public void OnGUI() { if (GUI.Button(new Rect(Screen.width - 300, 0, 100, 30), "Start", fontstyle)) { time = 4f; statues = GameStatues.Counting; scoreKeeper.Reset(); } if (GUI.Button(new Rect(Screen.width - 300, 50, 100, 30), "Change", fontstyle)) { flyStyle = !flyStyle; } GUI.TextArea(new Rect(0, 0, 200, 50), "Round: " + scoreKeeper.GetRound().ToString(), fontstyle); GUI.TextArea(new Rect(0, 50, 200, 50), "Score: " + scoreKeeper.GetScore().ToString(), fontstyle); if (flyStyle) { GUI.TextArea(new Rect(0, 100, 200, 50), "Gymnastic", fontstyle); } else { GUI.TextArea(new Rect(0, 100, 200, 50), "Physics", fontstyle); } if (statues == GameStatues.Counting) { if (time >= 3) { GUI.TextArea(new Rect(Screen.width / 2 - 50, 100, 40, 40), "3", fontstyle); } else if (time >= 2) { GUI.TextArea(new Rect(Screen.width / 2 - 50, 100, 40, 40), "2", fontstyle); } else if (time >= 1) { GUI.TextArea(new Rect(Screen.width / 2 - 50, 100, 40, 40), "1", fontstyle); } else if (time >= 0) { GUI.TextArea(new Rect(Screen.width / 2 - 50, 100, 40, 40), "0", fontstyle); } time -= Time.deltaTime; if (time < 0) { statues = GameStatues.Running; } } else if (statues == GameStatues.NextRound) { if (GUI.Button(new Rect(Screen.width - 300, Screen.height - 200, 100, 30), "NEXT ROUND!", fontstyle)) { time = 4f; statues = GameStatues.Counting; if (!scoreKeeper.NextRound()) { statues = GameStatues.GameOver; } } } else if (statues == GameStatues.GameOver) { GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 200, 100, 30), "Game Over", fontstyle); GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 100, 100, 30), "You Score Is: " + scoreKeeper.GetScore().ToString(), fontstyle); } }