/// <summary> /// Use this to Remove Sprites /// It will remove them from ingame to who those effected. /// and invoke the objectmanager. /// </summary> public void Remove <T>() where T : Sprite, new() { var nearby = GetObjects <Aisling>(i => i.WithinRangeOf(this)); var response = new ServerFormat0E(Serial); foreach (var o in nearby) { o?.Client?.Send(response); } if (this is Monster) { DelObject(this as Monster); } if (this is Aisling) { DelObject(this as Aisling); } if (this is Money) { DelObject(this as Money); } if (this is Item) { DelObject(this as Item); } if (this is Mundane) { DelObject(this as Mundane); } Map?.Update(X, Y, TileContent.None); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here base.Update(gameTime); inputManager.CaptureInput(gameTime); GameParameters.Update(gameTime); map.Update(gameTime); debugInfo.Update(recto, map, resolution, _graphics, GraphicsDevice.DisplayMode); elapsedMiliseconds += gameTime.ElapsedGameTime.TotalMilliseconds; debugOverlay.Update(debugInfo); if (elapsedMiliseconds > 1000) { RefreshFPSVariables(); } ++updateCounter; }
public override void Update(GameTime gameTime) { if (!oskHide) { oskHide = true; Game.KeyboardInput.IsOskVisable = false; } Game.SideBar.DesignWidth = 0; if (Game.KeyboardInput.TypedKey(Keys.Escape)) { Game.Sounds.Menu.Play(); SaveState(); PreviousMap = CurrentMap; Game.Arena = PreviousArena; } /*else if (Game.KeyboardInput.TypedKey(Keys.S)) * { * Game.Sounds.Menu.Play(); * NextMap(CurrentMap); * }*/ else if (Players.All(p => p.Par > 5 || p.State == Graphics.PlayerState.Done) && Game.KeyboardInput.TypedKey(Keys.S)) { Game.Sounds.Menu.Play(); NextMap(CurrentMap); } else { if (!Game.Transitioning) { CurrentMap.Update(gameTime); } } base.Update(gameTime); }
public void Update(float deltaTime) { if (NextSyncTime >= 10 * 1000) { Send(new GameTimerMessage(0, GameTime / 1000f)); NextSyncTime = 0; } BlueTeam.Update(deltaTime); PurpleTeam.Update(deltaTime); NeutralTeam.Update(deltaTime); Map.Update(deltaTime); foreach (var unit in UnitsToRemove) { Map.RemoveUnit(unit); unit.Team.RemoveUnit(unit); unit.DefineTeam(null); unit.DefineGame(null); } UnitsToRemove.Clear(); }
private void RunGame() { OnStarted(); Task.Factory.StartNew(() => { ManualResetEvent serverEndOfTurnWait = new ManualResetEvent(false); _endOfTurnWaitList.Add(serverEndOfTurnWait); _playersThatSentDataThisTurnArray = _playersThatSentDataThisTurnList.ToArray(); _endOfTurnWaitArray = _endOfTurnWaitList.ToArray(); //main game loop while (true) //issue [B.2.3] of the design document { WaitHandle.WaitAll(_playersThatSentDataThisTurnArray); //issue [B.2.3] of the design document _completeGameState.Update(_currentTurnClientActions); //issue [B.2.8] of the design document foreach (ManualResetEvent ev in _endOfTurnWaitArray) { ev.Reset(); } _gameStateProcessed.Set(); foreach (ManualResetEvent ev in _playersThatSentDataThisTurnArray) { ev.Reset(); } serverEndOfTurnWait.Set(); WaitHandle.WaitAll(_endOfTurnWaitArray); //issue [B.2.3] of the design document } _gameStateProcessed.Close(); serverEndOfTurnWait.Close(); }); }
protected override void Update(GameTime gameTime) { if (Form.ActiveForm == parentForm) { if (CurrentMap != null) { Viewport.Location = new Location(hscroll.Value, vscroll.Value); Camera.Position = new Vector2(hscroll.Value, vscroll.Value); InputProvider.Update(); CurrentMap.Update(gameTime.ElapsedGameTime.Milliseconds); MouseState ms = InputProvider.MouseState; if ((ms.X > 0) && (ms.Y > 0) && (ms.X < Camera.ViewPortWidth) && (ms.Y < Camera.ViewPortHeight)) { Vector2 mouseLoc = Camera.ScreenToWorld(new Vector2(ms.X, ms.Y)); int cellX = (int)MathHelper.Clamp(TileMap.GetCellByPixelX((int)mouseLoc.X), 0, TileMap.MapWidth - 1); int cellY = (int)MathHelper.Clamp(TileMap.GetCellByPixelY((int)mouseLoc.Y), 0, TileMap.MapHeight - 1); if (Camera.WorldRectangle.Contains((int)mouseLoc.X, (int)mouseLoc.Y)) { if (!RectangleMode) { if (ShortcutProvider.LeftButtonClicked()) { TileMap.GetMapSquareAtCell(cellX, cellY).Passable = Passable; } if (ShortcutProvider.RightButtonClicked()) { if (SetCode) { ((EditorForm)parentForm).SetCodeList(cellX, cellY); } else { ((EditorForm)parentForm).GetCodeList(TileMap.GetCellCodes(cellX, cellY)); } } } else { if (ShortcutProvider.LeftButtonClickedNowButNotLastFrame()) { if (!waitingForSecondClick) { startCell = new Vector2(cellX, cellY); waitingForSecondClick = true; } else { Vector2 endCell = new Vector2(cellX, cellY); waitingForSecondClick = false; for (int cellx = (int)startCell.X; cellx <= endCell.X; ++cellx) { for (int celly = (int)startCell.Y; celly <= endCell.Y; ++celly) { TileMap.GetMapSquareAtCell(cellx, celly).Passable = Passable; } } } } else if (ShortcutProvider.RightButtonClickedButNotLastFrame()) { if (!waitingForSecondClick) { startCell = new Vector2(cellX, cellY); waitingForSecondClick = true; } else { Vector2 endCell = new Vector2(cellX, cellY); waitingForSecondClick = false; for (int cellx = (int)startCell.X; cellx <= endCell.X; ++cellx) { for (int celly = (int)startCell.Y; celly <= endCell.Y; ++celly) { if (SetCode) { ((EditorForm)parentForm).SetCodeList(cellx, celly); } } } } } } } } } } base.Update(gameTime); }
public static Map ParseMap(string mapSizeStr, string productionMapStr, string gameMapStr) { var mapSize = ParseMapSize(mapSizeStr); var map = new Map(mapSize.Item1, mapSize.Item2); var productionValues = new Queue<string>(productionMapStr.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)); ushort x, y; for (y = 0; y < map.Height; y++) { for (x = 0; x < map.Width; x++) { ushort production; if (!ushort.TryParse(productionValues.Dequeue(), out production)) throw new ApplicationException("Could not get some production value from stdin"); map._sites[x, y].Production = production; } } map.Update(gameMapStr); return map; }
public void Update(GameTime gameTime) { playTime++; //inputState.Update(); //死んでいないと更新する if (!isClear && !isOver) { for (int i = 0; i < map.MapThings.Count; i++) { map.MapThings[i].Update(gameTime); } //プレイヤーの更新 player.Update(gameTime); //火の更新 for (int i = fires.Count - 1; i >= 0; i--) { fires[i].Update(gameTime); } //死んだ火を消す fires.RemoveAll(x => x.IsDead); // && x.IsOnGround //水の更新 foreach (var w in waterLines) { w.Update(gameTime); } waterLines.RemoveAll(x => x.IsDead); //マップの更新 map.Update(gameTime); //カメラの注視位置を更新 //camera.SetAimPosition(player.Position + new Vector2(player.ImageSize.Width / 2, player.ImageSize.Height / 2)); camera.MoveAimPosition(player.Position + new Vector2(player.Width / 2, player.Height / 2)); //Console.WriteLine(camera.OffSet); //マップ上にある炭の数を取得 nowCoals = map.MapThings.FindAll(x => x is Coal); //マップの更新 map.Update(gameTime); if (map.GetGoal() != null) { if (map.GetGoal().IsOnFire) { //柏 stageSever.ClearStage = mapIndex; stageSever.PlayTime = playTime / 60; stageSever.CurrentStage = mapIndex; stageSever.Charcoal = coals.Count - nowCoals.Count; stageSever.SaveStageData(); isClear = true; clearSelect.IsClear = true; } } //葉梨竜太 if (player.IsDead) { isOver = true; //isClear = true; //clearSelect.IsClear = true; } } // ClearWindow2が出るように変更(KeyもQに変更) By佐瀬拓海 if (gameDevice.GetInputState().CheckTriggerKey(Keys.Q, Parameter.MenuButton)) { if (isOver == false) { isOver = true; player.IsDead = true; } else if (isOver == true) { isOver = false; player.IsDead = false; } } clearSelect.Update(); isEnd = clearSelect.IsEnd; //clear窓口からend状態をとる if (isOver) //SceneのisOverで判断する { if (clearSelect.IsClear == true) { return; } clearSelect.Initialize(); clearSelect.IsClear = true; } else if (isOver == false && isClear == false) //isOver = falseでゲーム画面に戻れる By佐瀬拓海 { clearSelect.Initialize(); clearSelect.IsClear = false; } }
public void Update(GameTime gameTime) { motion.Update(gameTime); metoronome.Update(gameTime); map.Update(gameTime); sound.PlayBGM("Title"); gameObjectManager.Update(gameTime); float delta = (float)gameTime.ElapsedGameTime.TotalSeconds; particleManager.Update(delta); if (particleManager.IsCount(30)) { particleManager.TitleParticle("title", new Vector2(Screen.Width / 2, 200)); } if (player3.IsHit()) { if (!player3.IsStop()) { player3.SetPosition2(player4.GetPosition()); //if (player3.IsPush()) //{ // stop4 = false; // player4.stop = stop4; //} } else { player3.SetPosition2(player4.GetPosition()); } } if (player4.IsHit()) { if (!player4.IsStop()) { player4.SetPosition2(player3.GetPosition()); //if (player4.IsPush()) //{ // stop3 = false; // player3.stop = stop3; //} } else { player4.SetPosition2(player3.GetPosition()); } } if (!player3.IsStop() && !player4.IsStop()) { player3.SetPosition(new Vector2(128 * 6 + 15, 128 * 5 + 15)); player4.SetPosition(new Vector2(128 * 7 + 18, 128 * 5 + 18)); player4.stop = true; player3.stop = false; } if (Input.GetKeyState(Keys.Right)) { camera.Move(1, 0); } if (Input.GetKeyState(Keys.Left)) { camera.Move(-1, 0); } if (Input.GetKeyState(Keys.Up)) { camera.Move(0, -1); } if (Input.GetKeyState(Keys.Down)) { camera.Move(0, 1); } if (player3.IsDead() || player4.IsDead()) { isEndFlag = true; } }
public void Update(GameTime gameTime) { Map.Update(gameTime); }
/// <summary> /// Call every frame to update the map to the next one provided by the environment. /// </summary> public static void getFrame(ref Map map) { map.Update(ReadNextLine()); }
/// <summary> /// New search location has become available, begin a new _map query. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void SearchLocation_OnGeocoderResponse(object sender, EventArgs e) { _map.Center = _searchLocation.Coordinate; _map.Update(); }
public override void Update(float dt) { _camera.Update(); map.Update(dt); }
/// <summary> /// Call every frame to update the map to the next one provided by the environment. /// </summary> public static void getFrame(ref Map map) { var productions = ReadNextLine(); var game = ReadNextLine(); map.Update(productions, game); }
public static void Main() { int level = 0; int counter = 0, shootCoolDown = 0; int windowWidth = 1200; int windowHeight = 900; int speed = 5; // new shape and window opened new Window("Tank Game", windowWidth, windowHeight); // required objects Map gameMap = Map.GetInstance(1); LivesBoard scoreBoard = LivesBoard.GetInstance(gameMap); Fort fort = new Fort(gameMap); Player player = new Player(gameMap); EnemyPool enemyPool = EnemyPool.GetInstance(1, gameMap); do { SplashKit.ProcessEvents(); SplashKit.ClearScreen(); gameMap.DrawObjects(); scoreBoard.Draw(windowWidth, windowHeight); // load map - if new map is needed if (level != gameMap.Level) { level = gameMap.LoadNextLevel(level); enemyPool.UpdateMax(level); } // generate new enemies if needed if (SplashKit.Rnd(1, 500) <= 5) { enemyPool.GenerateEnemy(windowWidth, windowHeight); } // demo - turn up, down, left, right if (SplashKit.KeyDown(KeyCode.UpKey)) { player.Move(0, speed); } else if (SplashKit.KeyDown(KeyCode.DownKey)) { player.Move(0, -1 * speed); } else if (SplashKit.KeyDown(KeyCode.LeftKey)) { player.Move(speed, 0); } else if (SplashKit.KeyDown(KeyCode.RightKey)) { player.Move(-1 * speed, 0); } // press space - player shoot if (SplashKit.KeyTyped(KeyCode.SpaceKey) && shootCoolDown > 50) { player.Shoot(); shootCoolDown = 0; } // generate a random powerup if (counter >= 500 && gameMap.CountObjects("item") < 1) { gameMap.GenerateRndItem(windowWidth, windowHeight); counter = 0; } // delete the powerUp after awhile, also cancels powerups if (gameMap.CountObjects("item") > 0 && counter >= 500) { gameMap.RemoveObject(gameMap.GetObject("item")); counter = 0; } // cancels powerup effects after a while if (player.FireRate == 3 && counter >= 400) { player.FireRate = 1; shootCoolDown = 0; } gameMap.Update(); shootCoolDown++; counter++; SplashKit.RefreshScreen(60); } while (!SplashKit.WindowCloseRequested("Tank Game")); }
public void TowerDoesNotAttackEnemyOutsideItsRange() { //Move the enemy outside of the tower's range enemy.moveTo(1000, 1000); //Update method for map causes the towers to add nearby enemies map.Update(); Assert.AreEqual(0, tower.Enemies.Count); //Update method causes the tower to attack nearest enemy in its range for (int i = 0; i < tower.UpdateMax; i++) { tower.Update(); } //Verify that the enemy was not damaged Assert.AreEqual(10, enemy.Health); }
public void ChangeMapId() #endif { var map = new Map <ClassicRasterTile>(_fs); var mapObserver = new Utils.ClassicRasterMapObserver(); map.Subscribe(mapObserver); map.Center = new Vector2d(60.163200, 24.937700); map.Zoom = 13; map.MapId = "invalid"; map.Update(); #if UNITY_5_6_OR_NEWER IEnumerator enumerator = _fs.WaitForAllRequests(); while (enumerator.MoveNext()) { yield return(null); } #else _fs.WaitForAllRequests(); #endif Assert.AreEqual(0, mapObserver.Tiles.Count); map.MapId = "mapbox.terrain-rgb"; map.Update(); #if UNITY_5_6_OR_NEWER enumerator = _fs.WaitForAllRequests(); while (enumerator.MoveNext()) { yield return(null); } #else _fs.WaitForAllRequests(); #endif Assert.AreEqual(1, mapObserver.Tiles.Count); map.MapId = null; // Use default map ID. map.Update(); #if UNITY_5_6_OR_NEWER enumerator = _fs.WaitForAllRequests(); while (enumerator.MoveNext()) { yield return(null); } #else _fs.WaitForAllRequests(); #endif Assert.AreEqual(2, mapObserver.Tiles.Count); // Should have fetched tiles from different map IDs. Assert.AreNotEqual(mapObserver.Tiles[0], mapObserver.Tiles[1]); map.Unsubscribe(mapObserver); }
// METHODS // UPDATE & DRAW public void Update(MouseState mouse, KeyboardState keyboard, GameTime gameTime, GraphicsDevice graphics) { MainMap.Update(mouse, keyboard, gameTime, graphics); MainHUD.Update(keyboard, MainMap.liste_joueurs); }
// Update is called once per frame void Update() { map.Update(); }
/// <summary> /// Draws the specified word cloud given list of words and frequecies /// </summary> /// <param name="words">List of words ordered by occurance.</param> /// <param name="freqs">List of frequecies.</param> /// <param name="bgcolor">Backgroud color of the output image</param> /// <param name="img">Backgroud image of the output image</param> /// <returns>Image of word cloud.</returns> /// <exception cref="System.ArgumentException"> /// Arguments null. /// or /// Must have the same number of words as frequencies. /// </exception> private Image Draw(IList <string> words, IList <int> freqs, Color bgcolor, Image img) { #if DEBUG ShowIntegralImgStepDraw(Map.IntegralImageToBitmap()); _drawWaitHandle.Reset(); #endif var fontSize = MaxFontSize; if (words == null || freqs == null) { throw new ArgumentException("Arguments null."); } if (words.Count != freqs.Count) { throw new ArgumentException("Must have the same number of words as frequencies."); } Bitmap result; if (img == null) { result = new Bitmap(WorkImage.Width, WorkImage.Height); } else { if (img.Size != WorkImage.Bitmap.Size) { throw new Exception("The backgroud img should be with the same size with the mask"); } result = new Bitmap(img); } using (var gworking = Graphics.FromImage(WorkImage.Bitmap)) using (var gresult = Graphics.FromImage(result)) { if (img == null) { gresult.Clear(bgcolor); } gresult.TextRenderingHint = TextRenderingHint.AntiAlias; gworking.TextRenderingHint = TextRenderingHint.AntiAlias; var lastProgress = 0.0d; for (var i = 0; i < words.Count; ++i) { var progress = (double)i / words.Count; if (progress - lastProgress > 0.01) { ShowProgress(progress); lastProgress = progress; } if (!UseRank) { fontSize = (float)Math.Min(fontSize, 100 * Math.Log10(freqs[i] + 100)); } var format = new StringFormat(); if (AllowVertical) { if (Random.Next(0, 2) == 1) { format.FormatFlags = StringFormatFlags.DirectionVertical; } } Point p; bool foundPosition; Font font; Debug.WriteLine("Word: " + words[i]); do { font = new Font(Fontname, fontSize, GraphicsUnit.Pixel); var size = gworking.MeasureString(words[i], font, new PointF(0, 0), format); Debug.WriteLine("Search with font size: " + fontSize); foundPosition = Map.GetRandomUnoccupiedPosition((int)size.Width, (int)size.Height, out p); if (!foundPosition) { fontSize -= FontStep; } } while (fontSize > 0 && !foundPosition); Debug.WriteLine("Found pos: " + p); if (fontSize <= 0) { break; } gworking.DrawString(words[i], font, new SolidBrush(FontColor), p.X, p.Y, format); gresult.DrawString(words[i], font, new SolidBrush(FontColor), p.X, p.Y, format); Map.Update(WorkImage, p.X, p.Y); #if DEBUG if (StepDrawMode) { ShowResultStepDraw(new Bitmap(WorkImage.Bitmap)); ShowIntegralImgStepDraw(Map.IntegralImageToBitmap()); _drawWaitHandle.WaitOne(); } #endif } } WorkImage.Dispose(); return(result); }
/// <summary> /// New search location has become available, begin a new _map query. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void SearchLocation_OnGeocoderResponse(ForwardGeocodeResponse response) { _map.Center = _searchLocation.Coordinate; _map.Update(); }
public virtual void RunThread() { //线程初始化 Images_num = 0; threadTime = MyAPI.ZombieRunSpeed; int time = 0; int gameTime = Controller.GameTime; while (Controller.gameStatus != GameStatus.OVER && gameTime == Controller.GameTime) { //判断是否游戏暂停 if (Controller.gameStatus != GameStatus.STOP) { switch (RolesStatus) { case RoleStatus.NORMAL: break; case RoleStatus.MOVE: if (time % 4 == 0) { Move(); } break; case RoleStatus.ATTACK: if (time % 30 == 0) { Attack(); AttackTime++; } break; case RoleStatus.DISPEAR: //loaddeadImage(); Dispear(); return; //case RoleStatus.IsBoom: // ZombieBoomImage(); // RolesStatus = RoleStatus.DEAD; // break; case RoleStatus.DEAD: if (time % 4 == 0) { Move(); } if (Images_num == Images.Count - 1) { //loaddeadImage(); Map.delete(Map.Zombies, this); return; } break; } if (contactEnemy()) { RolesStatus = RoleStatus.ATTACK; loadAttackImage(); } if (Enemy != null && Enemy.Hp <= 0 && Enemy.RolesStatus != RoleStatus.DEAD) { loadImage(); Enemy.Hp = 0; RolesStatus = RoleStatus.MOVE; Enemy.RolesStatus = RoleStatus.DEAD; } time++; //更新图片 Images_num = (Images_num + 1) % Images.Count; // Form update Map.Update(); } Thread.Sleep(threadTime); } }
public void Call() { m_map.Update(m_diff); m_updater.UpdateFinished(); }
public override void Update(GameTime gameTime) { newKeyState = Keyboard.GetState(); newGamePadState = GamePad.GetState(PlayerIndex.One); cameraTimer.Update(gameTime); if (cameraTimer.GetAsSeconds() > cameraTimeToMove) { cameraTimer.Restart(); CameraLocator.Camera.Position = new Vector2(CameraLocator.Camera.Position.X + 1f, CameraLocator.Camera.Position.Y); ConfigLocator.Config.LeftBoundry = (int)Math.Ceiling(CameraLocator.Camera.Position.X); ConfigLocator.Config.RightBoundry = (int)ConfigLocator.Config.LeftBoundry + ConfigLocator.Config.VirtualWidth; player.box.X += 1; } player.MoveLeft = 0; player.MoveRight = 0; player.MoveUp = 0; player.MoveDown = 0; // Left if (newKeyState.IsKeyDown(Keys.A) || newKeyState.IsKeyDown(Keys.Left) || newGamePadState.IsButtonDown(Buttons.DPadLeft) || newGamePadState.ThumbSticks.Left.X < -0.5f) { player.MoveLeft = 1; } // Right if (newKeyState.IsKeyDown(Keys.D) || newKeyState.IsKeyDown(Keys.Right) || newGamePadState.IsButtonDown(Buttons.DPadRight) || newGamePadState.ThumbSticks.Left.X > 0.5f) { player.MoveRight = 1; } // Up if (newKeyState.IsKeyDown(Keys.W) || newKeyState.IsKeyDown(Keys.Up) || newGamePadState.IsButtonDown(Buttons.DPadUp) || newGamePadState.ThumbSticks.Left.Y > 0.5f) { player.MoveUp = 1; } // Down if (newKeyState.IsKeyDown(Keys.S) || newKeyState.IsKeyDown(Keys.Down) || newGamePadState.IsButtonDown(Buttons.DPadDown) || newGamePadState.ThumbSticks.Left.Y < -0.5f) { player.MoveDown = 1; } player.MoveHorizontal = player.MoveRight - player.MoveLeft; player.MoveVertical = player.MoveDown - player.MoveUp; // Shoot if (newKeyState.IsKeyDown(Keys.Space) && oldKeyState.IsKeyUp(Keys.Space) || newKeyState.IsKeyDown(Keys.Enter) && oldKeyState.IsKeyUp(Keys.Enter) || newGamePadState.IsButtonDown(Buttons.X) && oldGamePadState.IsButtonUp(Buttons.X)) { if (player.CanShoot) { AddObject(new BulletPlayerShip(player.box.X, player.box.Y)); player.CanShoot = false; player.ShootTimer.Restart(); } } map.Update(gameTime); UpdateObjects(gameTime); player.Update(gameTime); hud.Update(gameTime); CheckCollision(); oldKeyState = newKeyState; oldGamePadState = newGamePadState; }
public override void Update(GameTime gameTime) { //keyTimer.Tick(gameTime.ElapsedGameTime.TotalMilliseconds); // update background map (to play tile animations) background.Update(null); KeyboardState keyboardState = Keyboard.GetState(); // if down or up is pressed, change menu item "hovered" over (blue square in front of text will move along with currentMenuItemHovered changing) if (keyboardState.IsKeyDown(Keys.Down) && keyTimer.IsTimeUp()) { keyTimer.Reset(); currentMenuItemHovered++; } else if (keyboardState.IsKeyDown(Keys.Up) && keyTimer.IsTimeUp()) { keyTimer.Reset(); currentMenuItemHovered--; } // if down is pressed on last menu item or up is pressed on first menu item, "loop" the selection back around to the beginning/end if (currentMenuItemHovered > 2) { currentMenuItemHovered = 0; } else if (currentMenuItemHovered < 0) { currentMenuItemHovered = 2; } // sets location for blue square in front of text (pointerLocation) and also sets color of spritefont text based on which menu item is being hovered if (currentMenuItemHovered == 0) { playGameText.Color = new Color(255, 215, 0); creditsText.Color = new Color(49, 207, 240); settingsText.Color = new Color(49, 207, 240); pointerLocationX = 170; pointerLocationY = 155; } else if (currentMenuItemHovered == 1) { playGameText.Color = new Color(49, 207, 240); creditsText.Color = new Color(255, 215, 0); settingsText.Color = new Color(49, 207, 240); pointerLocationX = 170; pointerLocationY = 255; } else if (currentMenuItemHovered == 2) { playGameText.Color = new Color(49, 207, 240); creditsText.Color = new Color(49, 207, 240); settingsText.Color = new Color(255, 215, 0); pointerLocationX = 170; pointerLocationY = 355; } // if space is pressed on menu item, change to appropriate screen based on which menu item was chosen if (keyboardState.IsKeyUp(Keys.Space)) { keyLocker.UnlockKey(Keys.Space); } if (!keyLocker.IsKeyLocked(Keys.Space) && keyboardState.IsKeyDown(Keys.Space)) { menuItemSelected = currentMenuItemHovered; if (menuItemSelected == 0) { screenCoordinator.GameState = GameState.LEVEL; } else if (menuItemSelected == 1) { screenCoordinator.GameState = GameState.CREDITS; } else if (menuItemSelected == 2) { screenCoordinator.GameState = GameState.SETTINGS; } } }
public void DrawFieldOfView(IEntity entity, bool discoverUnexploredTiles = false) { // Check if there is a lightsource nearby, then explore all cells enlighted by it automatically var prevFov = entity.FieldOfViewRadius; entity.FieldOfViewRadius = Constants.Player.DiscoverLightsRadius; EntityManager.RecalculatFieldOfView(entity, false); // Get cells that emit light var cellsThatEmitLight = GridManager.Grid.GetCellsInFov(entity) .Where(a => a.LightProperties.EmitsLight && !a.CellProperties.IsExplored) .ToList(); // Actual cells we see foreach (var lightCell in cellsThatEmitLight) { var cell = GetNonClonedCell(lightCell.Position.X, lightCell.Position.Y); cell.CellProperties.IsExplored = true; cell.IsVisible = true; } // Reset entity fov if (prevFov != entity.FieldOfViewRadius) { entity.FieldOfViewRadius = prevFov; EntityManager.RecalculatFieldOfView(entity, false); } for (int x = 0; x < GridSizeX; x++) { for (int y = 0; y < GridSizeY; y++) { var cell = GetNonClonedCell(x, y); if (discoverUnexploredTiles && !cell.CellProperties.IsExplored) { if (entity.FieldOfView.BooleanFOV[x, y]) { cell.CellProperties.IsExplored = true; } } // Cells near light sources are automatically visible if (cell.LightProperties.Brightness > 0f && !cell.LightProperties.EmitsLight && !cell.CellProperties.IsExplored && cell.LightProperties.LightSources.Any(a => a.CellProperties.IsExplored)) { cell.CellProperties.IsExplored = true; } cell.IsVisible = cell.CellProperties.IsExplored; SetCellColors(cell); SetCell(cell); } } // Redraw the map if (Map != null) { Map.Update(); } }
private void OnMapUpdate(View view) { _map.Update(view.GameTime); }
public void Call() { m_map.Update(m_diff); }
private void Update() { if (TheForest.Utils.Input.GetButtonDown("Esc")) { Opened = false; RestoreEquipement(); } try { Overworld.Update(); Underworld.Update(); if (ModAPI.Input.GetButtonDown("OpenMap") && !ChatBox.IsChatOpen && LocalPlayer.Inventory.CurrentView != PlayerInventory.PlayerViews.Pause) { if (LocalPlayer.IsInCaves) { currentMap = Underworld; } else { currentMap = Overworld; } Opened = !Opened; ShowPhase = 0f; if (Opened) { ShouldEquipLeftHandAfter = !LocalPlayer.Inventory.IsLeftHandEmpty(); ShouldEquipRightHandAfter = !LocalPlayer.Inventory.IsRightHandEmpty(); if (!LocalPlayer.Inventory.IsRightHandEmpty()) { if (!LocalPlayer.Inventory.RightHand.IsHeldOnly) { LocalPlayer.Inventory.MemorizeItem(Item.EquipmentSlot.RightHand); } LocalPlayer.Inventory.StashEquipedWeapon(equipPrevious: false); } if (!LocalPlayer.Inventory.IsLeftHandEmpty()) { LocalPlayer.Inventory.MemorizeItem(Item.EquipmentSlot.LeftHand); LocalPlayer.Inventory.StashLeftHand(); } } else { RestoreEquipement(); } } if (Opened) { if (currentMap.TexturesLoaded && ShowPhase < 1f) { ShowPhase += Time.unscaledDeltaTime; } LocalPlayer.FpCharacter.LockView(); } else if (visible) { LocalPlayer.FpCharacter.UnLockView(); } visible = Opened; } catch (Exception ex) { Log.Write(ex.ToString()); } }
private void UpdateGame() { if (GamePad.GetState(PlayerIndex.One).Triggers.Left > .2f) { frameTime /= 20f; } int idx = 0; if (NetPlay.Joined) { idx = 1; } if (character[idx] != null) { Scroll += ((character[idx].Loc - new Vector2(400f, 400f)) - Scroll) * FrameTime * 20f; } Scroll += QuakeManager.Quake.Vector; bloomPulse[0] += FrameTime * .5f; bloomPulse[1] += FrameTime * .9f; for (int i = 0; i < bloomPulse.Length; i++) { if (bloomPulse[i] > 6.28f) { bloomPulse[i] -= 6.28f; } } float xLim = map.GetXLim(); float yLim = map.GetYLim(); waterDelta += FrameTime * 8f; waterTheta += FrameTime * 10f; if (waterDelta > 6.28f) { waterDelta -= 6.28f; } if (waterTheta > 6.28f) { waterTheta -= 6.28f; } if (Scroll.X < 0f) { scroll.X = 0f; } if (Scroll.X > xLim) { scroll.X = xLim; } if (Scroll.Y < 0f) { scroll.Y = 0f; } if (Scroll.Y > yLim) { scroll.Y = yLim; } if (map.transOutFrame <= 0f) { pManager.UpdateParticles(FrameTime, map, character); if (gameType == GameType.Solo) { if (character[0] != null) { character[0].DoInput(0); } } else if (gameType == GameType.Arena) { if (NetPlay.Hosting) { if (character[0] != null) { character[0].DoInput(0); } } if (NetPlay.Joined) { if (character[1] != null) { character[1].DoInput(0); } } } for (int i = 0; i < character.Length; i++) { if (character[i] != null) { character[i].Update(map, pManager, character); if (character[i].DyingFrame > 1f) { if (character[i].Team == Character.TEAM_GOOD_GUYS) { character[i].DyingFrame = 1f; } else { if (character[i].Name != "") { map.mapScript.Flags.SetFlag(character[i].Name); } character[i] = null; } } } } } if (GamePad.GetState(PlayerIndex.One).Triggers.Left < .2f) { map.Update(pManager, character); } hud.Update(); }
public void Update(GameTime gameTime) { if (isClear && mapIndex == StageDef.BigIndexMax * StageDef.SmallIndexMax - 1) { clearSelect.GetSelect = 0; isEnd = true; return; } StartTimer.Update(); if (StartTimer.IsTime()) { StartTimer.Stop(); } ClearShow(); //死んでいないと更新する if (!isClear && !isOver && !isPause) { //カメラ操作中、別の操作は不可 if (input.CheckDownKey(Parameter.CameraKey, Parameter.CameraButton)) { isView = true; player.IsView = isView; } else { isView = false; player.IsView = isView; } if (isView) { CameraControl(); } //Goal出現の時に、全画面の更新を一時停止、Goalの演出だけをする By 張ユービン if (goal.State == GoalState.APPEARING) { FuncSwitch.AllAnimetionPause = true; goal.Update(gameTime); camera.MoveAimPosition(goal.Position + new Vector2(goal.Width / 2, goal.Height / 2)); } else { FuncSwitch.AllAnimetionPause = false; playTime++; for (int i = 0; i < map.MapThings.Count; i++) { map.MapThings[i].Update(gameTime); } //プレイヤーの更新 player.Update(gameTime); //火の更新 for (int i = fires.Count - 1; i >= 0; i--) { fires[i].Update(gameTime); } //死んだ火を消す fires.RemoveAll(x => x.IsDead); // && x.IsOnGround //水の更新 foreach (var w in waterLines) { w.Update(gameTime); } waterLines.RemoveAll(x => x.IsDead); //マップの更新 map.Update(gameTime); //カメラの注視位置を更新 if (!isView) { camera.MoveAimPosition(player.Position + new Vector2(player.Width / 2, player.Height / 2)); } //Console.WriteLine(camera.OffSet); //マップ上にある炭の数を取得 nowCoals = map.MapThings.FindAll(x => x is Coal); ChangeGoalStage(gameTime); Goal(); //ゴール後処理 by柏 2016.12.22 //葉梨竜太 if (player.IsDead) { isOver = true; //isClear = true; //clearSelect.IsClear = true; } } } else { FuncSwitch.AllAnimetionPause = false; sound.StopBGM(); } // ClearWindow2が出るように変更(KeyもQに変更) By佐瀬拓海 if (!player.IsDead && !isClear) { if (gameDevice.GetInputState().CheckTriggerKey(Keys.Q, Parameter.MenuButton)) { if (isOver == false) { sound.PlaySE("pauseMenu"); //by柏 2016.12.14 SE実装 //全体Animationを一時停止 isPause = true; clearSelect.IsPause = isPause; clearSelect.GetSelect = 1; isOver = true; } else if (isOver == true) { sound.PlaySE("pauseMenu"); //by柏 2016.12.14 SE実装 //全体Animationを一時停止解除 isPause = false; clearSelect.IsPause = isPause; isOver = false; } } } clearSelect.Update(); isEnd = clearSelect.IsEnd; //clear窓口からend状態をとる if (isOver) //SceneのisOverで判断する { if (player.IsDead) { //player.Death(); } if (isPause) { clearSelect.IsClear = true; return; } else { if (clearSelect.IsClear) { return; } } if (clearSelect.IsClear) { return; } clearSelect.Initialize(); clearSelect.IsClear = true; } else if (!isOver && !isClear && !isPause) //isOver = falseでゲーム画面に戻れる By佐瀬拓海 { clearSelect.Initialize(); clearSelect.IsClear = false; sound.PlayBGM("forest1"); } }