コード例 #1
0
    bool PrepareMove(Entity player, ICollection<Entity> entitiesInSpot)
    {
        if (entitiesInSpot.ContainsComponent(ComponentIds.AIMove))
        {
            // enemy there, can't do anything
            return false;
        }

        // handle walls
        Entity wall = null;
        if (entitiesInSpot.ContainsComponent(ComponentIds.Destructible, out wall))
        {
            wall.DamageDestructible();
            pool.PlayAudio(player.audioAttackSource);

            if (player.hasView)
            {
                player.AddAnimation(Animation.playerChop);
            }
            // nothing to do now that we've chopped
            return false;
        }

        // otherwise we can move
        return true;
    }
コード例 #2
0
    bool PrepareMove(Entity enemy, ICollection<Entity> entitiesInSpot)
    {
        // handle player
        Entity player;
        if (enemy.hasFoodDamager &&
            entitiesInSpot.ContainsComponent(ComponentIds.Controllable, out player))
        {
            pool.AddToFoodBag(-enemy.foodDamager.points);
            pool.PlayAudio(enemy.audioAttackSource);
            enemy.AddAnimation(Animation.enemyAttack);
            player.AddAnimation(Animation.playerHit);
            // can't move
            return false;
        }

        if (entitiesInSpot.Count == 1 &&
            entitiesInSpot.ContainsComponent(ComponentIds.Food))
        {
            return true;
        }

        return false;
    }