Exemple #1
0
 protected override void Execute(List <PoolEntity> entities)
 {
     if (!pool.isGameOver && pool.hasFoodBag && pool.foodBag.points <= 0)
     {
         pool.isGameOver = true;
         pool.PlayAudio(pool.controllableEntity.audioDeathSource);
     }
 }
Exemple #2
0
    protected override void Execute(List <PoolEntity> entities)
    {
        if (pool.isGameOver ||
            pool.isLevelTransitionDelay ||
            !pool.hasMoveInput ||
            !pool.isControllable ||
            !pool.controllableEntity.isActiveTurnBased)
        {
            // ignore input
            return;
        }

        var controllable = pool.controllableEntity;

        pool.ReplaceFoodBag(pool.foodBag.points - 1);

        var movement    = pool.moveInput.movement;
        var movementPos = ToVector(movement);

        var currentPos = controllable.position;
        int newX       = currentPos.x + (int)movementPos.x;
        int newY       = currentPos.y + (int)movementPos.y;

        ICollection <PoolEntity> existing;
        bool canMove = pool.IsGameBoardPositionOpen(newX, newY, out existing);

        if (existing != null)
        {
            canMove = PrepareMove(controllable, existing);
        }

        if (canMove)
        {
            pool.PlayAudio(controllable.audioWalkSource);
            controllable.ReplacePosition(newX, newY);
        }

        controllable.isActiveTurnBased = false;
    }
Exemple #3
0
    protected override void Execute(List <PoolEntity> entities)
    {
        var position = pool.controllableEntity.position;
        ICollection <PoolEntity> posEntities;

        pool.IsGameBoardPositionOpen(position, out posEntities);

        PoolEntity food;

        if (posEntities != null &&
            posEntities.ContainsComponent(PoolComponentsLookup.Food, out food))
        {
            int points = food.food.points;
            pool.PlayAudio(food.audioPickupSource);
            pool.AddToFoodBag(points);
            pool.DestroyEntity(food);
        }
    }
Exemple #4
0
    bool PrepareMove(PoolEntity enemy, ICollection <PoolEntity> entitiesInSpot)
    {
        // handle player
        PoolEntity player;

        if (enemy.hasFoodDamager &&
            entitiesInSpot.ContainsComponent(PoolComponentsLookup.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(PoolComponentsLookup.Food))
        {
            return(true);
        }

        return(false);
    }