Ejemplo n.º 1
0
        //======================
        public dwWorld2D()
        {
            unindexedPlayers = new HashSet<PlayerData>();
            playerList = new PlayerData[dwWorldConstants.GAME_MAX_PLAYERS];

            playerCountCached = 0;
            playerCountDirty = false;

            objects = new List<dwObject2D>();

            currentFrameInput = new FrameInput();
            currentFrame = 0;
            running = false;
            paused = false;

            inputData = new Dictionary<uint, FrameInput>();
        }
Ejemplo n.º 2
0
 public void mergeFrom(FrameInput other)
 {
     orderList.AddRange(other.orderList);
 }
Ejemplo n.º 3
0
        private void update()
        {
            //Issue all of the scheduled orders
            if (inputData.ContainsKey(currentFrame))
            {
                foreach (Order o in inputData[currentFrame].orderList)
                {
                    sendOrderToObject(o.owner, o);
                }

                //Clear the data from the input table
                inputData.Remove(currentFrame);
            }

            //Call an update on all of the world's objects
            for (int i = 0; i < objects.Count; i++)
            {
                dwObject2D currentObject = objects[i];

                currentObject.update_internal();
            }

            worldUpdate();

            //Call any specified external update functions
            if (onWorldUpdate != null)
                onWorldUpdate();

            //Increment time
            currentFrame++;

            //Set up data for the next frame (thereby allowing user interaction to occur independant of game ticks,
            // because there is always something to notify of user input/actions
            currentFrameInput = new FrameInput(currentFrame + dwWorldConstants.ORDER_DELAY_TICKS);
        }
Ejemplo n.º 4
0
 internal void addFrameInputData(FrameInput frameInput)
 {
     if(inputData.ContainsKey(frameInput.targetFrame))
     {
         inputData[frameInput.targetFrame].mergeFrom(frameInput);
     }
     else
         inputData[frameInput.targetFrame] = frameInput;
 }