public override void Update(GameTime gameTime) { for (int i = 0; i < ListLayer.Count; ++i) { ListLayer[i].Update(gameTime); } if (!IsInit) { Init(); } else if (MovementAnimation.Count > 0) { MoveSquad(); } else if (ListPlayer.Count > 0) { if (!ListActionMenuChoice.HasMainPanel) { if (ListPlayer[ActivePlayerIndex].IsHuman) { ListActionMenuChoice.AddToPanelListAndSelect(new ActionPanelPlayerDefault(this, ActivePlayerIndex)); } else { } } ListActionMenuChoice.Last().Update(gameTime); } UpdateCursorVisiblePosition(gameTime); }
public override void Update(GameTime gameTime) { if (GameMode == 1) { OnlinePlayers.Update(); } if (!IsFrozen) { if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.K)) { ListLayer[0].LayerGrid = new Map3D(this, GraphicsDevice); } if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.L)) { ListLayer[0].LayerGrid = new CubeMap3D(this, GraphicsDevice); } if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.O)) { ListLayer[0].LayerGrid = new SphericalMap3D(this, GraphicsDevice); } if ((KeyboardHelper.KeyHold(Keys.LeftControl) || KeyboardHelper.KeyHold(Keys.RightControl)) && KeyboardHelper.KeyPressed(Keys.U)) { ListLayer[0].LayerGrid = ListLayer[0].OriginalLayerGrid; } foreach (MapLayer ActiveMapLayer in ListLayer) { ActiveMapLayer.Update(gameTime); } if (ListNextAnimationScreen.Count > 0) { PushScreen(ListNextAnimationScreen[0]); ListNextAnimationScreen.Remove(ListNextAnimationScreen[0]); } else { if (!IsInit) { Init(); } else if (MovementAnimation.Count > 0) { MoveSquad(); } else if (GameMode == 0 || (GameMode == 1 && !ListPlayer[ActivePlayerIndex].IsOnline)) { ListActionMenuChoice.Last().Update(gameTime); } UpdateCursorVisiblePosition(gameTime); } } }
public override void Draw(CustomSpriteBatch g) { g.End(); g.Begin(SpriteSortMode.Deferred, null); if (IsOnTop) { if (ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Draw(g); } } }
public override void Update(double ElapsedSeconds) { GameTime UpdateTime = new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(ElapsedSeconds)); if (!IsInit) { if (ListGameScreen.Count == 0) { Load(); Init(); TogglePreview(true); if (ListGameScreen.Count == 0) { foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer) { ActivePlayer.Send(new ServerIsReadyScriptServer()); } } else { IsInit = false; } } else { ListGameScreen[0].Update(UpdateTime); if (!ListGameScreen[0].Alive) { ListGameScreen.RemoveAt(0); } if (ListGameScreen.Count == 0) { foreach (IOnlineConnection ActivePlayer in GameGroup.Room.ListOnlinePlayer) { ActivePlayer.Send(new ServerIsReadyScriptServer()); } IsInit = true; } } } LayerManager.Update(UpdateTime); if (!ListPlayer[ActivePlayerIndex].IsPlayerControlled && ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Update(UpdateTime); } }
public override void Draw(CustomSpriteBatch g) { g.End(); g.Begin(SpriteSortMode.Deferred, null); MapGrid.Draw(g); int Y = Constants.Height - 30; DrawBox(g, new Vector2(0, Y), 400, 30, Color.White); DrawText(g, "Ressources", new Vector2(5, Y + 5), Color.White); DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].EnergyReserve.ToString(), new Vector2(150, Y + 5), Color.White); DrawText(g, "Unit", new Vector2(155, Y + 5), Color.White); DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].ListUnit.Count.ToString(), new Vector2(220, Y + 5), Color.White); DrawText(g, "Constructions", new Vector2(225, Y + 5), Color.White); DrawTextRightAligned(g, ListPlayer[ActivePlayerIndex].ListConstruction.Count.ToString(), new Vector2(360, Y + 5), Color.White); if (ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Draw(g); } }
public override void Update(GameTime gameTime) { if (!IsInit) { Init(); } else if (MovementAnimation.Count > 0) { MoveSquad(); } else if (GameMode == 0) { if (!ListActionMenuChoice.HasMainPanel) { if (ListPlayer[ActivePlayerIndex].IsHuman) { ListActionMenuChoice.Add(new ActionPanelPlayerHumanStep(this)); } else { } } ListActionMenuChoice.Last().Update(gameTime); } UpdateCursorVisiblePosition(gameTime); for (int P = 0; P < ListPlayer.Count; P++) { for (int U = 0; U < ListPlayer[P].ListConstruction.Count; U++) { ListPlayer[P].ListConstruction[U].SpriteMap.Update(gameTime); if (ListPlayer[P].ListConstruction[U].SpriteMap.AnimationEnded) { ListPlayer[P].ListConstruction[U].SpriteMap.RestartAnimation(); } } } }
public override void Draw(CustomSpriteBatch g) { g.End(); g.Begin(SpriteSortMode.Deferred, null); if (ShowAllLayers) { for (int i = 0; i < ListLayer.Count; ++i) { ListLayer[i].Draw(g); } } else { ListLayer[ActiveLayerIndex].Draw(g); } if (IsOnTop) { if (ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Draw(g); } } }
public override void Draw(CustomSpriteBatch g) { if (!IsInit) { return; } //Handle screen shaking. if (IsShaking) { g.End(); //Run during initialization ShakingRenderTraget = new RenderTarget2D(GraphicsDevice, Constants.Width, Constants.Height, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); GraphicsDevice.SetRenderTarget(ShakingRenderTraget); g.Begin(); } if (ShowAllLayers) { for (int i = 0; i < ListLayer.Count; ++i) { ListLayer[i].Draw(g); } } else { ListLayer[ActiveLayerIndex].Draw(g); } if (IsOnTop) { if (ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.Last().Draw(g); } } #region Handle screen shaking. if (IsShaking) { g.End(); //Switches rendertarget back to backbuffer GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.Black); g.Begin(); // counter is a float initially set to zero ShakeCounter += 0.45f; Vector2 Translation = new Vector2(ShakeOffsetX + ShakeAngleVariation.X * (float)Math.Sin(ShakeCounter), ShakeOffsetY + ShakeAngleVariation.Y * (float)Math.Sin(ShakeCounter)); //Reached the peak of the sin function. if (ShakeCounter >= MathHelper.PiOver2) { //Remember where and how the shake ended. ShakeOffsetX = ShakeOffsetX + ShakeAngleVariation.X; ShakeOffsetY = ShakeOffsetY + ShakeAngleVariation.Y; //Calculate new shake angle. ShakeAngle = (ShakeAngle + 150 + RandomHelper.Next(60)) % 360; float Angle = MathHelper.ToRadians(ShakeAngle); ShakeAngleVariation.X = (float)Math.Cos(Angle); ShakeAngleVariation.Y = (float)Math.Sin(Angle); float DestinationX = ShakeRadiusMax * ShakeAngleVariation.X; float DestinationY = ShakeRadiusMax * ShakeAngleVariation.Y; ShakeAngleVariation.X = DestinationX - ShakeOffsetX; ShakeAngleVariation.Y = DestinationY - ShakeOffsetY; ShakeCounter = 0; if (IsShakingEnded) { IsShaking = false; } } g.Draw(ShakingRenderTraget, Translation, null, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.9f); } #endregion #region Handle fade to black if (FadeIsActive) { g.Draw(sprPixel, new Rectangle(0, 0, Constants.Width, Constants.Height), Color.FromNonPremultiplied(0, 0, 0, (int)FadeAlpha)); } #endregion }