Exemplo n.º 1
0
    void Awake()
    {
        BuyNewTrap.init();

        playerHud = GameObject.Find("PlayerHud");

        classHud = playerHud.transform.Find("ClassHud").gameObject;

        respawnHud    = playerHud.transform.Find("RespawnTimerPanel").transform.Find("Charge").GetComponent <Image>();
        wHealthBar    = worldHealthBar;
        buffHud       = playerHud.transform.Find("DamageBuffPanel").transform.Find("Charge").GetComponent <Image>();
        healthHud     = playerHud.transform.Find("HealthBarPanel").transform.Find("Charge").GetComponent <Image>();
        healthHudText = healthHud.transform.parent.Find("Text").GetComponent <Text> ();

        scoreBoard = playerHud.transform.Find("ScoreBoardPanel").gameObject;
        Transform[] killsHeader  = { scoreBoard.transform.Find("BlueKillsHeader"), scoreBoard.transform.Find("RedKillsHeader") };
        Transform[] deathsHeader = { scoreBoard.transform.Find("BlueDeathsHeader"), scoreBoard.transform.Find("RedDeathsHeader") };
        scoreBoardPlayers.Add(new List <GameObject> ());
        scoreBoardPlayers.Add(new List <GameObject> ());
        scoreBoardKills.Add(new List <Text> ());
        scoreBoardKills.Add(new List <Text> ());
        scoreBoardDeaths.Add(new List <Text> ());
        scoreBoardDeaths.Add(new List <Text> ());
        foreach (Transform element in scoreBoard.transform)
        {
            if (element.name.StartsWith("BluePlayer") || element.name.StartsWith("RedPlayer"))
            {
                int team = 0;
                if (element.name.StartsWith("RedPlayer"))
                {
                    team = 1;
                }

                int num = LevelLogic.getNumber(element.name);
                while (scoreBoardPlayers[team].Count <= num)
                {
                    scoreBoardPlayers[team].Add(null);
                    scoreBoardKills[team].Add(null);
                    scoreBoardDeaths[team].Add(null);
                }
                scoreBoardPlayers [team] [num] = element.gameObject;
                GameObject kill = (GameObject)GameObject.Instantiate(killsHeader [team].gameObject, scoreBoard.transform);
                kill.GetComponent <RectTransform> ().position = new Vector3(kill.GetComponent <RectTransform> ().position.x, element.position.y, 0);
                scoreBoardKills [team] [num] = kill.GetComponent <Text> ();
                GameObject death = (GameObject)GameObject.Instantiate(deathsHeader [team].gameObject, scoreBoard.transform);
                death.GetComponent <RectTransform> ().position = new Vector3(death.GetComponent <RectTransform> ().position.x, element.position.y, 0);
                scoreBoardDeaths [team] [num] = death.GetComponent <Text> ();
            }
        }

        GameObject killFeed = GameObject.Find("KillFeed");

        foreach (Transform element in killFeed.transform)
        {
            this.killFeed.Add(element.Find("Text"));
        }

        networkSettings = GameObject.Find("NetworkSettings");

        classSelectionMenu      = GameObject.Find("ClassSelectionPanel");
        classSelectionTeams [0] = classSelectionMenu.transform.Find("BlueTeamSelect").GetComponent <Image>();
        classSelectionTeams [0].GetComponent <SelectClass> ().num = 0;
        classSelectionTeams [1] = classSelectionMenu.transform.Find("RedTeamSelect").GetComponent <Image>();
        classSelectionTeams [1].GetComponent <SelectClass> ().num = 1;
        classSelectionTeams [2] = classSelectionMenu.transform.Find("SpectateTeamSelect").GetComponent <Image>();
        classSelectionTeams [2].GetComponent <SelectClass> ().num = 2;

        foreach (Transform element in classSelectionMenu.transform)
        {
            if (element.name.StartsWith("Class"))
            {
                int classNumber = LevelLogic.getNumber(element.name);
                while (classTypes.Count <= classNumber)
                {
                    classTypes.Add(null);
                }
                classTypes[classNumber] = element.GetComponent <Image>();
                element.GetComponent <SelectClass> ().num = (byte)classNumber;
            }
        }

        GameObject trapPlayerHud = GameObject.Find("TrapDisplay");

        trapPlayerHudTypes = new GameObject[2];
        for (int i = 0; i < 2; i++)
        {
            trapPlayerHudTypes[i] = trapPlayerHud.transform.Find("Trap" + i).gameObject;
            trapPlayerHudTypes[i].SetActive(false);
        }
        displayTraps             = new byte[] { 255, 255 };
        trapSelectionZoneMessage = GameObject.Find("TrapSelectionZoneMessage");
        GameObject trapSelectionHud = GameObject.Find("TrapSelectionHud");

        trapsHud = new GameObject[2];         //BuyNewTrap.NUM_TRAP_GROUPS];
        for (int i = 0; i < 2; i++)
        {
            trapsHud [i] = trapSelectionHud.transform.Find("Traps" + i).gameObject;
        }
        GameObject trap = trapSelectionHud.transform.Find("Trap").gameObject;

        trapsChoices = new GameObject[2, 3];
        for (int i = 0; i < trapsHud.Length; i++)
        {
            // 3 choices for each trap:
            for (int n = 0; n < 3; n++)
            {
                GameObject newTrap = (GameObject)Instantiate(trap, trapsHud[i].transform);
                newTrap.GetComponent <RectTransform> ().anchoredPosition = new Vector2(125 + n * 220, 0);
                trapsChoices [i, n] = newTrap;
            }
        }

        trap.SetActive(false);

        HudUpdate();
    }