Пример #1
0
        /// <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);
        }
Пример #2
0
    private void spawnPlayer()
    {
        Vector2 spawnLocation = new Vector2(0, 0);

        player             = Instantiate(playerPrefab, spawnLocation, Quaternion.identity).GetComponent <Player>();
        player.gameManager = this;
        OnNewPlayer?.Invoke(player);
    }
Пример #3
0
    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;
        }
    }
Пример #4
0
 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)));
     }
 }
Пример #5
0
 protected virtual void NewPlayerAlert()
 {
     OnNewPlayer?.Invoke(this, EventArgs.Empty);
 }