Beispiel #1
0
 public void InitializeSquadBuilder(string modeName)
 {
     SquadBuilder.Initialize();
     SquadBuilder.SetCurrentPlayer(PlayerNo.Player1);
     SquadBuilder.SetPlayers(modeName);
     SquadBuilder.SetDefaultPlayerNames();
 }
Beispiel #2
0
    //SHIP CREATION

    private static void SpawnAllShips()
    {
        foreach (var squadList in SquadBuilder.SquadLists)
        {
            SquadBuilder.SetPlayerSquadFromImportedJson(squadList.SavedConfiguration, squadList.PlayerNo, delegate { });

            if (Roster.GetPlayer(squadList.PlayerNo).GetType() != typeof(HotacAiPlayer))
            {
                JSONObject playerInfo = squadList.SavedConfiguration.GetField("PlayerInfo");
                Roster.GetPlayer(squadList.PlayerNo).NickName = playerInfo.GetField("NickName").str;
                Roster.GetPlayer(squadList.PlayerNo).Title    = playerInfo.GetField("Title").str;
                Roster.GetPlayer(squadList.PlayerNo).Avatar   = playerInfo.GetField("Avatar").str;
            }

            Roster.GetPlayer(squadList.PlayerNo).SquadCost = squadList.Points;
        }

        // Keep order, ships must have same ID on both clients
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player1).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player2).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }

        Board.BoardManager.SetShips();
    }
Beispiel #3
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "OptionsPanel":
            Options.InitializePanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            Network.BrowseMatches();
            break;

        case "SelectFactionPanel":
            SquadBuilder.ClearShipsOfPlayer(SquadBuilder.CurrentPlayer);
            break;

        case "SquadBuilderPanel":
            SquadBuilder.UpdateSquadName("SquadBuilderPanel");
            SquadBuilder.ShowShipsAndUpgrades();
            SquadBuilder.UpdateNextButton();
            break;

        case "SelectShipPanel":
            SquadBuilder.ShowShipsFilteredByFaction();
            break;

        case "SelectPilotPanel":
            SquadBuilder.ShowPilotsFilteredByShipAndFaction();
            break;

        case "ShipSlotsPanel":
            SquadBuilder.ShowPilotWithSlots();
            break;

        case "SelectUpgradePanel":
            SquadBuilder.ShowUpgradesList();
            break;

        case "SquadronOptionsPanel":
            SquadBuilder.UpdateSquadName("SquadronOptionsPanel");
            break;

        case "BrowseSavedSquadsPanel":
            SquadBuilder.BrowseSavedSquads();
            break;

        case "SaveSquadronPanel":
            SquadBuilder.PrepareSaveSquadronPanel();
            break;

        case "ShipSkinsPanel":
            SquadBuilder.ShowSkinButtons();
            break;
        }
    }
Beispiel #4
0
    // NEW

    public void SetCurrentPlayerFactionAndNext(string factionText)
    {
        Faction faction = (Faction)Enum.Parse(typeof(Faction), factionText);

        SquadBuilder.SetCurrentPlayerFaction(faction);

        SquadBuilder.ReturnToSquadBuilder();
    }
 public void Import()
 {
     SquadBuilder.CreateSquadFromImportedJson(
         GameObject.Find("UI/Panels/ImportExportPanel/InputField").GetComponent <InputField>().text,
         SquadBuilder.CurrentPlayer,
         delegate { MainMenu.CurrentMainMenu.ChangePanel("SquadBuilderPanel"); }
         );
 }
Beispiel #6
0
 public void StartSquadBuilerMode(string modeName)
 {
     SquadBuilder.Initialize();
     SquadBuilder.SetCurrentPlayer(PlayerNo.Player1);
     SquadBuilder.SetPlayers(modeName);
     SquadBuilder.SetDefaultPlayerNames();
     ChangePanel("SelectFactionPanel");
 }
Beispiel #7
0
 public static void ShowAiInformation()
 {
     if ((SquadBuilder.GetSquadList(PlayerNo.Player2).PlayerType == typeof(HotacAiPlayer)) && (!Options.DontShowAiInfo))
     {
         GameObject.Find("GlobalUI/OpponentSquad").transform.Find("AiInformation").gameObject.SetActive(true);
         GameObject.Find("GlobalUI/OpponentSquad/AiInformation").transform.Find("ToggleBlock").gameObject.SetActive(false);
     }
 }
 public void NextPlayer()
 {
     if (SquadBuilder.ValidateCurrentPlayersRoster())
     {
         SquadBuilder.SetCurrentPlayer(PlayerNo.Player2);
         MainMenu.CurrentMainMenu.ChangePanel("SelectFactionPanel");
     }
 }
    private void RpcLoadBattleScene()
    {
        //RosterBuilder.GeneratePlayersShipConfigurations();

        SquadBuilder.GetSquadList(PlayerNo.Player1).PlayerType = (isServer) ? typeof(HumanPlayer) : typeof(NetworkOpponentPlayer);
        SquadBuilder.GetSquadList(PlayerNo.Player2).PlayerType = (isServer) ? typeof(NetworkOpponentPlayer) : typeof(HumanPlayer);

        SquadBuilder.LoadBattleScene();
    }
Beispiel #10
0
 private void RpcSendPlayerInfoToClients(int playerNo, string playerName, string title, string avatar, string squadString)
 {
     SquadBuilder.PrepareOnlineMatchLists
     (
         playerNo,
         playerName,
         title,
         avatar,
         squadString
     );
 }
Beispiel #11
0
 public static void SendClientInfoToServer()
 {
     CurrentPlayer.CmdSyncAndStartGame
     (
         Options.NickName,
         Options.Title,
         Options.Avatar,
         SquadBuilder.GetSquadInJson(PlayerNo.Player1).ToString(),
         Global.CurrentVersion
     );
 }
Beispiel #12
0
    public void TrySaveSquadron()
    {
        string squadName = GameObject.Find("UI/Panels/SaveSquadronPanel/Panel/Name/InputField").GetComponent <InputField>().text;

        if (squadName == "")
        {
            squadName = "Unnamed squadron";
        }

        SquadBuilder.SaveSquadron(SquadBuilder.CurrentSquadList, squadName, SquadBuilder.ReturnToSquadBuilder);
    }
Beispiel #13
0
 public void RestartMatch()
 {
     Rules.FinishGame();
     if (ReplaysManager.Mode == ReplaysMode.Write)
     {
         SquadBuilder.ReGenerateSquads(SquadBuilder.SwitchToBattleScene);
     }
     else if (ReplaysManager.Mode == ReplaysMode.Read)
     {
         GameController.StartBattle(ReplaysMode.Read);
     }
 }
 public void FactionSelectionBackIsPressed()
 {
     if (SquadBuilder.CurrentPlayer == PlayerNo.Player1)
     {
         MainMenu.CurrentMainMenu.ChangePanel("GameModeDecisionPanel");
     }
     else if (SquadBuilder.CurrentPlayer == PlayerNo.Player2)
     {
         SquadBuilder.SetCurrentPlayer(PlayerNo.Player1);
         SquadBuilder.ReturnToSquadBuilder();
     }
 }
Beispiel #15
0
    public static void StartBattle(ReplaysMode mode = ReplaysMode.Write)
    {
        GameController.Initialize();
        ReplaysManager.Initialize(mode);

        if (mode == ReplaysMode.Read)
        {
            MainMenu.CurrentMainMenu.InitializeSquadBuilder("Replay");
        }

        Console.Write("Game is started", LogTypes.GameCommands, true, "aqua");
        SquadBuilder.StartLocalGame();
    }
Beispiel #16
0
        private static void PrintNewSquad(IEnumerable <FplPlayer> players)
        {
            var dictionaryBuilder = new PlayerDictionaryBuilder();
            var playerDictionary  = dictionaryBuilder.BuildFilteredPlayerDictionary(players);

            Console.WriteLine($"Number of players (after filter): {playerDictionary.CountNumberOfPlayers()}");

            var squadBuilder = new SquadBuilder();
            var squad        = squadBuilder.BuildTeamByCost(playerDictionary);

            Console.WriteLine(squad.GetSquadString());
            Console.WriteLine($"Squad Cost: {squad.GetSquadCost()}");
        }
Beispiel #17
0
 public void NextPlayer()
 {
     if (SquadBuilder.ValidateCurrentPlayersRoster())
     {
         if (!SquadBuilder.IsVsAiGame)
         {
             NextPlayerOpen();
         }
         else
         {
             MainMenu.CurrentMainMenu.ChangePanel("AiDecisionPanel");
         }
     }
 }
    private void Start()
    {
        DontDestroyOnLoad(this.gameObject);

        if (isLocalPlayer)
        {
            Network.CurrentPlayer = this;

            if (Network.ReadyToStartMatch)
            {
                Network.ReadyToStartMatch = false;
                SquadBuilder.StartNetworkGame();
            }
        }
    }
Beispiel #19
0
    public void StartBattle()
    {
        if (SquadBuilder.ValidateCurrentPlayersRoster())
        {
            SquadBuilder.SaveSquadConfigurations();

            if (!SquadBuilder.IsNetworkGame)
            {
                GameController.StartBattle();
            }
            else
            {
                MainMenu.CurrentMainMenu.ChangePanel("MultiplayerDecisionPanel");
            }
        }
    }
Beispiel #20
0
    public void RpcGetSquadList()
    {
        GameMode.CurrentGameMode = new NetworkGame();

        SquadBuilder.ShowOpponentSquad();

        JSONObject localSquadList = SquadBuilder.GetSquadList(PlayerNo.Player1).SavedConfiguration;

        Network.StoreSquadList(localSquadList.ToString(), isServer);

        if (IsServer)
        {
            SquadBuilder.SwitchPlayers();
        }

        Network.FinishTask();
    }
    private void RpcGetSquadList()
    {
        GameMode.CurrentGameMode = new NetworkGame();

        Global.ToggelLoadingScreen(true);

        JSONObject localSquadList = SquadBuilder.GetSquadList(PlayerNo.Player1).SavedConfiguration;

        Network.StoreSquadList(localSquadList.ToString(), isServer);

        if (IsServer)
        {
            SquadBuilder.SwitchPlayers();
        }

        Network.FinishTask();
    }
Beispiel #22
0
    public void StartBattle()
    {
        if (SquadBuilder.ValidateCurrentPlayersRoster())
        {
            SquadBuilder.SaveSquadConfigurations();
            ShipFactory.Initialize();

            if (!SquadBuilder.IsNetworkGame)
            {
                SquadBuilder.StartLocalGame();
            }
            else
            {
                ChangePanel("MultiplayerDecisionPanel");
            }
        }
    }
    private void RpcSendSquadToOpponent(string squadsJsonString)
    {
        JSONObject squadsJson = new JSONObject(squadsJsonString);

        if (squadsJson.HasField("Server"))
        {
            JSONObject squadJson = squadsJson["Server"];
            SquadBuilder.GetSquadList(PlayerNo.Player1).SavedConfiguration = squadJson;
        }

        if (squadsJson.HasField("Client"))
        {
            JSONObject squadJson = squadsJson["Client"];
            SquadBuilder.GetSquadList(PlayerNo.Player2).SavedConfiguration = squadJson;
            Network.FinishTask();
        }
    }
Beispiel #24
0
    public void CmdSyncAndStartGame(string playerName, string title, string avatar, string squadString, string clientAppVersion)
    {
        if (clientAppVersion == Global.CurrentVersion)
        {
            if (!Network.ConnectionIsEstablished)
            {
                RpcSendPlayerInfoToClients
                (
                    1,
                    Options.NickName,
                    Options.Title,
                    Options.Avatar,
                    SquadBuilder.GetSquadInJson(PlayerNo.Player1).ToString()
                );

                RpcSendPlayerInfoToClients
                (
                    2,
                    playerName,
                    title,
                    avatar,
                    squadString
                );

                RpcStartNetworkGame();

                new NetworkTask
                (
                    "Load Battle Scene",
                    RpcBattleIsReady
                );
            }
            else
            {
                RpcDisconnectExtraClient("Sorry, the host have already found an opponent");
            }
        }
        else
        {
            RpcDisconnectExtraClient("Sorry, the host uses another version of the game: " + Global.CurrentVersion);
        }
    }
Beispiel #25
0
    //SHIP CREATION

    private static void SpawnAllShips()
    {
        ObstaclesManager.Instance.ChosenObstacles = new List <GenericObstacle>();

        foreach (var squadList in SquadBuilder.SquadLists)
        {
            SquadBuilder.SetPlayerSquadFromImportedJson(squadList.Name, squadList.SavedConfiguration, squadList.PlayerNo, delegate { });

            if (Roster.GetPlayer(squadList.PlayerNo).PlayerType != PlayerType.Ai)
            {
                JSONObject playerInfo = squadList.SavedConfiguration.GetField("PlayerInfo");
                Roster.GetPlayer(squadList.PlayerNo).NickName = playerInfo.GetField("NickName").str;
                Roster.GetPlayer(squadList.PlayerNo).Title    = playerInfo.GetField("Title").str;
                Roster.GetPlayer(squadList.PlayerNo).Avatar   = playerInfo.GetField("Avatar").str;
            }

            Roster.GetPlayer(squadList.PlayerNo).SquadCost = squadList.Points;

            Roster.GetPlayer(squadList.PlayerNo).ChosenObstacles = new List <GenericObstacle>()
            {
                ObstaclesManager.GenerateObstacle(squadList.ChosenObstacles[0].ShortName, squadList.PlayerNo),
                ObstaclesManager.GenerateObstacle(squadList.ChosenObstacles[1].ShortName, squadList.PlayerNo),
                ObstaclesManager.GenerateObstacle(squadList.ChosenObstacles[2].ShortName, squadList.PlayerNo)
            };
        }

        // Keep order, ships must have same ID on both clients
        ShipFactory.Initialize();
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player1).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player2).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }

        BoardTools.Board.SetShips();
    }
Beispiel #26
0
    //SHIP CREATION

    private static void SpawnAllShips()
    {
        foreach (var squadList in SquadBuilder.SquadLists)
        {
            SquadBuilder.SetPlayerSquadFromImportedJson(squadList.SavedConfiguration, squadList.PlayerNo, delegate { });
            Roster.GetPlayer(squadList.PlayerNo).SquadCost = squadList.Points;
        }

        // Keep order, ships must have same ID on both clients
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player1).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }
        foreach (SquadBuilderShip shipConfig in SquadBuilder.GetSquadList(PlayerNo.Player2).GetShips())
        {
            GenericShip newShip = ShipFactory.SpawnShip(shipConfig);
            AddShipToLists(newShip);
        }

        Board.BoardManager.SetShips();
    }
Beispiel #27
0
    private void InitializePanelContent(string panelName, string previousPanelName)
    {
        switch (panelName)
        {
        case "MainMenuPanel":
            UpdatePlayerInfo();
            break;

        case "OptionsPanel":
            //Options.InitializePanel();
            OptionsUI.Instance.InitializeOptionsPanel();
            break;

        case "ModsPanel":
            ModsManager.InitializePanel();
            break;

        case "CreditsPanel":
            CreditsUI.InitializePanel();
            break;

        case "BrowseRoomsPanel":
            Network.BrowseMatches();
            break;

        case "SelectFactionPanel":
            SquadBuilder.SetCurrentPlayerFaction(Faction.None);
            SquadBuilder.ClearShipsOfPlayer(SquadBuilder.CurrentPlayer);
            SquadBuilder.ShowFactionsImages();
            break;

        case "SquadBuilderPanel":
            SquadBuilder.CheckAiButtonVisibility();
            SquadBuilder.UpdateSquadName("SquadBuilderPanel");
            SquadBuilder.ShowShipsAndUpgrades();
            SquadBuilder.UpdateNextButton();
            break;

        case "SelectShipPanel":
            SquadBuilder.ShowShipsFilteredByFaction();
            break;

        case "SelectPilotPanel":
            SquadBuilder.ShowPilotsFilteredByShipAndFaction();
            break;

        case "ShipSlotsPanel":
            SquadBuilder.ShowPilotWithSlots();
            break;

        case "SelectUpgradePanel":
            SquadBuilder.ShowUpgradesList();
            break;

        case "SquadronOptionsPanel":
            SquadBuilder.UpdateSquadName("SquadronOptionsPanel");
            break;

        case "BrowseSavedSquadsPanel":
            SquadBuilder.BrowseSavedSquads();
            break;

        case "SaveSquadronPanel":
            SquadBuilder.PrepareSaveSquadronPanel();
            break;

        case "AvatarsPanel":
            InitializePlayerCustomization();
            break;

        case "EditionPanel":
            ShowActiveEdition(Options.Edition);
            break;

        case "ShipInfoPanel":
            SquadBuilder.ShowShipInformation();
            break;

        case "SkinsPanel":
            SquadBuilder.ShowSkinsPanel();
            break;

        case "ChosenObstaclesPanel":
            SquadBuilder.ShowChosenObstaclesPanel();
            break;

        case "BrowseObstaclesPanel":
            SquadBuilder.ShowBrowseObstaclesPanel();
            break;
        }
    }
Beispiel #28
0
 public void RestartMatch()
 {
     Rules.FinishGame();
     SquadBuilder.ReGenerateSquads(SquadBuilder.SwitchToBattlecene);
 }
Beispiel #29
0
 public void AiDecisionPanelBack()
 {
     SquadBuilder.SetCurrentPlayer(PlayerNo.Player1);
     MainMenu.CurrentMainMenu.ChangePanel("SquadBuilderPanel");
 }
Beispiel #30
0
 public void NextPlayerRandomAi()
 {
     SquadBuilder.SetCurrentPlayer(PlayerNo.Player2);
     SquadBuilder.SetRandomAiSquad(StartBattle);
 }