Inheritance: MonoBehaviour
Exemple #1
0
 private void SetGameWin()
 {
     if (levelResultat == null)
     {
         levelResultat = new GameWin(PController.instance.playerUnits.Count);
     }
 }
Exemple #2
0
 private void SetGameOver()
 {
     if (levelResultat == null)
     {
         levelResultat = new GameOver();
     }
 }
Exemple #3
0
        void IGameFinishObserver.NotifyGameFinished(GameFinish finish)
        {
            gameObject.AddComponent <Image>();
            var message = new GameObject("Game finish message");
            var text    = message.AddComponent <Text>();

            text.text      = finish.winner + " wins!\nBecause " + finish.reason;
            text.font      = Resources.GetBuiltinResource <Font>("Arial.ttf");
            text.color     = Color.black;
            text.alignment = TextAnchor.MiddleCenter;
            text.rectTransform.anchorMin = new Vector2(0.20f, 0.20f);
            text.rectTransform.anchorMax = new Vector2(0.80f, 0.80f);
            message.AttachTo(gameObject);
        }
 public static Task GameFinish(this IClientProxy hubConnection, GameFinish apiObject)
 {
     return(hubConnection.SendAsync(GameHubApiKeys.GameFinish, apiObject));
 }
Exemple #5
0
    void Update()
    {
        scene = SceneManager.GetActiveScene();

        switch (gameState)
        {
        case GameState.Intro:
            break;

        case GameState.MainMenu:
            scores.Clear();

            if (scene.name != "MainMenu")
            {
                SceneManager.LoadScene("MainMenu");
            }
            break;

        case GameState.GameOver:

            player = GameObject.FindGameObjectWithTag("Player");

            if (player != null)
            {
                GameOver gameOver = player.GetComponent <GameOver>();

                if (gameOver == null)
                {
                    player.AddComponent <GameOver>();
                }
            }

            level_index = 0;
            break;

        case GameState.Paused:
            break;

        case GameState.NextLevel:
            if (levels != null && levels.Length > 0)
            {
                if (level_index < levels.Length)
                {
                    level_index++;
                    SetGameState(GameState.LoadLevel);
                }
                else
                {
                    SetGameState(GameState.GameFinished);
                }
            }
            break;

        case GameState.LoadLevel:
            if (levels != null && levels.Length > 0)
            {
                if (level_index < levels.Length)
                {
                    SceneManager.LoadScene(levels[level_index]);
                    SetGameState(GameState.Playing);
                }
            }
            break;

        case GameState.Playing:
            break;

        case GameState.PlayerDied:
            playerLives--;

            if (playerLives > 0)
            {
                SetGameState(GameState.LoadLevel);
            }
            else
            {
                SetGameState(GameState.GameOver);
            }
            break;

        case GameState.LevelFinished:
            player = GameObject.FindGameObjectWithTag("Player");

            if (player != null)
            {
                if (level_index == levels.Length - 1)
                {
                    SetGameState(GameState.GameFinished);
                }
                else
                {
                    LevelFinish levelFinish = player.GetComponent <LevelFinish>();

                    if (levelFinish == null)
                    {
                        player.AddComponent <LevelFinish>();
                    }
                }
            }
            break;

        case GameState.GameFinished:
            GameFinish gameFinish = player.GetComponent <GameFinish>();

            if (gameFinish == null)
            {
                player.AddComponent <GameFinish>();
            }
            break;

        case GameState.QuitGame:
            Debug.Log("Application Quit!");
            Application.Quit();
            break;
        }
    }
Exemple #6
0
 void Start()
 {
     singleton = this;
 }
Exemple #7
0
        public bool TryAdd(ReadOnlySpan <char> logLine)
        {
            if (LevelLoad.TryParse(logLine, LogDate, out var ll))
            {
                Current = ll;
                LoadLevelList.Add(ll);
            }
            else if (TestDriveStart.TryParse(logLine, LogDate, out var std))
            {
                Current = std;
                StartTestDriveList.Add(std);
            }
            else if (TestDriveFinish.TryParse(logLine, LogDate, out var ftd))
            {
                Current = ftd;
                FinishTestDriveList.Add(ftd);
            }
            else if (GameStart.TryParse(logLine, LogDate, out var sg))
            {
                Current = sg;
                StartGameList.Add(sg);
            }
            else if (GameFinish.TryParse(logLine, LogDate, out var fg))
            {
                Current = fg;
                FinishGameList.Add(fg);
            }
            else if (GameRound.TryParse(logLine, LogDate, out var rg))
            {
                Current = rg;
                RoundGameList.Add(rg);
            }
            else if (ActiveBattleStart.TryParse(logLine, LogDate, out var sab))
            {
                Current = sab;
                StartActiveBattleList.Add(sab);
            }
            else if (PlayerLoad.TryParse(logLine, LogDate, out var pl))
            {
                Current = pl;
                PlayerLoadList.Add(pl);
            }
            else if (Damage.TryParse(logLine, LogDate, out var dmg))
            {
                Current = dmg;
                DamageList.Add(dmg);
            }
            else if (Killing.TryParse(logLine, LogDate, out var kill))
            {
                Current = kill;
                KillList.Add(kill);
            }
            else if (KillAssist.TryParse(logLine, LogDate, out var ka))
            {
                Current = ka;
                KillAssistList.Add(ka);
            }
            else if (Score.TryParse(logLine, LogDate, out var sc))
            {
                Current = sc;
                ScoreList.Add(sc);
            }
            else if (Decal.TryParse(logLine, LogDate, out var dec))
            {
                Current = dec;
                DecalList.Add(dec);
            }
            else
            {
                Current = null;
                return(false);
            }
            //update datetimes
            var currentDateTime = new DateTime(Current.TimeStamp);

            if (currentDateTime > Last)
            {
                Last = currentDateTime;
            }
            if (currentDateTime < First)
            {
                First = currentDateTime;
            }
            return(true);
        }