Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        MainMenuUI = GetComponentInChildren <DylanMainMenu>();
        GamePlayUI = GetComponentInChildren <DylanGamePlay>();
        GameOverUI = GetComponentInChildren <DylanGameOver>();

        if (SceneManager.GetActiveScene().buildIndex == 0)
        {
            MainMenuUI.gameObject.SetActive(true);
            GamePlayUI.gameObject.SetActive(false);
            GameOverUI.gameObject.SetActive(false);
        }
        else if (SceneManager.GetActiveScene().buildIndex == 1)
        {
            GamePlayUI.gameObject.SetActive(true);
            MainMenuUI.gameObject.SetActive(false);
            GameOverUI.gameObject.SetActive(false);
        }
        else if (SceneManager.GetActiveScene().buildIndex == 2)
        {
            GameOverUI.gameObject.SetActive(true);
            GamePlayUI.gameObject.SetActive(false);
            MainMenuUI.gameObject.SetActive(false);
        }
    }
Esempio n. 2
0
    public void PlayerDamage()
    {
        _cAction = PLAYERACTIONS.takeDamage;
        if (shield != true)
        {
            currentHealth -= 1;
        }
        else
        {
            shield = false;
            AddShield(shield);
        }

        if (playerGUI != null)
        {
            playerGUI.HPChange(currentHealth);
        }

        if (currentHealth == 0)
        {
            Instantiate(Resources.Load("BigExsplosion"), transform.position, transform.localRotation);
            EntityManager.ResetWave();
            acceleration = Vector3.zero;
            velocity     = Vector3.zero;
            _fsm.Transition(_fsm.state, PLAYERSTATES.dead);
            livesRemaining -= 1;
            if (livesRemaining >= 0)
            {
                LivesRemaining.RemoveLife();
                _cAction                = PLAYERACTIONS.die;
                transform.position      = spawnPosition;
                well.transform.position = spawnPosition;
                PlayerSpawn();
                currentHealth = maxHealth;
                if (GODMODE == true)
                {
                    livesRemaining += 1;
                }
            }
            else if (livesRemaining < 0)
            {
                _fsm.Transition(_fsm.state, PLAYERSTATES.destroyed);
                GameStates.ChangeState("GameOver");
            }
        }
        DylanGamePlay.UpdatePlayer(currentHealth, livesRemaining);
    }
Esempio n. 3
0
    /// <summary>
    /// Function calls
    /// PlayerBroadcast()
    /// </summary>
    void Start()
    {
        int round = (int)ScreenBorders.m_topLeft.x + 2;

        startPosition.x = (float)round;
        gameObject.name = "Player";              //Changes the name of the object to Player
        CheckPlayerBounds();                     //Checks to see if the player in within the game play area
        currentHealth  = maxHealth;              //Sets the current health equal to the maximumHealth
        livesRemaining = maxLives;               //Sets the lives remaining equal the the max lives
        SetPlayerControls();                     //Sets the controls the user uses to control the player
        well = FindObjectOfType <GravityWell>(); //Searchs for an object of type GravityWell and sets the return value equal to the well
        foreach (SpringJoint2D s in gameObject.GetComponents <SpringJoint2D>())
        {
            s.connectedBody = well.GetComponent <Rigidbody2D>();                                      //Sets the connected body of the springs attached to the player equal to the well's rigidbody
        }
        well.transform.position = new Vector3(spawnPosition.x - 2, spawnPosition.y, spawnPosition.z); //Sets the wells position to just behind the player
        transform.position      = spawnPosition;                                                      //Sets the player's position to be just out side the play area
        _fsm.Transition(_fsm.state, PLAYERSTATES.dead);                                               //Transitions the player to the dead state so it will start its spawning movement
        DylanGamePlay.UpdatePlayer(currentHealth, livesRemaining);
    }