Esempio n. 1
0
    void Attacked(bool attacked)
    {
        if (JoystickMove.isAttack == true && playerAttacked == true)
        {
            return;
        }

        playerAttacked = JoystickMove.isAttack;

        if (playerAttacked == true)
        {
            hp -= PlayerInfo.playerAtt1;
            Debug.Log(hp);
        }

        if (hp <= 0.0f)
        {
            if (true)
            {
                AnimalAI ai = GetComponent <AnimalAI>();
                this.GetComponent <AnimalMoveAgent>().Stop();
                animator.SetBool("isPlayers", true);

                ai.SetAnimalType(AnimalAI.AnimalType.Player);
                PlayerInfo.clickTarget.SetLayer(21);
                PlayerInfo.clickTarget.transform.Find("Mark Canvas").gameObject.SetActive(false);
                PlayerInfo.clickTarget = null;
            }
            else
            {
                GetComponent <AnimalAI>().state = AnimalAI.AnimalState.Die;

                hpBarImage.GetComponentsInParent <Image>()[1].color = Color.clear;
            }
        }
    }