コード例 #1
0
        public void ChangePlayerAndReplaceBots(UpdatableObjects updatableObjects)
        {
            Player player        = null;
            Player currentPlayer = updatableObjects.GetPlayer();
            Random rand          = new Random();
            int    r             = rand.Next(0, updatableObjects.GetBots().Count);
            int    i             = 0;

            foreach (Player bot in updatableObjects.GetBots())
            {
                if (i == r)
                {
                    player = bot;
                }
                i++;
            }
            ReplaceBotAndChangeStatus(currentPlayer, player);
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: lk14kirill/Agario
        private void DoCycleStep()
        {
            totalTimeElapsed    = clock.ElapsedTime.AsSeconds();
            deltaTime           = totalTimeElapsed - previousTimeElapsed;
            previousTimeElapsed = totalTimeElapsed;

            totalTimeBeforeUpdate += deltaTime;
            if (totalTimeBeforeUpdate >= Constants.TIME_UNTIL_UPDATE)
            {
                time = clock.ElapsedTime.AsMicroseconds();
                clock.Restart();
                time /= 800;

                window.Clear(Color.White);
                window.DispatchEvents();

                updatableObjects.Update(direction, updatableObjects.GetFood(), updatableObjects.GetBots(), (float)time, updatableObjects.GetPlayer());

                Fabric.Instance.RemoveCachedObjectsAndCreateNew(updatableObjects, drawableObjects);

                drawableObjects.Draw(window);
                window.Display();
            }
        }