Update() приватный Метод

private Update ( ) : void
Результат void
Пример #1
0
        public void Update(GraphicsDevice graphicsDevice, GameTime gameTime, KeyboardState keyboardState, MouseState mouseState)
        {
            Player.InFocus = GameInstance.IsActive;

            latestGameTime = gameTime;

            //Update network
            NetworkManager.Update(this);

            //Update map
            if (GameRunning && gameMap != null)
            {
                gameMap.Update(graphicsDevice, gameTime, keyboardState, mouseState);
            }

            //Update GUI
            graphicsUI.Update(gameTime);
            if (GameInstance.IsActive)
            {
                graphicsUI.Interact(new GameGUI.GUIInput(keyboardState, pastKeyboardState, mouseState, pastMouseState));
            }

            pastKeyboardState = keyboardState;
            pastMouseState    = mouseState;
        }
Пример #2
0
        public void Update(float delta)
        {
            unit.Update(delta, npcs.Cast <GameObject>().ToList(), gameMap);
            npcs.ForEach(n => ((NonPlayerCharacter)n).Update(delta, new List <GameObject>()
            {
                unit
            }, gameMap));
            var units = new List <GameObject>();

            units.AddRange(npcs);
            units.Add(unit);
            gameMap.Update(units);

            RemoveDeadGameObjects();
        }
Пример #3
0
        public Result Update(string id)
        {
            Result result = new Result
            {
                success = true
            };

            if (Players[0].Id.Equals(id))//First player is a minesetter
            {
                bool mineSweeper = Players[0].role.Equals(MoveSet.MineSweeper);
                result = GameMap.Update(mineSweeper);
                //Checks if it's players turn yet
                if (Players[0]?.TurnsLeft > 0)
                {
                    //players[0].TurnsLeft = TurnCount;
                    //result = GameMap.Update(false);
                    result.turn = true;
                    // SetMemento();
                }
            }
            else if (Players[1].Id.Equals(id)) //Second player is a minesweeper
            {
                bool mineSweeper = Players[1].role.Equals(MoveSet.MineSweeper);
                result = GameMap.Update(mineSweeper);//Checks if it's players turn yet
                if (Players[1]?.TurnsLeft > 0)
                {
                    //players[1].TurnsLeft = TurnCount;
                    result.turn = true;
                }
            }
            else
            {
                result.success = false;
            }

            return(result);
        }
Пример #4
0
    /// <summary>
    /// Entry point for bot execution in C#ß
    /// </summary>
    public static void Main(string[] args)
    {
        // Intialize the game with the name of your bot
        var hlt = Halite.Initialize(RandomBotName);
        // Create the Game Map
        var map = new GameMap(hlt.Item2);

        // Set up logging
        Log.Setup("RandomC#Bot" + hlt.Item1 + ".log", LogingLevel.User);
        // Intialize a command queue to store all the commands per turn
        var commands = new List <String> ();

        // Game loop
        while (true)
        {
            // Make sure commands are cleared prior to each turn
            commands.Clear();
            // Update your map
            map.Update();
            // Get your player info
            var myplayer = map.Players.FirstOrDefault(player => player.Id == hlt.Item1);
            // Now do the following for each ship that is owned by you
            foreach (var ship in myplayer.Ships)
            {
                // If the ship is already docked, skip the loop and start with the next ship
                if (ship.DockingStatus != DockingStatus.undocked)
                {
                    continue;
                }

                // Since the ship is not docked, lets checkout whast the planets are doing
                foreach (var planet in map.Planets)
                {
                    // If the planet is owned, lets not bother attacking it or going near it.
                    if (planet.isOwned())
                    {
                        continue;
                    }

                    // If you are close enough to the planet you can dock and produce more ships.
                    // lets try that out now
                    if (ship.CanDock(planet))
                    {
                        // Sweet, you can dock. Lets add the dock command to your queue
                        commands.Add(ship.Dock(planet));
                        break;
                    }
                    else
                    {
                        // Not close enough to dock.
                        // So lets find the closest point in the planet relative to the current ships location
                        var entityPoint = ship.GetClosestPointToEntity(planet);
                        // Since we have the point, lets try navigating to it.
                        // Our pathfinding algorthm takes care of going around obstsancles for you.
                        var navigatecommand = ship.Navigate(entityPoint, map, Constants.MaxSpeed / 2);
                        // Lets check If we were able to find a route to the point
                        if (!string.IsNullOrEmpty(navigatecommand))
                        {
                            // Looks like we found a way, let add this to our command queue
                            commands.Add(navigatecommand);
                        }

                        break;
                    }
                }
            }

            // You are now done with the commands to your ships Fleet Admiral,
            // lets get our battle computers to execute your commands
            Halite.SendCommandQueue(commands);
        }
    }