Пример #1
0
    private void ResetGameStats()
    {
        GameTimer = SettingsManager.GameTimer;
        SettingsManager.HighScore = GetHighScore();
        IsPaused = false;
        if (CurrentLevelIndex >= 1)
        {
            if (MonoFactory.Instance != null)
            {
                MonoFactory.ReturnAllChildren();
            }

            if (LevelBuilder.Instance != null)
            {
                LevelBuilder.Instance.LevelIndex = CurrentLevelIndex - 1;

                LevelBuilder.Instance.BuildLevel();
            }
            if (!SettingsManager.OverWriteLevelSettings)
            {
                SettingsManager.Instance.SetSettings(CurrentLevelIndex);
            }
            if (_playerTwo != null && _playerOne != null)
            {
                ResetPlayer();
            }
        }
        CurrentLevelIndex++;
        LevelChanged = true;
    }
Пример #2
0
    // --- Public/Internal Methods ------------------------------------------------------------------------------------
    public override void ReturnToFactory()
    {
        Debug.Log($"{this.GetType().Name} returning to factory!");
        foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>())
        {
            if (rb.gameObject == this.gameObject)
                continue;
            rb.isKinematic = true;
        }
        MonoFactory.ReturnFactoryObject(this);

        //for (int i = 0; i < _prefab.transform.childCount; i++)
        //{
        //    for (int j = 0; j < _prefab.transform.GetChild(i).childCount; j++)
        //    {
        //        for (int k = 0; k < _prefab.transform.GetChild(i).GetChild(j).childCount; k++)
        //        {
        //            transform.GetChild(i).GetChild(j).GetChild(k).localRotation = _prefab.transform.GetChild(i).GetChild(j).GetChild(k).localRotation;
        //            transform.GetChild(i).GetChild(j).GetChild(k).localPosition = _prefab.transform.GetChild(i).GetChild(j).GetChild(k).localPosition;
        //        }

        //    }
        //}

        BoxCollider[] prefabCols =_prefab.GetComponentsInChildren<BoxCollider>(true);
        BoxCollider[] thisCols = transform.GetComponentsInChildren<BoxCollider>(true);
        for (int i = 0; i < prefabCols.Length; i++)
        {
            thisCols[i].transform.localPosition = prefabCols[i].transform.localPosition;
            thisCols[i].transform.localRotation = prefabCols[i].transform.localRotation;
        }
    }
Пример #3
0
 private void OnBackToMenuButtonClicked()
 {
     GameController.Instance.GameOver -= (winner) => OnGameOver(winner);
     GameController.Instance.ResetCombinedPlayerScore();
     SettingsManager.HighScore = GameController.Instance.GetHighScore();
     GameController.Instance.CurrentLevelIndex = 0;
     MonoFactory.ReturnAllChildren();
     GameController.Instance.LoadLevelWithIndex(0);
 }
Пример #4
0
 virtual public void ReturnToFactory()
 {
     if (Player != null)
     {
         Player.ClearBullet();
         Player = null;
     }
     MonoFactory.ReturnFactoryObject(this);
 }
Пример #5
0
    // --- Properties -------------------------------------------------------------------------------------------------

    // --- Unity Functions --------------------------------------------------------------------------------------------
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(this);

        PopulateFactory();
    }
Пример #6
0
    private void OnGameOver(PlayerController winner)
    {

        if (_GameOverText != null)
        {
            _GameOverText.gameObject.SetActive(true);
            _playerOneScore.gameObject.SetActive(true);
            _playerTwoScore.gameObject.SetActive(true);
            _playerOneScore.text = GameController.Instance.CombinedScorePlayerOne.ToString();
            _playerTwoScore.text = GameController.Instance.CombinedScorePlayerTwo.ToString();
            if (winner != null)
            {
                _GameOverText.text = winner.name + " has Won!";
            }
            else
            {
                _GameOverText.text = "tie!";
            }
            MonoFactory.ReturnAllChildren();
            ToggleGameMenu();
        }
    }
Пример #7
0
 // --- Unity Functions --------------------------------------------------------------------------------------------
 private void Awake()
 {
     _prefab = MonoFactory.GetFactoryPrefab(this);
 }
Пример #8
0
 public virtual void ReturnToFactory()
 {
     Debug.Log($"{this.GetType().Name} returning to factory!");
     MonoFactory.ReturnFactoryObject(this);
 }