Exemple #1
0
    //Check whether the pawn is able to move
    protected bool Move()
    {
        do
        {
            if (CheckForWall())
            {
                return(false);
            }
            if (!InRange())
            {
                return(false);
            }
        } while (false);

        otherPos  = currCell.coordinates + dir.ToIntVec2();
        otherCell = cells[otherPos.x, otherPos.y];

        //Check otherCell to see if it contains an enemy or player, if the enemy
        //sees the player in the other cell they will stop to "take a shot"
        for (int i = 0; i < otherCell.transform.childCount; i++)
        {
            string tag = otherCell.transform.GetChild(i).tag;
            if (tag == "Enemy")
            {
                return(false);
            }
            else if (tag == "Player")
            {
                stop = true;
                return(false);
            }
        }

        //move position of pawn and update parentz
        transform.position += dir.ToVec3();
        transform.parent    = otherCell.transform;
        return(true);
    }