Ejemplo n.º 1
0
    void CreateCell(Vector2 position, NetworkTeam team, int id, int initialHelath, int maxHealth, int pulseValue)
    {
        GameObject cell = GameObject.Instantiate(cellPrefab_);

        cell.transform.position = position;
        cell.GetComponent <NetworkCell>().InitializeServer(id, initialHelath, maxHealth, pulseValue, team);
        cell.GetComponent <NetworkObject>().Spawn();
    }
Ejemplo n.º 2
0
    NetworkTeam CreateTeam(int teamId)
    {
        //GameObject teamGO = GameObject.Instantiate(teamPrefab_);
        NetworkTeam team = new NetworkTeam(teamId);//teamGO.GetComponent<NetworkTeam>();

        //team.Initialize(teamId);
        //teamGO.GetComponent<NetworkObject>().Spawn();
        TM_.teams_.Add(team);
        return(team);
    }
Ejemplo n.º 3
0
    public void ConvertCell(NetworkCell attacker, NetworkCell prey)
    {
        NetworkTeam teamAttacker = null;
        NetworkTeam teamPrey     = null;

        foreach (NetworkTeam team in teams_)
        {
            if (team.HasCell_(attacker))
            {
                teamAttacker = team;
            }
            if (team.HasCell_(prey))
            {
                teamPrey = team;
            }
        }
        teamPrey.RemoveCell(prey.gameObject);
        teamAttacker.AddCell(prey.gameObject);
        ConvertCellClientRpc(teamPrey.TeamCellsArray_, teams_.IndexOf(teamPrey));
        ConvertCellClientRpc(teamAttacker.TeamCellsArray_, teams_.IndexOf(teamAttacker));
        prey.RetreatAllTentacles();
    }
Ejemplo n.º 4
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;
                    }
                }
            }
        }
    }