Esempio n. 1
0
    protected override void act()
    {
        //move or attack
        spaceComponent nextSpace = mySpace.choseSpaceWithAheads(playerUnit);

        if (!nextSpace)
        {
            return;
        }
        else if (nextSpace == mySpace)
        {
            // player takes damage
            if (playerUnit)
            {
                GameObject.Find("EnemyObject").GetComponent <playerManager>().health--;
                if (evolved)
                {
                    GameObject.Find("EnemyObject").GetComponent <playerManager>().health--;
                }
            }
            else
            {
                GameObject.Find("PlayerObject").GetComponent <playerManager>().health--;
                if (evolved)
                {
                    GameObject.Find("PlayerObject").GetComponent <playerManager>().health--;
                }
            }

            AudioMan.inst.PlayHit();

            mySpace.removeUnit();
            Destroy(myHealthBar);
            Destroy(gameObject);
            return;
        }

        if (nextSpace.unit)
        {
            if (nextSpace.unit.takeDamage(damage))
            {
                nextSpace.removeUnit();
            }
        }
        else
        {
            mySpace.removeUnit();
            mySpace = nextSpace;
            nextSpace.addUnit(this);

            // move the dude
            GetComponent <Animator>().SetTrigger("Jump");
            location = nextSpace.transform.position;
            Invoke("setMove", 0.2F);
        }
    }
Esempio n. 2
0
    protected override void act()
    {
        //move or attack
        spaceComponent nextSpace = mySpace.chooseSpace(playerUnit);

        if (!nextSpace)
        {
            //Debug.Log("Unable to move, wating for next turn.");
            return;
        }
        else if (nextSpace == mySpace)
        {
            AudioMan.inst.PlayHit();

            // player takes damage
            if (playerUnit)
            {
                GameObject.Find("EnemyObject").GetComponent <playerManager>().health--;
                if (evolved)
                {
                    GameObject.Find("EnemyObject").GetComponent <playerManager>().health--;
                }
            }
            else
            {
                GameObject.Find("PlayerObject").GetComponent <playerManager>().health--;
                if (evolved)
                {
                    GameObject.Find("PlayerObject").GetComponent <playerManager>().health--;
                }
            }

            mySpace.removeUnit();
            Destroy(myHealthBar);
            Destroy(gameObject);
            return;
        }

        bool killed = false;

        if (nextSpace.unit)
        {
            //Debug.Log("Attacking!");
            peacefulSpaces = 1;

            if (nextSpace.unit.takeDamage(damage))
            {
                killed = true;
                nextSpace.removeUnit();
            }
        }
        if (!nextSpace.unit || killed)
        {
            //Debug.Log("Moving to a new space");
            if (!killed)
            {
                peacefulSpaces++;
            }

            mySpace.removeUnit();
            mySpace = nextSpace;
            nextSpace.addUnit(this);

            // move the dude
            GetComponent <Animator>().SetTrigger("Jump");
            location = nextSpace.transform.position;
            Invoke("setMove", 0.2F);
        }
    }