예제 #1
0
    /// <summary>
    /// Changes the intention of the enemy based on the input recieved
    /// </summary>
    /// <param name="target">The target object or creature</param>
    public void changeIntent(GameObject target)
    {
        this.target = target;
        int currentIntent = (int)intent;

        // If the target is the player...
        if (targetIsPlayer())
        {
            // ...and we aren't on the "attack player" intent...
            if (currentIntent != (int)intentions.attackPlayer)
            {
                // Change the intent
                intent = intentions.attackPlayer;
                callChangeOfIntentions();
            }
        }
        // If the target is the castle...
        else if (targetIsCastle())
        {
            // ...and we aren't on the "attack castle" intent...
            if (currentIntent != (int)intentions.attackCastle)
            {
                // Change the intent
                intent = intentions.attackCastle;
                callChangeOfIntentions();
            }
        }
        // If the target is a troop...
        else if (targetIsTroop())
        {
            // ...and we aren't on the "attack troop" intent...
            if (currentIntent != (int)intentions.attackTroop)
            {
                // Change the intent
                intent = intentions.attackTroop;
                callChangeOfIntentions();
            }
        }
        // If the target isn't the player, castle, or a troop, change to the "wandering" intent
        else
        {
            this.target = this.gameObject;
            intent = intentions.wander;
            callChangeOfIntentions();
        }
    }
예제 #2
0
    /// <summary>
    /// Changes the intention of the troop based on the input recieved
    /// </summary>
    /// <param name="target">The target object or creature</param>
    public void changeIntent(GameObject target)
    {
        this.target = target;
        int currentIntent = (int)intent;

        // If the target is an enemy...
        if (targetIsEnemy())
        {
            // ...and we aren't on the "attack enemy" intent...
            if (currentIntent != (int)intentions.attackEnemy)
            {
                // Change the intent
                intent = intentions.attackEnemy;
                callChangeOfIntentions();
            }
        }
        // If the target is a collectible...
        else if (targetIsCollectible())
        {
            // ...and we aren't on the "get collectible" intent...
            if (currentIntent != (int)intentions.getCollectible)
            {
                // Change the intent
                intent = intentions.getCollectible;
                callChangeOfIntentions();
            }
        }
        // If the target is the castle...
        else if (targetIsCastle())
        {
            // ...and we aren't on the "protect castle" intent...
            if (currentIntent != (int)intentions.protectCastle)
            {
                // Change the intent
                intent = intentions.protectCastle;
                callChangeOfIntentions();
            }
        }
        // If the target isn't an enemy, collectible, or castle, change to the "wandering" intent
        else
        {
            this.target = this.gameObject;
            intent = intentions.wander;
            callChangeOfIntentions();
        }
    }