private void RpcSpawnCommand(float x, float z, Command.CommandType type, int uniqueId) { GameObject go = GameObject.Instantiate(CommandPrefab, new Vector3(x, 0.0f, z), Quaternion.identity); if (go == null) { Debug.LogError("failed to instantiate command"); return; } Command command = go.GetComponent <Command>(); if (command == null) { Debug.LogError("failed to instantiate command"); return; } for (int i = 0; i < GameData.CommandIconSpriteInfos.Length; i++) { if (GameData.CommandIconSpriteInfos[i].Type == type) { command.Setup(GameData.CommandIconSpriteInfos[i].BackgroundColor, GameData.CommandIconSpriteInfos[i].Icon, uniqueId, type); break; } } //if (isServer) //{ _spawnedCommands.Add(command); //} }
public void ExecuteCommand(Command.CommandType commandType) { _currentCommand = commandType; switch (commandType) { case Command.CommandType.DIR_UP: transform.rotation = Quaternion.identity; _stateMachine.ChangeState <MoveState>(); break; case Command.CommandType.DIR_DOWN: transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f); _stateMachine.ChangeState <MoveState>(); break; case Command.CommandType.DIR_LEFT: transform.rotation = Quaternion.Euler(0.0f, -90.0f, 0.0f); _stateMachine.ChangeState <MoveState>(); break; case Command.CommandType.DIR_RIGHT: transform.rotation = Quaternion.Euler(0.0f, 90.0f, 0.0f); _stateMachine.ChangeState <MoveState>(); break; } }
private void GameEvents_OnExecuteCommand(int mechIndex, Command.CommandType type, int id) { if (isServer) { RpcExecuteCommand(mechIndex, type); CommandSpawner.ServerRemoveCommand(id); } }
private void ServerSpawnCommand() { float x = Random.Range(SpawnMin.position.x, SpawnMax.position.x); float z = Random.Range(SpawnMin.position.z, SpawnMax.position.z); Command.CommandType type = ChooseCommandType(); RpcSpawnCommand(x, z, type, _nextUniqueId++); }
public void SetExecutingCommand(string dataRef, Command.CommandType type = Command.CommandType.Once) { if (string.IsNullOrWhiteSpace(dataRef)) { throw new ArgumentNullException("dataRef"); } Commands.Enqueue(new SetExecutingCommand(dataRef, type)); }
private static void ProcessPlayerInput(ActiveChar character, ref bool moveMade) { if (MenuManager.Menus.Count > 0) { MenuManager.ProcessMenus(CurrentInput, character, ref moveMade); return; } else if (replayInputs.Count > 0 && !isLogging) { ProcessDecision(replayInputs[0], character, ref moveMade); replayInputs.RemoveAt(0); return; } Command command = new Command(Command.CommandType.None); bool jump = false; bool spell = false; bool turn = false; bool diagonal = false; #if GAME_MODE //menu button presses if (CurrentInput[Input.InputType.Enter] && !PrevInput[Input.InputType.Enter]) { MenuManager.Menus.Insert(0, new MainMenu()); } else if (CurrentInput[Input.InputType.Q] && !PrevInput[Input.InputType.Q]) { MenuManager.Menus.Insert(0, new ItemMenu()); } else if (CurrentInput[Input.InputType.W] && !PrevInput[Input.InputType.W]) { MenuManager.Menus.Insert(0, new SpellMenu()); } else #endif //multi-button presses if (CurrentInput[Input.InputType.A]) { if (CurrentInput[Input.InputType.S] && !PrevInput[Input.InputType.S]) { command = new Command(Command.CommandType.Spell, 0); } else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D]) { command = new Command(Command.CommandType.Spell, 1); } else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { command = new Command(Command.CommandType.Spell, 2); } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { command = new Command(Command.CommandType.Spell, 3); } else { //keep move display spell = true; if (CurrentInput.Direction != Direction8.None) { command = new Command(Command.CommandType.Dir); command.AddArg((int)CurrentInput.Direction); } } } else { if (CurrentInput[Input.InputType.Z]) { jump = true; } if (CurrentInput[Input.InputType.S]) { turn = true; } if (CurrentInput[Input.InputType.D]) { diagonal = true; } //single button presses if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) { if (jump) { command = new Command(Command.CommandType.AltAttack); command.AddArg((int)character.CharDir); command.AddArg(1); } else { command = new Command(Command.CommandType.Attack); } jump = false; turn = false; diagonal = false; } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) { if (jump) { command = new Command(Command.CommandType.Wait); } else { command = new Command(Command.CommandType.Pickup); } jump = false; turn = false; diagonal = false; }//directions else if (CurrentInput.Direction != Direction8.None) { if (Display.Screen.DebugSpeed != Display.Screen.GameSpeed.Instant || PrevInput.Direction == Direction8.None) { Command.CommandType cmdType = Command.CommandType.None; if (Operations.IsDiagonal(CurrentInput.Direction)) { cmdType = Command.CommandType.Dir; } else if (InputTime > RenderTime.FromMillisecs(20) || PrevInput.Direction == Direction8.None) { cmdType = Command.CommandType.Dir; } if (InputTime > RenderTime.FromMillisecs(60) || Display.Screen.DebugSpeed == Display.Screen.GameSpeed.Instant) { cmdType = Command.CommandType.Move; } if (jump) { cmdType = Command.CommandType.AltAttack; } if (turn) { cmdType = Command.CommandType.Dir; } if (!diagonal || Operations.IsDiagonal(CurrentInput.Direction)) { command = new Command(cmdType); command.AddArg((int)CurrentInput.Direction); } if (!turn) { jump = false; diagonal = false; } } } } #if GAME_MODE Display.Screen.Jump = jump; Display.Screen.Spell = spell; Display.Screen.Turn = turn; Display.Screen.Diagonal = diagonal; #endif ProcessDecision(command, character, ref moveMade); }
private void RpcExecuteCommand(int mechIndex, Command.CommandType type) { _mechs[mechIndex].ExecuteCommand(type); }
public static void TriggerExecuteCommand(int mechIndex, Command.CommandType type, int id) { OnExecuteCommand?.Invoke(mechIndex, type, id); }