Beispiel #1
0
    void Start()
    {
        rb2d = GetComponent<Rigidbody2D>();
        midX = Screen.width / 2;
        midY = Screen.height / 2;
        up = "w";
        down = "s";
        left = "a";
        right = "d";
        movestyles = movestyle.relative;
		anim = gameObject.GetComponent<Animator>();
        ClassStat = GetComponent<BaseClass>().ClassStat;
        GameData.PlayerPosition.Add(GameData.MyPlayer.PlayerID, transform.position);
    }
Beispiel #2
0
    /*---------------------------------------------------------------------------------------------------------------------
    *  -- METHOD: PlayerTookDamage
    *  --
    *  -- DATE: March 25th, 2016
    *  --
    *  -- REVISIONS: N/A
    *  --
    *  -- DESIGNER: Carson Roscoe
    *  --
    *  -- PROGRAMMER: Carson Roscoe
    *  --
    *  -- INTERFACE: void PlayerTookDamage(int playerID of the one taking data
    *  --                                  float newHP of the player after having taken data
    *  --                                  PlayerBaseStat class stats of the player in question)
    *  --
    *  -- RETURNS: void
    *  --
    *  -- NOTES:
    *  -- Handles what to do when someone takes damage in the game in regards to making the screen flash
    *  -- and killing our player if our health is below/equal to zero.
    *  ---------------------------------------------------------------------------------------------------------------------*/
    public void PlayerTookDamage(int playerID, float newHP, BaseClass.PlayerBaseStat ClassStat)
    {
        var damage = (ClassStat.CurrentHp - newHP);

        if (GameData.MyPlayer.PlayerID == playerID)
        {
            HUD_Manager.instance.UpdatePlayerHealth(-(damage / ClassStat.MaxHp));
            if (ClassStat.CurrentHp <= 0)
            {
                PlayerDied();
            }
            else
            {
                if (damage > 0)
                {
                    HUD_Manager.instance.colourizeScreen.PlayerHurt();
                }
                else if (damage < 0)
                {
                    HUD_Manager.instance.colourizeScreen.PlayerHealed();
                }
            }
        }
    }