示例#1
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
示例#2
0
    void InitializeMapSetup()
    {
        if (NetworkManager.Singleton.IsServer)
        {
            if (!TM_)
            {
                if (GUILayout.Button("Start game", buttonStyle, buttonOptions))
                {
                    GameObject teamManagerGO = Instantiate(teamManagerPrefab_);
                    teamManagerGO.GetComponent <NetworkObject>().Spawn();
                    TM_ = teamManagerGO.GetComponent <NetworkTeamManager>();

                    TM_.teamColors.Add(-1, Color.white);
                    TM_.teamColors.Add(0, Color.magenta);
                    TM_.teamColors.Add(1, Color.red);
                    TM_.teamColors.Add(2, Color.green);
                    TM_.teamColors.Add(3, Color.yellow);
                    TM_.teamColors.Add(4, Color.cyan);

                    NetworkTeam neutralTeam = CreateTeam(-1);
                    NetworkTeam team1       = CreateTeam(0);
                    NetworkTeam team2       = CreateTeam(1);

                    NetworkManager.Singleton.ConnectedClients[NetworkManager.Singleton.LocalClientId].PlayerObject.gameObject.GetComponent <NetworkPlayer>().Initialize(1, team1);
                    int cellMaxHealth = 30;
                    switch (mapSelected_)
                    {
                    case 1:
                        CreateCell(new Vector2(0, -6), team1, 1, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0, 6), team2, 2, 10, cellMaxHealth, 1);

                        CreateCell(new Vector2(-1.5f, -4), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(1.5f, -4), neutralTeam, 4, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-2.5f, -2), neutralTeam, 5, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0, -2), neutralTeam, 6, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(2.5f, -2), neutralTeam, 7, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-1.5f, 4), neutralTeam, 8, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(1.5f, 4), neutralTeam, 9, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-2.5f, 2), neutralTeam, 10, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0, 2), neutralTeam, 11, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(2.5f, 2), neutralTeam, 12, 10, cellMaxHealth, 1);

                        break;

                    case 2:
                        CreateCell(new Vector2(3.0547359f, -3.03451753f), team1, 1, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-3.03999996f, 3.03999996f), team2, 2, 10, cellMaxHealth, 1);

                        CreateCell(new Vector2(0.579999983f, -2.68000007f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(2.7021470f, -0.559507132f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-2.69237232f, 0.564286232f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-0.565979958f, 2.68052292f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0, 0), neutralTeam, 3, 10, cellMaxHealth, 1);

                        break;

                    case 3:
                        CreateCell(new Vector2(0, -6), team1, 1, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0, 6), team2, 2, 10, cellMaxHealth, 1);

                        CreateCell(new Vector2(-2.20000005f, -1.10000002f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(0.769999981f, -1.10000002f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(-0.710000038f, 1.10000002f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        CreateCell(new Vector2(2.3499999f, 1.10000002f), neutralTeam, 3, 10, cellMaxHealth, 1);
                        break;
                    }
                }
            }
        }
    }