Exemplo n.º 1
0
    /// <summary>
    /// This init is called only for local player
    /// </summary>
    private void Init()
    {
        //Debug.Log($"{this} Init {IsItMe}");
        if (!IsItMe)        //player image controllers dont need initializing
        {
            return;
        }

        if (IsInited)
        {
            return;
        }

        Stats.Init();
        input.Init(InitInfo);

        ItemController.Init(InitInfo.Hero);

        if (InitInfo.PlayerType == EPlayerType.AI)
        {
            ai.Init();
        }

        IsInited = true;
        //Debug.Log("X_Inited_Init");

        game.PlayerManager.OnAllPlayersAdded.AddAction(OnAllPlayersAdded);
        OnPlayerInited.Invoke();
    }
Exemplo n.º 2
0
    /// <summary>
    /// Use this instead of: Players.Add()
    /// </summary>
    public void AddPlayer(Player pPlayer)
    {
        if (pPlayer.ai.IsTmp)
        {
            //Debug.Log("Skip tmp ai");
            //tmp AIs (Tesla clone) are not registered as active players
            return;
        }

        Players.Add(pPlayer);
        //Debug.Log("Add player " + pPlayer);
        int playersCount = Players.FindAll(a => !a.IsLocalImage).Count;

        if (playersCount == brainiacs.GameInitInfo.Players.Count)
        {
            if (pPlayer.IsLocalImage)
            {
                return;
            }

            if (AreAllPlayersAdded)
            {
                Debug.LogError("OnAllPlayersAdded already called");
                return;
            }

            //foreach(var player in Players)
            //{
            //	player.Init();
            //}
            //Debug.Log("All players added");
            OnAllPlayersAdded.Invoke();
            //OnAllPlayersAdded = null;
            AreAllPlayersAdded = true;
        }
    }