void Awake() { syncController = GameObject.FindObjectOfType <SyncController>(); spellsController = GameObject.FindObjectOfType <SpellsController>(); timeToStart = Time.time + 4; initialCanvas = transform.Find("InitialCanvas").gameObject; initialText = initialCanvas.transform.Find("InitialText").GetComponent <Text>(); mapNameText = initialCanvas.transform.Find("MapNameText").GetComponent <Text>(); initialCanvas.SetActive(true); gameStarted = false; playerInfoText = GameObject.Find("InfoText").GetComponent <Text>(); healthbarImage = GameObject.Find("HealthbarImage").GetComponent <Image>(); spellsListCanvas = GameObject.Find("SpellsListCanvas").transform; endCanvas = transform.Find("EndCanvas").gameObject; winnerNameText = endCanvas.transform.Find("Panel/WinnerCanvas/WinnerNameText").GetComponent <Text>(); endCanvas.SetActive(false); spellIcons = new List <GameSpellIcon>(); foreach (SpellItem spellItem in syncController.GetSpellsSelected()) { GameSpellIcon spellIcon = Instantiate(spellIconPrefab).GetComponent <GameSpellIcon>(); spellIcon.SetData(spellItem); spellIcon.transform.SetParent(spellsListCanvas); spellIcons.Add(spellIcon); } }
void Awake() { syncController = GameObject.FindObjectOfType <SyncController>(); spellsController = GameObject.FindObjectOfType <SpellsController>(); selectRoomCanvas = transform.Find("SelectRoomCanvas").gameObject; roomCanvas = transform.Find("RoomCanvas").gameObject; roomNameInput = selectRoomCanvas.transform.Find("RoomNameInput").GetComponent <InputField>(); roomNameInput.onValueChanged.AddListener(this.OnRoomNameChange); userNameInput = selectRoomCanvas.transform.Find("UserNameInput").GetComponent <InputField>(); userNameInput.onValueChanged.AddListener(this.OnUserNameChange); createGameButton = selectRoomCanvas.transform.Find("CreateGameButton").GetComponent <Button>(); joinGameButton = selectRoomCanvas.transform.Find("JoinGameButton").GetComponent <Button>(); startGameButton = roomCanvas.transform.Find("StartGameButton").GetComponent <Button>(); selectMapButton = roomCanvas.transform.Find("SelectMapButton").GetComponent <Button>(); readyButton = roomCanvas.transform.Find("ReadyButton").GetComponent <Button>(); playerColorImage = roomCanvas.transform.Find("PlayerColorImage").GetComponent <Image>(); usersList = roomCanvas.transform.Find("UsersList").gameObject; offensiveSpellsList = roomCanvas.transform.Find("OffensiveSpellsList"); defensiveSpellsList = roomCanvas.transform.Find("DefensiveSpellsList"); roomNameText = roomCanvas.transform.Find("RoomNameText").GetComponent <Text>(); mapSelectContainer = roomCanvas.transform.Find("SelectMapContainer").gameObject; mapSelectContainer.SetActive(false); spellData = roomCanvas.transform.Find("SpellData").gameObject; spellName = spellData.transform.Find("SpellName").GetComponent <Text>(); spellMultiplier = spellData.transform.Find("Multiplier").GetComponent <Text>(); spellIncrement = spellData.transform.Find("Increment").GetComponent <Text>(); spellCooldown = spellData.transform.Find("Cooldown").GetComponent <Text>(); spellDescription = spellData.transform.Find("SpellDescription").GetComponent <Text>(); spellMultiplierIcon = spellData.transform.Find("MultiplierIcon").gameObject; spellIncrementIcon = spellData.transform.Find("IncrementIcon").gameObject; spellData.SetActive(false); createGameButton.onClick.AddListener(syncController.CreateGame); joinGameButton.onClick.AddListener(syncController.JoinGame); readyButton.onClick.AddListener(this.onReadyClick); selectMapButton.onClick.AddListener(this.OpenSelectMap); mapName = ""; startGameButton.onClick.AddListener(() => syncController.StartGame(mapName)); selectRoomCanvas.SetActive(true); roomCanvas.SetActive(false); User us = syncController.GetUser(); if (us != null) { this.MyUserJoinedRoom(syncController.GetRoomName(), us.isOwner); } }
public void Awake() { DontDestroyOnLoad(this.gameObject); spellsController = GameObject.FindObjectOfType <SpellsController>(); playersList = new List <Player>(); spellsList = new List <Spell>(); spellsSelected = new List <string>(); socket = GetComponent <SocketIOComponent>(); roomName = ""; userName = PlayerPrefs.GetString("Name", ""); serverUrl = socket.url; }