Ejemplo n.º 1
0
        void Shoot(bool left, JoinedPlayer player)
        {
            var ship = MainMenuGum.JoinedPlayerContainer.Children
                       .FirstOrDefault(item => item.SailDesignState == player.ShipType.ToGum());

            var bulletVelocity = 600f;
            var z = 20;
            ContainerRuntime runtime;

            if (left)
            {
                runtime = ship.GetGunLeft;
            }
            else
            {
                runtime = ship.GetGunRight;
            }

            var gumCamera =
                RenderingLibrary.SystemManagers.Default.Renderer.Camera;

            var screenX = runtime.GetAbsoluteX() * gumCamera.Zoom + Camera.Main.DestinationRectangle.Left;
            var screenY = runtime.GetAbsoluteY() * gumCamera.Zoom + Camera.Main.DestinationRectangle.Top;

            var bullet = BulletFactory.CreateNew(LayerInstance);

            bullet.Position = new Vector3()
            {
                X = Camera.Main.WorldXAt(screenX, z, LayerInstance),
                Y = Camera.Main.WorldYAt(screenY, z, LayerInstance),
                Z = z,
            };
            bullet.YVelocity     = 100;
            bullet.YAcceleration = -600;
            bullet.TeamIndex     = (int)ship.SailDesignState.Value;
            if (left)
            {
                bullet.XVelocity = -bulletVelocity;
                ship.StopAnimations();
                ship.RockRightAnimation.Play();
            }
            else
            {
                bullet.XVelocity = bulletVelocity;
                ship.StopAnimations();
                ship.RockLeftAnimation.Play();
            }
        }
Ejemplo n.º 2
0
        private void InitializeShips()
        {
            ShipFactory.RemoveList(this.DeadShipList);


            if (JoinedPlayerManager.JoinedPlayers.Count == 0)
            {
                var player = new JoinedPlayer();
                player.InputDevice = InputManager.Keyboard;
                player.ShipType    = ShipType.Gray;

                JoinedPlayerManager.JoinedPlayers.Add(player);
            }

#if DEBUG
            if (DebuggingVariables.CreateExtraShips)
            {
                var player = new JoinedPlayer();
                player.InputDevice = InputManager.Xbox360GamePads[2];
                player.ShipType    = ShipType.RedStripes;

                JoinedPlayerManager.JoinedPlayers.Add(player);
            }
#endif

            int index = 0;
            foreach (var player in JoinedPlayerManager.JoinedPlayers)
            {
                var ship = ShipFactory.CreateNew();
                ship.RotationZ = MathHelper.ToRadians(90);
                ship.SetTeam(index);
                ship.SetSail(player.ShipType.ToSailColor());
                ship.InitializeRacingInput(player.InputDevice);
                ship.AfterDying += ReactToShipDying;
                ship.BulletHit  += ReactToBulletHit;

                // create local var:
                var shipIndex = index;
                ship.BulletShot += () => CameraControllerList[shipIndex].DoShake();
                index++;
            }
        }
Ejemplo n.º 3
0
 public static void RemovePlayer(JoinedPlayer player) => joinedPlayers.Remove(player);