Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        hp -= 0.003f;


        if (wolfStates == _states.hunting)
        {
            currentWolfPos = WolfnewPos;
            if (transform.position.x != WolfnewPos.x)
            {
                transform.position = Vector3.MoveTowards(transform.position, new Vector3(WolfnewPos.x, WolfoldPos.y), 1f * Time.deltaTime);
            }
            else if (transform.position.x == WolfnewPos.x)
            {
                transform.position = Vector3.MoveTowards(transform.position, new Vector3(WolfnewPos.x, WolfnewPos.y), 1f * Time.deltaTime);
                if (transform.position.x == WolfnewPos.x && transform.position.y == WolfnewPos.y)
                {
                    if (grid.WolfEating(this) == false)
                    {
                        this.GetComponent <SpriteRenderer>().color = NormalColor;
                        Startimus();
                    }
                    else
                    {
                        hp += 5;
                        this.GetComponent <SpriteRenderer>().color = EatingColor;
                    }
                }
            }
        }

        if (hp >= 30)
        {
            grid.AddWolf(currentWolfPos.x, currentWolfPos.y);
            hp = 5;
        }

        if (hp <= 0)
        {
            currentWolfPos = grid.ClosestTile(this);
            grid.AddWolfGrass(currentWolfPos.x, currentWolfPos.y, this);
            Destroy(gameObject);
        }
    }