示例#1
0
    public static PoolEntity AddToFoodBag(this PoolContext context,
                                          int pointsToAdd)
    {
        int existingPoints = context.foodBag.points;

        context.ReplaceFoodBag(pointsToAdd + existingPoints);
        return(context.foodBagEntity);
    }
示例#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;
    }