コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (currentGameState == GameState.notStarted)
        {
            GameObject.Find("MainLogo").GetComponent <Fade>().FadeIn(0.8f);
            cam.Left(0.1f);

            if (cam.transform.position.magnitude < 250)
            {
                cam.ZoomOut();
            }
        }


        if (currentGameState == GameState.notStarted)
        {
            if (Input.GetKeyUp(KeyCode.Space))
            {
                GameStart();
            }
        }

        if (currentGameState == GameState.gameOver)
        {
            if (Input.GetKeyUp(KeyCode.Space))
            {
                GamePrep();
            }
        }



        if (Input.mouseScrollDelta.y < 0)
        {
            cam.ZoomOut(1f);
        }
        if (Input.mouseScrollDelta.y > 0)
        {
            cam.ZoomIn(1f);
        }

        if (Input.GetKeyDown(KeyCode.LeftBracket))
        {
            cam.SetTargetFollowMode(simulation.GetNextTank());
        }

        if (Input.GetKeyDown(KeyCode.RightBracket))
        {
            cam.SetTargetFollowMode(simulation.GetPreviousTank());
        }
        if (Input.GetKeyDown(KeyCode.Return))
        {
            cam.SetCenterCircleMode();
        }

        if (Input.GetKeyUp(KeyCode.Alpha1))
        {
            if (currentGameState == GameState.notStarted)
            {
                GameStart();
            }

            dummyTankCount++;
            simulation.CreateDummyTank(GenerateRandomHexColorString(), "DummyTank" + dummyTankCount, simulation.RandomArenaPosition(), true, true);
        }

        if (Input.GetKeyUp(KeyCode.Alpha2))
        {
            if (currentGameState == GameState.notStarted)
            {
                GameStart();
            }
            dummyTankCount++;
            simulation.CreateDummyTank(GenerateRandomHexColorString(), "DummyTank" + dummyTankCount, simulation.RandomArenaPosition(), false, true);
        }

        if (Input.GetKeyUp(KeyCode.Alpha3))
        {
            if (currentGameState == GameState.notStarted)
            {
                GameStart();
            }

            aiTankCount++;
            simulation.CreateAITank(GenerateRandomHexColorString(), "AITank" + aiTankCount, simulation.RandomArenaPosition(), false, true);
        }

        if (Input.GetKeyUp(KeyCode.Alpha4))
        {
            if (currentGameState == GameState.notStarted)
            {
                GameStart();
            }

            simulation.CreateManualTank();
        }

        if (Input.GetKeyUp(KeyCode.Backspace))
        {
            simulation.ClearAllNonPlayerTanks();
        }

        if (Input.GetKeyUp(KeyCode.R))
        {
            cam.ResetCamera();
        }



        if (Input.GetKeyUp(KeyCode.Delete))
        {
            simulation.ClearAllTanks();
            GamePrep();
        }

        if ((DateTime.Now - scoreRefreshTime).TotalSeconds > 5 && currentGameState == GameState.playing)
        {
            RefreshScores();
        }


        if (TrainingRoomMain.currentGameState == GameState.playing)
        {
            TimeSpan timeSinceStart = DateTime.Now - gameStart;
            timeLeft = gameDuration - timeSinceStart;

            timer.text = string.Format("{0:hh\\:mm\\:ss}", timeLeft);

            if (timeLeft.TotalSeconds < 30)
            {
                timer.color = Color.red;
            }
            else
            {
                timer.color = Color.white;
            }

            if (timeSinceStart > gameDuration)
            {
                GameOver();
            }
        }


        simulation.Update();
        server.Update();
    }