/// <summary> /// Creates or gets a player. /// </summary> /// <param name="id">Player id</param> /// <param name="name">Player name.</param> /// <returns></returns> public Player CreatePlayer(int id, string name) { if (Players.ContainsKey(id)) { return(Players[id]); } Player p; Account a = Server.AccountManager.GetAccount(name); if (a == null) { p = new Player(id); } else { p = new MyPlayer(id); a.SetPlayer(p as MyPlayer); } p.Name = name; Players.Add(id, p); if (OnNewPlayer != null) { OnNewPlayer.Invoke(p); } return(p); }
private void spawnPlayer() { Vector2 spawnLocation = new Vector2(0, 0); player = Instantiate(playerPrefab, spawnLocation, Quaternion.identity).GetComponent <Player>(); player.gameManager = this; OnNewPlayer?.Invoke(player); }
private void CreatePlayer(int padIndex, PadUsedType type) { _activeIndex.Add(padIndex); var playerInput = new PlayerInput(padIndex, type); _playersByPadIndex.Add(PlayerInputUtils.NameByIndexAndPadUsedType(padIndex, type), playerInput); OnNewPlayer.SafeInvoke(playerInput); if (_mainPlayerInput == null) { _mainPlayerInput = playerInput; } }
private void OnGamePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(CurrentPlayer)) { OnNewPlayer?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentPlayer))); } else if (e.PropertyName == nameof(CurrentLocation)) { OnNewLocation?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentLocation))); } else if (e.PropertyName == nameof(CurrentMonster)) { OnNewMonster?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentMonster))); } }
protected virtual void NewPlayerAlert() { OnNewPlayer?.Invoke(this, EventArgs.Empty); }