Exemplo n.º 1
0
        public static bool IsStillInsideSamePuzzle(this Pool pool, TilePos currentPosition, TilePos nextPosition)
        {
            var currentPuzzle = pool.GetEntityAt(currentPosition, x => x.isPuzzleArea && x.hasBossConnection);
            var nextPuzzle    = pool.GetEntityAt(nextPosition, x => x.isPuzzleArea && x.hasBossConnection);

            if (currentPuzzle != null && nextPuzzle != null)
            {
                return(nextPuzzle.bossConnection.BossId == currentPuzzle.bossConnection.BossId);
            }

            return(currentPuzzle == nextPuzzle);
        }
Exemplo n.º 2
0
        public static bool KnockObjectsInFront(this Pool pool, TilePos position, TilePos forwardDirection, bool immediate, float knockWait)
        {
            var knockable = pool.GetEntityAt(position + forwardDirection, x => x.isBlockingTile);

            if (knockable != null)
            {
                knockable.ReplaceKnocked(forwardDirection, immediate, knockWait);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        public void Execute(List <Entity> entities)
        {
            var hero          = entities.SingleEntity();
            var moveDirection = hero.inputMove.Direction;
            var newPosition   = moveDirection + hero.position.Value;

            var canMoveTo             = _pool.OpenTileAt(newPosition);
            var stillInsideSamePuzzle = _pool.IsStillInsideSamePuzzle(hero.position.Value, newPosition);

            if (canMoveTo && !(hero.isSpikesCarried && !stillInsideSamePuzzle))
            {
                hero.ReplacePosition(newPosition);
                hero.ReplaceRotation(LocalDirections.ToRotation(moveDirection));
            }
            else
            {
                var hasKnockedObjectInFront = _pool.KnockObjectsInFront(hero.position.Value, moveDirection, true, 0.4f);
                if (hasKnockedObjectInFront)
                {
                    var knockedObject   = _pool.GetEntityAt(newPosition, x => x.hasKnocked);
                    var pushableCanMove = _pool.OpenTileAt(newPosition + moveDirection);
                    if (pushableCanMove && knockedObject.isBox)
                    {
                        hero.IsPushing(true);
                        hero.ReplacePosition(newPosition);
                    }
                    else
                    {
                        hero.HasBumpedIntoObject(true);
                    }

                    hero.ReplaceRotation(LocalDirections.ToRotation(moveDirection));
                }
                else
                {
                }
            }
        }
Exemplo n.º 4
0
 public static Entity GetAreaAt(this Pool pool, TilePos position)
 {
     return(pool.GetEntityAt(position, x => x.gameObject.Type == ObjectType.Area));
 }
Exemplo n.º 5
0
        public static Entity GetCurrentPuzzleArea(this Pool pool)
        {
            var hero = pool.GetHero();

            return(pool.GetEntityAt(hero.position.Value, x => x.isPuzzleArea));
        }