Пример #1
0
    public void StartGame()
    {
        // Fetch Scripts
        GameObject gameScripts = GameObject.Find("GameScripts");

        spawnTiles       = gameScripts.GetComponent <SpawnTiles>();
        actionManager    = gameScripts.GetComponent <ActionManager>();
        turnManager      = gameScripts.GetComponent <TurnManager>();
        uiManager        = gameScripts.GetComponent <UIManager>();
        inputHandler     = gameScripts.GetComponent <InputHandler>();
        cameraController = gameScripts.GetComponent <CameraController>();

        // Create Map to play on
        spawnTiles.CreateMap(Seed, RoundMap, Mountains);

        // Initialize scripts in a certain order
        actionManager.Initialize();
        uiManager.Initialize();
        inputHandler.Initialize();
        turnManager.Initialize();

        foreach (Player player in Players)
        {
            turnManager.AddPlayer(player);
        }

        uiManager.UpdateCurrentPlayer(turnManager.GetCurrentPlayer());
        uiManager.UpdateResources(
            turnManager.GetCurrentPlayer().GetStone(),
            turnManager.GetCurrentPlayer().GetWood(),
            turnManager.GetCurrentPlayer().GetWheat(),
            turnManager.GetCurrentPlayer().GetCoins());
    }
Пример #2
0
 public void AddPlayers(List <Player> players)
 {
     foreach (Player player in players)
     {
         turnManager.AddPlayer(player);
     }
 }
Пример #3
0
    public void BeginGame(string _peliID)
    {
        GameObject newTurnManager    = Instantiate(turnManagerpreF);
        GameObject PlayerSpawnSystem = Instantiate(PlayerSpawnSystempref);

        // Spawn Server
        NetworkServer.Spawn(newTurnManager);
        NetworkServer.Spawn(PlayerSpawnSystem);
        newTurnManager.GetComponent <NetworkMatchChecker>().matchId = _peliID.toGuid();
        TurnManager turnManager = newTurnManager.GetComponent <TurnManager>();

        for (int i = 0; i < matches.Count; i++)
        {
            if (matches[i].matchID == _peliID)
            {
                foreach (var player in matches[i].pelaajat)
                {
                    PlayerHostScript _pelaaja = player.GetComponent <PlayerHostScript>();
                    turnManager.AddPlayer(_pelaaja);
                    _pelaaja.StartGame();
                }
                break;
            }
        }
    }
Пример #4
0
    public void BeginGame(string _matchID)
    {
        GameObject newTurnManager = Instantiate(turnMangerPrefab);

        NetworkServer.Spawn(newTurnManager);
        newTurnManager.GetComponent <NetworkMatchChecker>().matchId = _matchID.ToGuid();
        TurnManager turnManager = newTurnManager.GetComponent <TurnManager>();

        for (int i = 0; i < matches.Count; ++i)
        {
            if (matches[i].matchID == _matchID)
            {
                foreach (var player in matches[i].players)
                {
                    Player _player = player.GetComponent <Player>();
                    turnManager.AddPlayer(_player);
                    _player.StartGame();
                }
            }
        }
    }
Пример #5
0
 private void HandleServerSceneHasChanged(string sceneName)
 {
     if (sceneName == Utilities.MainGameSceneName)
     {
         GameObject turnManagerInstance = Instantiate(turnManagerPrefab);
         turnManagerInstance.GetComponent <NetworkMatchChecker>().matchId = Player.localPlayer.MatchID.ToGuid();
         TurnManager turnManager = turnManagerInstance.GetComponent <TurnManager>();
         for (int i = 0; i < matches.Count; i++)
         {
             if (matches[i].MatchId == Player.localPlayer.MatchID)
             {
                 foreach (var player in matches[i].players)
                 {
                     //Player plr = player.GetComponent<Player>();
                     turnManager.AddPlayer(player);
                 }
                 break;
             }
         }
         NetworkServer.Spawn(turnManagerInstance, this.connectionToClient);
         GameObject visualEventsInstance = Instantiate(visualEventsPrefab);
         NetworkServer.Spawn(visualEventsInstance);
     }
 }
Пример #6
0
 public void Cmd_AddPlayerToManager()
 {
     manager.AddPlayer(this);
 }