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

private Update ( ) : void
Результат void
Пример #1
0
        public override void Update(GameTime gameTime)
        {
            switch (State)
            {
            case States.Outside:

                _playerOutside.Update(gameTime);
                _mapManagerOutside.Update(gameTime);

                if (_house.EntranceRectangle.Intersects(_playerOutside.NextRectangleTile))
                {
                    State = States.EnteringBuilding;
                    _insideFog.Opacity = 0.0f;
                }

                break;

            case States.EnteringBuilding:

                _playerOutside.Update(gameTime);
                _mapManagerOutside.Update(gameTime);

                var diff = Map.TileHeight / _playerOutside.Speed;
                _insideFog.Opacity += 0.8f / diff;

                if (_playerOutside.TileRectangle == _house.EntranceRectangle)
                {
                    _insideFog.Opacity = 0.8f;
                    State = States.Inside;

                    _mapManagerInside.Refresh();

                    _playerInside.TilePosition = new Vector2(_house.ExitRectangle.X, _house.ExitRectangle.Y);
                    _playerInside.Move(Directions.Up);
                }

                break;

            case States.Inside:

                _playerInside.Update(gameTime);

                if (BaseGame.GameKeyboard.IsKeyPressed(Microsoft.Xna.Framework.Input.Keys.Escape) || _house.ExitRectangle.Intersects(_playerInside.NextRectangleTile))
                {
                    _playerInside.NextRectangleTile = Rectangle.Empty;
                    State = States.Outside;
                    _mapManagerOutside.Map.RemoveItem(_playerOutside.TileRectangle);
                    _playerOutside.Move(Directions.Down);
                }

                break;

            default:
                break;
            }
        }
Пример #2
0
 private void OnUpdate(object sender, EventArgs e)
 {
     Invoke(new Action(() =>
     {
         _objectSlotManager.Update();
         _objectManager.Update(tabControlMain.SelectedTab == tabPageObjects);
         _marioManager.Update(tabControlMain.SelectedTab == tabPageMario);
         _cameraManager.Update(tabControlMain.SelectedTab == tabPageCamera);
         _hudManager.Update(tabControlMain.SelectedTab == tabPageHud);
         _actionsManager.Update(tabControlMain.SelectedTab == tabPageActions);
         _waterManager.Update(tabControlMain.SelectedTab == tabPageWater);
         _inputManager.Update(tabControlMain.SelectedTab == tabPageInput);
         _fileManager.Update(tabControlMain.SelectedTab == tabPageFile);
         _quarterFrameManager.Update(tabControlMain.SelectedTab == tabPageQuarterFrame);
         _cameraHackManager.Update(tabControlMain.SelectedTab == tabPageCamHack);
         _miscManager.Update(tabControlMain.SelectedTab == tabPageMisc);
         _triangleManager.Update(tabControlMain.SelectedTab == tabPageTriangles);
         _debugManager.Update(tabControlMain.SelectedTab == tabPageDebug);
         _puManager.Update(tabControlMain.SelectedTab == tabPagePu);
         _testingManager.Update(tabControlMain.SelectedTab == tabPageTesting);
         _mapManager?.Update();
         _modelManager?.Update();
         _scriptManager.Update();
         _hackManager.Update();
     }));
 }
Пример #3
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardInput.UpdateStart();

            Camera.Update(gameTime);
            MapManager.Update(gameTime);

            WaypointRecorder.Update();


            if (KeyboardInput.isKeyPressed(Keys.F1))
            {
                WaypointRecorder.Recording = !WaypointRecorder.Recording;
            }

            if (KeyboardInput.isKeyPressed(Keys.F2))
            {
                List <Waypoint> sortWaypoints = WaypointManager.waypoints.OrderBy(wp => Vector2.Distance(wp.Position, new Vector2(ObjectManager.Me.X, ObjectManager.Me.Y))).ToList();

                WaypointRecorder.lastWaypoint = sortWaypoints[0];
            }

            if (KeyboardInput.isKeyPressed(Keys.F3))
            {
                List <Waypoint> sortWaypoints = WaypointManager.waypoints.OrderBy(wp => Vector2.Distance(wp.Position, new Vector2(ObjectManager.Me.X, ObjectManager.Me.Y))).ToList();
                //PathFinder.findPath(
                List <PathNode> list = PathFinder.findPath(sortWaypoints[sortWaypoints.Count - 1], sortWaypoints[0]);
                Console.WriteLine(list);
            }

            UpdateEntities(gameTime);

            KeyboardInput.UpdateEnd();
        }
Пример #4
0
        public static void Initialise()
        {
            new Thread(() =>
            {
                var sw          = new Stopwatch();
                double lastTick = 0d;

                while (true)
                {
                    sw.Restart();

                    NetworkManager.Update(lastTick);
                    SocialManager.Update(lastTick);
                    MapManager.Update();

                    Thread.Sleep(1);
                    lastTick = (double)sw.ElapsedTicks / Stopwatch.Frequency;

                    #if DEBUG
                    Console.Title = $"{WorldServer.Title} (Update Time: {lastTick})";
                    #endif
                }
            })
            {
                IsBackground = true
            }.Start();
        }
Пример #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //myPlayer.Update(gameTime);
            switch (myState)
            {
            case State.LOAD:
                myLoad.Update(gameTime);
                break;

            case State.MENU:
                myMenu.Update(gameTime);
                break;

            case State.PREPARE:
                myPrepare.Update(gameTime);
                break;

            case State.PLAY:
                myMapManager.Update(gameTime);
                break;

            case State.RESET:
                myReset = new Reset();
                break;

            case State.UPGRADE:
                myUpgrade.Update(gameTime);
                break;
            }
            base.Update(gameTime);
        }
Пример #6
0
        private static void Main()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            Console.Title = Title;
            log.Info("Initialising...");

            ConfigurationManager <WorldServerConfiguration> .Initialise("WorldServer.json");

            DatabaseManager.Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Database);

            GameTableManager.Initialise();
            MapManager.Initialise();
            SearchManager.Initialise();
            EntityManager.Initialise();
            EntityCommandManager.Initialise();
            GlobalMovementManager.Initialise();

            AssetManager.Initialise();
            GlobalSpellManager.Initialise();
            ServerManager.Initialise();

            ResidenceManager.Initialise();

            // make sure the assigned realm id in the configuration file exists in the database
            RealmId = ConfigurationManager <WorldServerConfiguration> .Config.RealmId;
            if (ServerManager.Servers.All(s => s.Model.Id != RealmId))
            {
                throw new ConfigurationException($"Realm id {RealmId} in configuration file doesn't exist in the database!");
            }

            MessageManager.Initialise();
            SocialManager.Initialise();
            CommandManager.Initialise();
            NetworkManager <WorldSession> .Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Network);

            WorldManager.Initialise(lastTick =>
            {
                NetworkManager <WorldSession> .Update(lastTick);
                MapManager.Update(lastTick);
                ResidenceManager.Update(lastTick);
                BuybackManager.Update(lastTick);
            });

            using (WorldServerEmbeddedWebServer.Initialise())
            {
                log.Info("Ready!");

                while (true)
                {
                    Console.Write(">> ");
                    string line = Console.ReadLine();
                    if (!CommandManager.HandleCommand(new ConsoleCommandContext(), line, false))
                    {
                        Console.WriteLine("Invalid command");
                    }
                }
            }
        }
Пример #7
0
 private void UpdateManagers()
 {
     MapManager.Update();
     StrategyManager.Update();
     EconomyManager.Update();
     ProductionManager.Update();
     OperationsManager.Update();
 }
Пример #8
0
 void Update()
 {
     /*
      * check gameover;
      * wait for player's input;
      * if there were players input, players act and characters act after that;
      */
     mapManager.Update();
     charactersManager.Update();
 }
Пример #9
0
        private static void Main()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            Console.Title = Title;
            log.Info("Initialising...");

            ConfigurationManager <WorldServerConfiguration> .Initialise("WorldServer.json");

            DatabaseManager.Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Database);

            GameTableManager.Initialise();

            EntityManager.Initialise();
            EntityCommandManager.Initialise();

            AssetManager.Initialise();
            ServerManager.Initialise();

            MessageManager.Initialise();
            CommandManager.Initialise();
            NetworkManager <WorldSession> .Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Network);

            WorldManager.Initialise(lastTick =>
            {
                NetworkManager <WorldSession> .Update(lastTick);
                MapManager.Update(lastTick);
            });

            log.Info("Ready!");

            while (true)
            {
                Console.Write(">> ");
                string line = Console.ReadLine();
                CommandManager.ParseCommand(line, out string command, out string[] parameters);

                CommandHandlerDelegate handler = CommandManager.GetCommandHandler(command);
                if (handler != null)
                {
                    try
                    {
                        handler.Invoke(null, parameters);
                    }
                    catch (Exception exception)
                    {
                        log.Error(exception);
                    }
                }
                else
                {
                    Console.WriteLine("Invalid command!");
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            MapManager.Update(gameTime);

            base.Update(gameTime);
        }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        // Draw map and marker
        mapManager.Update();

        // Debug
        if (Input.GetMouseButtonDown(1))
        {
            Vector2 gPosMarker = MapManager.Utility.GetAbsGamePosByRelGamePos(MapManager.Utility.GetMarkerGamePosition(), mapManager);
            Debug.Log(mapManager.HitFlags[(int)gPosMarker.x, (int)gPosMarker.y]);
        }
    }
Пример #12
0
 private void OnUpdate(object sender, EventArgs e)
 {
     _objectSlotManager.Update();
     _objectManager.Update(tabControlMain.SelectedTab == tabPageObjects);
     _marioManager.Update(tabControlMain.SelectedTab == tabPageMario);
     _cameraManager.Update(tabControlMain.SelectedTab == tabPageCamera);
     _hudManager.Update(tabControlMain.SelectedTab == tabPageHud);
     _miscManager.Update(tabControlMain.SelectedTab == tabPageMisc);
     _triangleManager.Update(tabControlMain.SelectedTab == tabPageTriangles);
     _mapManager?.Update();
     _scriptManager.Update();
     _hackManager.Update();
 }
Пример #13
0
    private static void InitializeMapThread()
    {
        if (Config.Type != ServerTypes.Game)
        {
            return;
        }

        MapManager.AddConfigMapsToMapManager();
        map_thread_manager = new TheadHelper(new List <Action>()
        {
            () => MapManager.Update()
        });
        map_thread_manager.the_thread.Start();
    }
Пример #14
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _inputManager.Update(gameTime);
            _player.Update(gameTime);
            _mapManager.Update(gameTime);
            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Пример #15
0
 private void Update(float deltaTime)
 {
     if (mapManager != null && offsetTime <= 0)
     {
         mapManager.Update();
     }
     if (playerCtrl != null)
     {
         playTime   += deltaTime;
         offsetTime -= deltaTime;
         if (offsetTime <= 0)
         {
             playerCtrl.Update();
         }
     }
 }
Пример #16
0
        private static void Main()
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

            Console.Title = Title;
            log.Info("Initialising...");

            ConfigurationManager <WorldServerConfiguration> .Initialise("WorldServer.json");

            DatabaseManager.Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Database);

            GameTableManager.Initialise();

            EntityManager.Initialise();
            EntityCommandManager.Initialise();

            AssetManager.Initialise();
            ServerManager.Initialise();

            MessageManager.Initialise();
            SocialManager.Initialise();
            CommandManager.Initialise();
            NetworkManager <WorldSession> .Initialise(ConfigurationManager <WorldServerConfiguration> .Config.Network);

            WorldManager.Initialise(lastTick =>
            {
                NetworkManager <WorldSession> .Update(lastTick);
                MapManager.Update(lastTick);
            });

            using (WorldServerEmbeddedWebServer.Initialise())
            {
                log.Info("Ready!");

                while (true)
                {
                    Console.Write(">> ");
                    string line = Console.ReadLine();
                    if (!CommandManager.HandleCommand(new ConsoleCommandContext(), line, false))
                    {
                        Console.WriteLine("Invalid command");
                    }
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        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
            _mapManager.Update(gameTime);

            foreach (Entity entity in _factory.EntityRegistry)
            {
                entity.Update(gameTime);
            }
            _camera.Update(_factory.PlayerEntity, _mapManager.CurrentMap);
            _dialogueManager.Update(gameTime);


            base.Update(gameTime);
        }
Пример #18
0
        public override void Update(GameTime gameTime)
        {
            mapManager.Update(gameTime);
            windowManager.Update(gameTime);

            if (mapManager.enterDoor)
            {
                Global.canMove       = false;
                doorTimer            = 30;
                mapManager.enterDoor = false;
                ScreenManager.LoadScreen(new MainGameScreen(Game), new FadeTransition(GraphicsDevice, Color.Black, 1.0f));
            }

            if (doorTimer > 0)
            {
                doorTimer--;
            }
            else
            {
                Global.canMove = true;
            }
        }
Пример #19
0
        public override void Update(GameTime gameTime)
        {
            if (State != NextState)
            {
                if (NextState == BattleStates.PlayerTurn)
                {
                    _units.ForEach(c =>
                    {
                        c.UnitModel.Stamina = 2;
                        c.TilesMoved        = 0;
                    });

                    _gui.UnitsGroup.CurrentIndex = 0;
                    OnUnitSelect();
                }

                State = NextState;
            }

            BaseGame.GameMouse.AddCamera(_camera.Transform);

            switch (State)
            {
            case BattleStates.PlayerTurn:

                CheckInput();

                _gui.Update(gameTime, _targets.Select(c => c.UnitModel).ToList());

                if (_unitManager.State == UnitManager.States.Moving)
                {
                    _camera.GoTo(_units[_gui.SelectedUnitIndex].TileRectangle);
                }

                var selectedTargetIndex = _gui.TargetsGroup.CurrentIndex;

                _camera.Update(gameTime);
                _unitManager.Update(gameTime, _gui, (selectedTargetIndex > -1 && selectedTargetIndex < _targets.Count) ? _targets[selectedTargetIndex] : null);

                if (_unitManager.FinisedMoving)
                {
                    OnUnitSelect();
                }

                foreach (var unit in _units)
                {
                    unit.Update(gameTime);
                }

                foreach (var unit in _enemies)
                {
                    unit.Update(gameTime);
                }

                if (_gui.HoveringTargetIndex > -1)
                {
                    var target = _targets[_gui.HoveringTargetIndex];

                    switch (target.UnitModel.UnitType)
                    {
                    case Lib.Models.UnitModel.UnitTypes.Friendly:
                        target.Colour = Color.Blue;
                        break;

                    case Lib.Models.UnitModel.UnitTypes.Enemy:
                        target.Colour = Color.Red;
                        break;

                    default:
                        break;
                    }
                }

                if (_unitManager.UpdateUnitIndex)
                {
                    _unitManager.UpdateUnitIndex = false;

                    _gui.UnitsGroup.Increment();

                    _camera.GoTo(_units[_gui.SelectedUnitIndex].TileRectangle);
                }

                _mapManager.Update(gameTime);

                if (_units.All(c => c.UnitModel.Stamina <= 0) && _unitManager.State == UnitManager.States.Selected)
                {
                    NextState = BattleStates.EnemyTurn;
                }

                break;

            case BattleStates.EnemyTurn:

                _enemyTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (_enemyTimer <= 0)
                {
                    _enemyTimer = 5f;
                    NextState   = BattleStates.PlayerTurn;
                }

                break;

            default:
                break;
            }
        }
Пример #20
0
        public void Update(GameTime gameTime)
        {
            var time = gameTime.ElapsedGameTime.TotalSeconds;

            _timeCurrent      += time;
            _lastComputeScore += time;

            if (_timeCurrent >= _timeGame)
            {
                StateManager.Instance.SetGameState(Enums.EnumGameState.Score, _lastScore);
            }

            _lastBallRed    += time;
            _lastBallBlue   += time;
            _lastBallGreen  += time;
            _lastBallYellow += time;

            var touches = TouchPanel.GetState().ToList();

            //touches.RemoveAll(x => x.Pressure == 0);
            foreach (var touch in touches)
            {
                //Move
                var team = GetTeam(touch.Position);

                if (team != EnumTeam.NONE)
                {
                    Color   color          = Color.Red;
                    Vector2 positionBall   = touch.Position;
                    Vector2 positionCenter = _positionRed;
                    double  lastBall       = _lastBallRed;

                    switch (team)
                    {
                    case EnumTeam.BLUE:
                        color          = Color.Blue;
                        positionCenter = _positionBlue;
                        lastBall       = _lastBallBlue;
                        break;

                    case EnumTeam.GREEN:
                        color          = Color.Green;
                        positionCenter = _positionGreen;
                        lastBall       = _lastBallGreen;
                        break;

                    case EnumTeam.YELLOW:
                        color          = Color.Yellow;
                        positionCenter = _positionYellow;
                        lastBall       = _lastBallYellow;
                        break;
                    }

                    if (lastBall > 0.1)
                    {
                        Vector2 direction = positionBall - positionCenter;
                        direction.Normalize();
                        float distanceThrow = Vector2.DistanceSquared(positionBall, positionCenter);

                        switch (team)
                        {
                        case EnumTeam.RED:
                            _lastBallRed   = 0;
                            distanceThrow /= 55;
                            break;

                        case EnumTeam.BLUE:
                            _lastBallBlue  = 0;
                            distanceThrow /= 30f;
                            break;

                        case EnumTeam.GREEN:
                            _lastBallGreen = 0;
                            distanceThrow /= 55;
                            break;

                        case EnumTeam.YELLOW:
                            _lastBallYellow = 0;
                            distanceThrow  /= 30f;
                            break;
                        }

                        _paintBalls.Add(new PaintBall()
                        {
                            Position = positionCenter,
                            Color    = color,
                            IsDrawed = false,
                            Height   = 32,
                            Width    = 32,
                            Time     = 1,
                            Velocity = direction * distanceThrow
                        });
                    }
                }
            }
            _touches = touches;

            //Update balls
            foreach (var ball in _paintBalls)
            {
                if (!ball.IsDrawed)
                {
                    ball.Time -= time;

                    if (ball.Time <= 0)
                    {
                        var textureSplashs = TextureManager.Instance.GetTexture("Textures/Splashs");

                        var rand = _random.Next(0, 10);

                        _mapManager.AddColor(
                            textureSplashs,
                            new Rectangle(rand * 64, 0, 64, 64),
                            new Rectangle((int)(ball.Position.X - 32), (int)(ball.Position.Y - 32), 64, 64),
                            ball.Color
                            );

                        ball.IsDrawed = true;
                    }

                    ball.Position += ball.Velocity * (float)time;
                }
            }

            _paintBalls.RemoveAll(x => x.IsDrawed);

            _mapManager.Update(time);

            if (_lastComputeScore > 0.2)
            {
                _lastScore        = _mapManager.ComputeScore(Color.Red, Color.Blue, Color.Green, Color.Yellow);
                _lastComputeScore = 0;
            }
        }
Пример #21
0
 void Update()
 {
     playerController.Update();
     mapManager.Update();
 }
Пример #22
0
        public void Update(double time)
        {
            _mapManager.Update(time);
            _mapView.Update(time);

            MouseState mouse   = Mouse.GetState();
            var        oldZoom = Settings.Zoom;

            Settings.Zoom = 1f + (Settings.Zoom * mouse.ScrollWheelValue / 1000); //(mouse.ScrollWheelValue != 0 ? mouse.ScrollWheelValue / 1200f : 0);


            var touches = TouchPanel.GetState().ToList();

            //touches.RemoveAll(x => x.Pressure == 0);
            if (touches.Any() && _touches.Any())
            {
                if (touches.Count > 1 && _touches.Count > 1)
                {
                    var touch1 = touches.First();
                    var touch2 = touches[1];

                    var oldTouch1 = _touches.First();
                    var oldTouch2 = _touches[1];

                    Vector2 a    = touch1.Position;
                    Vector2 b    = touch2.Position;
                    float   dist = Vector2.Distance(a, b);

                    // prior positions
                    Vector2 aOld    = oldTouch1.Position;
                    Vector2 bOld    = oldTouch2.Position;
                    float   distOld = Vector2.Distance(aOld, bOld);

                    _pinchDistance = 0;
                    if (dist != distOld && Math.Abs(distOld - dist) > 1)
                    {
                        _pinchDistance = distOld - dist;
                        float scale = -(distOld - dist) * 0.1f;
                        Settings.Zoom += scale;

                        _mapView.Resize();
                    }

                    //var center = (touch1.Position - touch2.Position) / 2;
                    //_mapView.SetOffset((int)center.X, (int)center.Y);
                }
                else
                {
                    //Move
                    var touch    = touches.First();
                    var oldTouch = _touches.First();
                    var position = oldTouch.Position - touch.Position;
                    _mapView.SetOffset(-(int)position.X, -(int)position.Y);

                    _mapView.Move();
                }
            }
            _touches = touches;

            if (Settings.Zoom > 4)
            {
                Settings.Zoom = 4;
            }
            else if (Settings.Zoom < 0.5f)
            {
                Settings.Zoom = 0.5f;
            }

            if (oldZoom != Settings.Zoom)
            {
                _mapView.Resize();
            }
        }