Exemplo n.º 1
0
        private void Shoot(Portal portal)
        {
            PortalGunShot shot = new PortalGunShot(Position + new Vector2(SpriteRect.Width / 2, SpriteRect.Height / 2), portal);

            if (viewDirection == SideDirections.Left)
            {
                shot.Velocity.X    = -50;
                shot.ViewDirection = viewDirection;
                hasShot            = true;
            }
            else if (viewDirection == SideDirections.Right)
            {
                shot.Velocity.X    = 50;
                shot.ViewDirection = viewDirection;
                hasShot            = true;
            }
        }
Exemplo n.º 2
0
        private Vector2 GetPortalablePosition(Vector2 portalPosition)
        {
            PortalGunShot shot = new PortalGunShot(Position + offset);

            while (hasMoved)
            {
                Tile currentTile = map.GetTile(shot.Position);

                if (currentTile is IronWall)
                {
                    break;
                }

                foreach (var item in SceneManager.CurrentScene.GameObjects)
                {
                    if ((item is TopDownMaterialEmancipationGrill && ((TopDownMaterialEmancipationGrill)item).isOn) || item is Portal)
                    {
                        if (((Entity)item).Position == shot.Position)
                        {
                            shot.Destroy();
                            return(portalPosition);
                        }
                    }
                }

                if (currentTile.IsPortalable)
                {
                    Vector2 shotPosition = shot.Position;
                    shot.Destroy();
                    return(shotPosition);
                }

                MoveInPlayersViewDirection(shot);
            }
            shot.Destroy();
            return(portalPosition);
        }