コード例 #1
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();
    }