Exemplo n.º 1
0
    /// <summary>
    /// Only master spawn players
    /// </summary>
    private Player SpawnPlayer(PlayerInitInfo pPlayerInfo, bool pIsLocalImage)
    {
        //Vector2 spawnPosition = game.MapController.ActiveMap.GetSpawnPoint().position;
        Vector2 spawnPosition = game.Map.ActiveMap.
                                GetSpawnPoint(pPlayerInfo.Number).position;

        if (pIsLocalImage)
        {
            spawnPosition += Vector2.down;
        }

        GameObject instance = InstanceFactory.Instantiate(playerPrefab.gameObject, spawnPosition);

        Player playerInstance = instance.GetComponent <Player>();

        bool debug_spwan = false;

        if (debug_spwan)
        {
            if (pPlayerInfo.Name == DebugData.GetPlayerName(1))
            {
                spawnPosition = new Vector2(-3.3f, 3);
            }
            //spawnPosition = Vector2.down;

            if (pPlayerInfo.Name == DebugData.GetPlayerName(2))
            {
                spawnPosition = new Vector2(-1.8f, 2.3f);
            }
            //spawnPosition = Vector2.zero;

            if (pPlayerInfo.Name == DebugData.GetPlayerName(3))
            {
                spawnPosition = Vector2.down;
            }
        }

        //OnAllPlayersAdded += () => playerInstance.SetInfo(pPlayerInfo, spawnPosition);
        playerInstance.SetInfo(pPlayerInfo, pIsLocalImage, spawnPosition);

        //AddPlayer(playerInstance);

        return(playerInstance);
    }