private void GetPlayerCommandsInput() { if (GamepadInput.GamePad.GetButton(GamepadInput.GamePad.Button.Start, GamepadInput.GamePad.Index.Any) || Input.GetKeyDown(KeyCode.Backspace)) { Reset(); } if (GamepadInput.GamePad.GetButton(GamepadInput.GamePad.Button.Back, GamepadInput.GamePad.Index.Any) || Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #endif } if (Time.timeScale == 0) { return; } // For each player, get command input, if any, and put it into the command queue. for (int playerIndex = 0; playerIndex < players.Count; playerIndex++) { PlayerCommand command = players[playerIndex].GetNextCommand(); if (command != null) { // Set sent time, and put the command in the queue. LinkedList <PlayerCommand> queue = playerCommandQueues[playerIndex]; Assert.IsNotNull(queue); float sentTime = Mathf.Ceil(Time.time); if (queue.Count > 0) { // Make sure we have an interval between commands. PlayerCommand prevCommand = queue.Last.Value; sentTime = Mathf.Max(sentTime, prevCommand.SentTime + CommandInterval); } command.SentTime = sentTime; command.Delay = CommandDelay; queue.AddLast(command); UICommandQueue uiQueue = playerCommandQueueUI[playerIndex]; Assert.IsNotNull(uiQueue); uiQueue.Add(command); AudioManager.PlayAtIndex(audioEventSendCommand, (int)command.Action); } } }
public static PluginsLoader GetInstance() { Config.GetInstance(); DrawGrid.GetInstance(); UICommandQueue.GetInstance().InitFromGlThread(); HeightMapPersistence.GetInstance(); SlopeMapPersistence.GetInstance(); MouseFilterSdlMouseCache.GetInstance(); KeyFilterSdlKeyCache.GetInstance(); KeyFilterConfigMappingsFactory.GetInstance(); MainUI.GetInstance(); HeightEditor.GetInstance(); Camera.GetInstance(); Framerate.GetInstance(); FrustrumCulling.GetInstance(); return(instance); }
private void ProcessCommandQueue(LinkedList <PlayerCommand> queue) { Assert.IsNotNull(queue); if (queue.Count > 0) { PlayerCommand command = queue.First.Value; // if the command can be received now, and we are not already executing a command if (command != null && Time.time > command.SentTime + CommandDelay) { // dequeue and execute the commmand queue.RemoveFirst(); Assert.IsNotNull(rovers[command.RoverId]); rovers[command.RoverId].EnqueueCommand(command, CommandDuration); UICommandQueue uiQueue = playerCommandQueueUI[command.PlayerId]; Assert.IsNotNull(uiQueue); uiQueue.Remove(command); } } }