/// <summary> /// this method creates a new player "PlayerController" Pawn is optional /// </summary> /// <param name="spawnPawn">optional parameter should pawn be instantiated?</param> public new void CreatePlayer(bool spawnPawn = false) { // check if there are still playersslots left for the currentGameMode if (GameState.Players.Count < currentGameMode.GetComponent <AGameMode>().MaxPlayers) { // playerController is always created, Pawn is optional AGameMode gm = currentGameMode.GetComponent <AGameMode>(); GameObject pawn = null; if (spawnPawn == true) { pawn = GameObject.Instantiate(gm.DefaultPawn); } GameObject pc = GameObject.Instantiate(gm.DefaultPlayerController); // bug pawn is not set -> can't get component of null object Player newPlayer = new Player(GameState.Players.Count, pawn != null ? pawn.gameObject.GetComponent <APawn>() : null, pc.GetComponent <APlayerController>()); //Player newPlayer = new Player(Players.Count, pawn.gameObject.GetComponent<APawn>(), pc.GetComponent<APlayerController>()); // add to players array GameState.Players.Add(newPlayer); } else { Debug.LogWarning("Can't create player because there are no empty player slots for the current GameMode."); } }
internal void ReleaseGameMode() { if (_currentGameMode == null) { Debug.LogError("No Game Mode to release."); } _currentGameMode = null; }
internal void RegisterGameMode(AGameMode a_gameMode) { if (_currentGameMode != null) { Debug.LogError("Two game modes are registered at the same time."); } _currentGameMode = a_gameMode; }
public void StartGame(Type mode, string description) { if (action == MenuAction.Loading) { return; } action = MenuAction.Loading; AGameMode gamemode = (AGameMode)Activator.CreateInstance(mode, this, map); gamemode.description = description; gamemode.StartMap(); SwitchTab(null); SetStartButton(false); }
public void StartGameMode(int index) { if (index >= _gameModes.Count) { throw new UnityException("Game Mode index out of range."); } if (_gameMode != null) { _gameMode.CleanUpGame(); } _gameMode = _gameModes[index]; _gameMode.StartGame(); _gameMenu.gameObject.SetActive(false); }
private void startGameArithmetic(AGameMode mode) { Font fnt = new System.Drawing.Font(lblThink.Font.FontFamily, 48, FontStyle.Bold); lblThink.Font = fnt; lblThink.TextAlign = ContentAlignment.MiddleRight; currentAMode = mode; btnPlus.Visible = false; btnMinus.Visible = false; btnMult.Visible = false; btnDivs.Visible = false; prbProgress.Visible = true; btnArithAnswer.Enabled = true; lblThink.Enabled = true; txbArithAnswer.Enabled = true; txbMax.Enabled = false; mnsMain.Enabled = false; txbArithAnswer.Text = ""; prbProgress.Minimum = 0; prbProgress.Maximum = countQuestionMax; prbProgress.Value = 0; countQuestion = 0; txbArithAnswer.Focus(); prbAnswerTime.Visible = true; prbAnswerTime.Maximum = timePerQuestArithmetic; try { maxValue = Convert.ToInt16(txbMax.Text); } catch { maxValue = 10; txbMax.Text = "10"; } nextThinkArith(); }
internal void SetGameMode(AGameMode a_gameMode) { _gameMode = a_gameMode; }