示例#1
0
    public void DistAttackToTile(Tile tile)
    {
        StatsScript stats = gameObject.GetComponent <StatsScript>();

        if (tile.npc != null && tile.npc != gameObject)
        {
            if (stats.stamina >= distAttackCost)
            {
                stats.UseStamina(distAttackCost);

                tile.target = true;
                attacking   = true;
                stack.Clear();

                stack.Push(tile);
            }
            else
            {
                return;
            }
        }
        else
        {
            tile.failAttack = true;
        }
    }
示例#2
0
    public void MoveToTile(Tile tile)
    {
        //Here we calculate how much stamina use
        StatsScript stats  = gameObject.GetComponent <StatsScript>();
        int         wasted = tile.dist;

        //////////Case to Enemy
        if (gameObject.tag == "Enemy")
        {
            if (stats.stamina - move >= 0)
            {
                wasted = move;
            }
            else if (stats.stamina - move > -move)
            {
                move = (int)stats.stamina;
                NPCActionScript npcAction = gameObject.GetComponent <NPCActionScript>();
                npcAction.FindNearestTarget();
                npcAction.CalculatePath();
                wasted = (int)stats.stamina;
                move   = maxMoveAI;
                return;
            }
            else
            {
                wasted = -1;
            }
        }
        /////////////////

        if (stats.stamina >= wasted && wasted != -1)
        {
            stats.UseStamina(wasted);
            tile.target = true;
            moving      = true;
            stack.Clear();

            Tile next = tile;
            while (next != null)
            {
                stack.Push(next);
                next = next.parent;
            }
        }
    }