Esempio n. 1
0
        public void DoPlayerDisconnected(GUIPlayer player)
        {
            if (IsFirstOrLast)
            {
                VisualState = PlayersStates[player].Clone();
                PPVisual.Hide();
            }

            PlayersStates.Remove(player);
        }
Esempio n. 2
0
        public void RemoveCelestialObject(GUIPlayer player, CelestialBody obj)
        {
            var state = PlayersStates[player];

            if (state.PathState == PathState.ObjectRemoved)
                return;

            if (IsFirstOrLast)
                PPVisual.Cancel();

            state.ChangeState(PathState.ObjectRemoved, NewPath, obj);

            if (IsFirstOrLast)
            {
                VisualState = state.Clone();
                PPVisual.Show();
            }
        }
Esempio n. 3
0
        public void AddCelestialObject(GUIPlayer player, CelestialBody obj)
        {
            var state = PlayersStates[player];

            if (state.PathState == PathState.ObjectAdded || ActualPath.ContainsCelestialBody(obj))
                return;

            if (IsFirstOrLast)
                PPVisual.Cancel();

            state.ChangeState(PathState.ObjectAdded, NewPath, obj);

            if (IsFirstOrLast)
            {
                VisualState = state.Clone();
                PPVisual.Show();
            }
        }
Esempio n. 4
0
 public PlayerState(GUIPlayer player)
 {
     Player = player;
     CelestialBody = null;
     PathState = PathState.None;
 }
Esempio n. 5
0
 public void DoPlayerConnected(GUIPlayer player)
 {
     PlayersStates.Add(player, new PlayerState(player));
 }
Esempio n. 6
0
        public void RollBack(GUIPlayer player)
        {
            var state = PlayersStates[player];

            if (state.PathState == PathState.None)
                return;

            if (IsFirstOrLast)
            {
                PPVisual.Cancel();
                VisualState = state.Clone();
                PPVisual.Hide();
                state.DeferredRollBack();
            }

            else
            {
                state.RollBack(NewPath);
            }
        }
Esempio n. 7
0
        public void Commit(GUIPlayer player)
        {
            var state = PlayersStates[player];

            if (state.PathState == PathState.None)
                return;

            if (IsFirstOrLast)
            {
                VisualState = null;
                PPVisual.Hide();
            }

            state.Commit(NewPath);
        }
Esempio n. 8
0
        public void Initialize()
        {
            Players.Clear();

            GamePausedResistance = new TheResistance(Simulator)
            {
                Enemies = new List<Enemy>(),
                AlphaChannel = 100
            };
            GamePausedResistance.Initialize();
            
            LevelStartedAnnunciation = new LevelStartedAnnunciation(Simulator, Level);
            LevelEndedAnnunciation = new LevelEndedAnnunciation(Simulator, Path, Level);

            PathPreviewing = new PathPreview(PathPreview, Path);

            MenuPowerUps.Turrets = Turrets;
            MenuPowerUps.AvailablePowerUps = AvailablePowerUps;
            MenuPowerUps.Initialize();

            StartingPathMenu.RemainingWaves = (InfiniteWaves == null) ? Waves.Count : -1;
            StartingPathMenu.TimeNextWave = (InfiniteWaves == null && Waves.Count != 0) ? Waves.First.Value.StartingTime : 0;
            NextWavePreview.RemainingWaves = (InfiniteWaves == null) ? Waves.Count : -1;
            GameBarPanel.RemainingWaves = (InfiniteWaves == null) ? Waves.Count : -1;


            if (!Simulator.DemoMode)
            {
                AdvancedView = new AdvancedView(Simulator);
                AdvancedView.Enemies = Enemies;
                AdvancedView.CelestialBodies = CelestialBodies;
                AdvancedView.Initialize();
            }

            GamePausedMenuPlayerCheckedIn = null;
            AdvancedViewCheckedIn = null;

            HelpBar.ActiveOptions = Main.Options.ShowHelpBar;
            HelpBar.Initialize();

            CelestialBodyNearHit = new CelestialBodyNearHitAnimation(Simulator)
            {
                CelestialBody = Level.CelestialBodyToProtect,
                EnemiesData = EnemiesData
            };

            AlienNextWaveAnimation = new AlienNextWaveAnimation(Simulator)
            {
                CelestialBody = Path.FirstCelestialBody,
                TimeNextWave = StartingPathMenu.TimeNextWave
            };

            lastEnemiesToReleaseCount = -1;

            GameBarPanel.Initialize();
        }
Esempio n. 9
0
        public void DoPlayerSelectionChanged(SimPlayer p)
        {
            var selection = p.ActualSelection;
            var player = Players[p];

            BeginHelpMessages(p);

            // Firing
            player.Cursor.ShowFiringCursor = p.Firing;

            if (!Simulator.DemoMode)
            {
                // Check in the starting path menu
                if (StartingPathMenu.CheckedIn == null && selection.CelestialBody != null && selection.CelestialBody.FirstOnPath)
                {
                    StartingPathMenu.CelestialBody = selection.CelestialBody;
                    StartingPathMenu.Visible = true;
                    StartingPathMenu.CheckedIn = p;
                    StartingPathMenu.Color = p.Color;
                    StartingPathMenu.Position = p.Position;

                    player.CelestialBodyMenu.Visible = false;
                }

                // Check out the starting path menu
                if (StartingPathMenu.CheckedIn == p && (selection.CelestialBody == null || !selection.CelestialBody.FirstOnPath))
                {
                    StartingPathMenu.Visible = false;
                    StartingPathMenu.CheckedIn = null;
                }
            }

            // Open the celestial body menu
            if (StartingPathMenu.CheckedIn != p)
            {
                player.CelestialBodyMenu.CelestialBody = selection.CelestialBody;
                player.CelestialBodyMenu.TurretToBuy = selection.TurretToBuy;
                player.CelestialBodyMenu.Visible = selection.TurretToPlace == null && selection.CelestialBody != null;
            }


            if (selection.PowerUpToBuy != PowerUpType.None)
                MenuPowerUps.PowerUpToBuy = selection.PowerUpToBuy;

            player.TurretMenu.Turret = selection.Turret;
            player.TurretMenu.AvailableTurretOptions = selection.AvailableTurretOptions;
            player.TurretMenu.SelectedOption = selection.TurretChoice;
            player.TurretMenu.Visible = player.TurretMenu.Turret != null && !player.TurretMenu.Turret.Disabled;

            if (Simulator.WorldMode)
            {
                player.WorldMenu.CelestialBody = selection.CelestialBody;
                player.WorldMenu.PausedGameChoice = selection.PausedGameChoice;

                if (GamePausedMenuPlayerCheckedIn == null && player.WorldMenu.PausedGameMenuVisible)
                {
                    GamePausedMenuPlayerCheckedIn = player;
                    player.WorldMenu.PausedGameMenuCheckedIn = true;
                }

                else if (GamePausedMenuPlayerCheckedIn == player && selection.CelestialBody == null)
                {
                    GamePausedMenuPlayerCheckedIn = null;
                    player.WorldMenu.PausedGameMenuCheckedIn = false;
                }
            }

            if (Simulator.DemoMode)
            {
                player.NewGameMenu.CelestialBody = selection.CelestialBody;
                player.NewGameMenu.NewGameChoice = selection.NewGameChoice;
            }

            player.SelectedCelestialBodyAnimation.CelestialBody = selection.CelestialBody;

            player.FinalSolutionPreview.CelestialBody =
                (player.PowerUpFinalSolution) ? selection.CelestialBody : null;

            if (!Simulator.EditorMode || (Simulator.EditorMode && Simulator.EditorState == EditorState.Playtest))
            {
                if (PathPreviewing != null && // preview: sell turret
                    selection.Turret != null &&
                    selection.Turret.Type == TurretType.Gravitational &&
                    selection.Turret.CanSell &&
                    !selection.Turret.Disabled &&
                    selection.TurretChoice == TurretChoice.Sell)
                    PathPreviewing.RemoveCelestialObject(player, selection.Turret.CelestialBody);
                else if (PathPreviewing != null && //preview: final solution
                    selection.CelestialBody != null &&
                    player.PowerUpFinalSolution &&
                    selection.CelestialBody.HasGravitationalTurret)
                    PathPreviewing.RemoveCelestialObject(player, selection.CelestialBody);
                else if (PathPreviewing != null && //preview: buy grav. turret
                    selection.TurretToBuy == TurretType.Gravitational)
                    PathPreviewing.AddCelestialObject(player, selection.CelestialBody);
                else if (PathPreviewing != null && //preview: place grav. turret
                    selection.TurretToPlace != null &&
                    selection.TurretToPlace.Type == TurretType.Gravitational)
                    PathPreviewing.AddCelestialObject(player, selection.CelestialBody);
                else if (PathPreviewing != null && //preview: update turret
                    selection.Turret != null &&
                    selection.Turret.Type == TurretType.Gravitational &&
                    selection.Turret.CanUpdate &&
                    selection.TurretChoice == TurretChoice.Update &&
                    selection.Turret.Level <= 1)
                    PathPreviewing.UpgradeCelestialObject(player, selection.Turret.CelestialBody);
                else if (PathPreviewing != null) //preview: rollback
                    PathPreviewing.RollBack(player);
            }
        }
Esempio n. 10
0
        public void DoHideAdvancedViewAsked(SimPlayer p)
        {
            if (Simulator.DemoMode)
                return;

            var player = Players[p];

            if (AdvancedViewCheckedIn == player)
            {
                AdvancedView.Visible = false;
                AdvancedViewCheckedIn = null;
            }
        }
Esempio n. 11
0
        public void DoShowAdvancedViewAsked(SimPlayer p)
        {
            if (Simulator.DemoMode)
                return;

            var player = Players[p];

            if (AdvancedViewCheckedIn == null)
            {
                AdvancedView.Visible = true;
                AdvancedViewCheckedIn = player;
            }
        }
Esempio n. 12
0
        public void DoPlayerConnected(SimPlayer p)
        {
            GUIPlayer player = new GUIPlayer(
                Simulator, AvailableTurrets, AvailableLevelsDemoMode,
                p.Color, p.ImageName, p.BasePlayer.InputType);

            player.Cursor.Position = p.Position;

            Players.Add(p, player);

            PathPreviewing.DoPlayerConnected(player);

            HelpBar.ActivePlayers = Players.Count <= 1;

            player.Cursor.TeleportIn();
            player.Cursor.FadeIn();
        }