// Use this for initialization void Start () { fountainParticles = (GameObject)Instantiate(fountainParticles, transform.position, Quaternion.identity); fountainParticles.GetComponent<ParticleSystem>().Play(); getPowerParticles = (GameObject)Instantiate(getPowerParticles, transform.position, Quaternion.identity); getPowerPSystem = getPowerParticles.GetComponent<ParticleSystem>(); var ui = GameObject.Find("LobbyPlacement(Clone)"); placementUI = ui.GetComponentInChildren<PlacementUI>(); }
void Awake(){ powerPrefabs = GetComponent<PowerPrefabs>(); GameObject placementRoot = Instantiate(PlacementUIPrefab, PlacementUIPrefab.transform.position, Quaternion.identity) as GameObject; placementUI = placementRoot.GetComponent<PlacementUI>(); //if starting powers are the same remove the second one and make it undefined before adding to UI if (firstPower == secondPower) { secondPower = PowerType.UNDEFINED; } placementUI.Initialize (powerPrefabs, firstPower, secondPower); }
void OnTriggerEnter2D(Collider2D other){ if(other.tag == "Player"){ if( tutorialUse ) placementUI = GameObject.Find( "OfflinePlacement(Clone)").GetComponent<PlacementUI>(); if(!used && placementUI.CanResupply()){ this.GetComponent<Animator>().enabled = true; reSupplyPlayer(); } } }
//teach death screen //spawn a dummy and a power //resupply with powers IEnumerator teachDeathScreen(){ deathScreenEvent = true; deathscreen = GameObject.Find( "OfflinePlacement(Clone)").GetComponent<PlacementUI>(); warningSign.transform.position = player.transform.position; warningSign.SetActive (true); yield return new WaitForSeconds (0.5f); //player.GetComponent<Controller2D> ().locked = true; setupPowerToUse(); yield return new WaitForSeconds (2f); setFadeClear (); yield return new WaitForSeconds (durationOfFading); setFadeSolid (); changeText (fifthMessage); InvokeRepeating ("resupplyDeathScreen", 1f, 10f); }
private void OnGUI() { if (styles == null) { styles = new GUIStyle[] { new GUIStyle(GUI.skin.textField) { fontSize = (int)(0.02f * (float)Screen.height) }, new GUIStyle(GUI.skin.box) { fontSize = (int)(0.04f * (float)Screen.height) }, new GUIStyle(GUI.skin.button) { fontSize = (int)(0.02f * (float)Screen.height) }, new GUIStyle(GUI.skin.label) { fontSize = (int)(0.014f * (float)Screen.height) }, new GUIStyle(GUI.skin.box) { fontSize = (int)(0.025f * (float)Screen.height) } }; backgroundColor = new Color32(51, 100, 51, 255); background = new Texture2D(1, 1); background.SetPixel(0, 0, new Color(1, 1, 1, 1)); background.Apply(); } else { styles[0].fontSize = (int)(0.02f * (float)Screen.height); styles[1].fontSize = (int)(0.04f * (float)Screen.height); styles[2].fontSize = (int)(0.02f * (float)Screen.height); styles[3].fontSize = (int)(0.014f * (float)Screen.height); styles[4].fontSize = (int)(0.025f * (float)Screen.height); styles[1].normal.background = background; styles[4].normal.background = background; GUI.backgroundColor = backgroundColor; } GameModeService gameModeService = ServiceLocator.GetService <GameModeService>(); GameStateManager gameModeManager = ServiceLocator.GetService <GameStateManager>(); PlacementUI pUI = FindObjectOfType <PlacementUI>(); Faction selectedFaction = null; if (pUI) { selectedFaction = (Faction)pUI.GetField("m_selectedFaction"); } if (gameModeService && (gameModeManager.GameState == GameState.PlacementState) && (pUI) && selectedFaction && (selectedFaction.Entity.Name == faction.Entity.Name || loadedFactions.ContainsKey(((Faction)pUI.GetField("m_selectedFaction")).Entity.GUID)) && enableGUI) { UnitPlacementBrush brush = (UnitPlacementBrush)pUI.GetField("m_unitPlacementBrush"); UnitBlueprint selectedUnit = brush.UnitToSpawn; if (!canvas) { canvas = new GameObject("WebTabsCanvas"); } canvas.SetActive(true); Canvas gameCanvas = FindObjectOfType <Canvas>(); if (gameCanvas) { canvas.transform.SetParent(gameCanvas.transform); canvas.FetchComponent <EventSystem>(); canvas.FetchComponent <Image>().color = new Color32(4, 36, 20, 255); RectTransform rt = canvas.FetchComponent <RectTransform>(); rt.pivot = new Vector2(0.5f, 0.5f); rt.anchorMax = new Vector2(0.99f, 0.935f); rt.anchorMin = new Vector2(0.79f, 0.41f); rt.anchoredPosition = Vector2.zero; rt.sizeDelta = new Vector2(1, 1); } GUI.Box(new Rect(0.79f * (float)Screen.width, 0.06f * (float)Screen.height, 0.2f * (float)Screen.width, 0.15f * (float)Screen.height), "WebTabs", styles[1]); GUI.Label(new Rect(0.81f * (float)Screen.width, 0.105f * (float)Screen.height, 0.05f * (float)Screen.width, 0.04f * (float)Screen.height), "Unit Key:", styles[3]); unitID = GUI.TextField(new Rect(0.858f * (float)Screen.width, 0.108f * (float)Screen.height, 0.05f * (float)Screen.width, 0.025f * (float)Screen.height), unitID, styles[0]).ToLower(); if (unitID.Length > 8) { unitID = unitID.Substring(0, 8); } if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.14f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Get Unit", styles[2])) { GetUnits(new string[] { unitID }); } if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.16f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), ((selectedUnit && Array.Exists(faction.Units, element => element == selectedUnit)) ? "Delete '" + selectedUnit.Entity.Name + "'" : "No unit selected"), styles[2]) && (selectedUnit && Array.Exists(faction.Units, element => element == selectedUnit) && selectedFaction == faction)) { output = "Deleting '" + selectedUnit.Entity.Name + "'...\n"; string deleteID = loadedUnits[selectedUnit.Entity.GUID]; deletedUnits[deleteID] = selectedUnit; loadedUnits.Remove(selectedUnit.Entity.GUID); UFunctions.RemoveUnitFromFaction(selectedUnit, faction); pUI.RedrawFactionUnits(faction); brush.ClearBrushUnit(); foreach (Unit unit in (from Unit unit in FindObjectsOfType <Unit>() where unit.unitBlueprint == selectedUnit select unit)) { brush.RemoveUnitInternal(unit, unit.Team); } output += "Deleted unit successfully!"; } GUI.Box(new Rect(0.79f * (float)Screen.width, 0.25f * (float)Screen.height, 0.2f * (float)Screen.width, 0.15f * (float)Screen.height), "Factions", styles[4]); GUI.Label(new Rect(0.81f * (float)Screen.width, 0.295f * (float)Screen.height, 0.05f * (float)Screen.width, 0.04f * (float)Screen.height), "Faction Key:", styles[3]); factionID = GUI.TextField(new Rect(0.858f * (float)Screen.width, 0.298f * (float)Screen.height, 0.05f * (float)Screen.width, 0.025f * (float)Screen.height), factionID, styles[0]).ToLower(); if (factionID.Length > 8) { factionID = factionID.Substring(0, 8); } if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.33f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Get Faction", styles[2])) { GetFactions(new string[] { factionID }); } if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.35f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), ((selectedFaction && selectedFaction != faction) ? "Delete '" + selectedFaction.Entity.Name + "'" : "No faction selected"), styles[2]) && (selectedFaction) && selectedFaction != faction) { output = "Deleting '" + selectedFaction.Entity.Name + "'...\n"; string deleteID = loadedFactions[selectedFaction.Entity.GUID]; deletedFactions[deleteID] = selectedFaction; loadedFactions.Remove(selectedFaction.Entity.GUID); selectedFaction.m_displayFaction = false; pUI.SelectFaction(); pUI.RedrawFactions(); brush.ClearBrushUnit(); output += "Deleted faction successfully!"; } GUI.Box(new Rect(0.79f * (float)Screen.width, 0.44f * (float)Screen.height, 0.2f * (float)Screen.width, 0.07f * (float)Screen.height), "Save All Data", styles[4]); if (GUI.Button(new Rect(0.82f * (float)Screen.width, 0.48f * (float)Screen.height, 0.15f * (float)Screen.width, 0.02f * (float)Screen.height), "Save", styles[2])) { SaveData(); } GUI.Box(new Rect(0.79f * (float)Screen.width, 0.53f * (float)Screen.height, 0.2f * (float)Screen.width, 0.07f * (float)Screen.height), "Console", styles[4]); GUI.TextField(new Rect(0.81f * (float)Screen.width, 0.56f * (float)Screen.height, 0.2f * (float)Screen.width, 0.04f * (float)Screen.height), output, styles[3]); } else if (canvas) { canvas.SetActive(false); } }
void Awake(){ if(GameObject.Find("LobbyGUI") != null){ sessionManager = SessionManager.Instance; FindPlatforms(); beginTime = float.PositiveInfinity; playerSpawnVectors = new List<Vector3>(); foreach(Transform location in spawnPositions){ playerSpawnVectors.Add(location.position); } hudTools = GetComponent<HUDTools>(); playersReady = new List<NetworkPlayer>(); allTimedSpawns = new HeapPriorityQueue<PowerSpawn>(30); powerPrefabs = GetComponent<PowerPrefabs>(); GameObject placementRoot = Instantiate(placementRootPrefab, placementRootPrefab.transform.position, Quaternion.identity) as GameObject; placementUI = placementRoot.GetComponent<PlacementUI>(); placementUI.Initialize(powerPrefabs); placementUI.SwitchToLive(false); placementUI.Enable(); } }
void Awake(){ sessionManager = SessionManager.Instance; sessionManager.psInfo.LevelReset(); playerSpawnVectors = new List<Vector3>(); foreach(Transform location in spawnPositions){ playerSpawnVectors.Add(location.position); } hudTools = GetComponent<HUDTools>(); playersReady = new List<NetworkPlayer>(); allTimedSpawns = new HeapPriorityQueue<PowerSpawn>(30); powerPrefabs = GetComponent<PowerPrefabs>(); GameObject placementRoot = Instantiate(placementRootPrefab, placementRootPrefab.transform.position, Quaternion.identity) as GameObject; placementUI = placementRoot.GetComponent<PlacementUI>(); timer = GameObject.Find("timer").GetComponent<Timer>(); timer.Hide(); ScoreUI scoreUI = placementRoot.GetComponent<ScoreUI>(); scoreUI.Initialize(sessionManager.psInfo); livesUI = placementRoot.GetComponent<LivesUI>(); livesUI.Initialize(sessionManager.psInfo, sessionManager.psInfo.livesPerRound); pointTracker = GetComponent<PointTracker>(); pointTracker.Initialize(scoreUI); }
public static void Tick() // A thread safe repeating method { if (Time.time > waitTime) // Wait until the interval has passed (~60tps) { waitTime += interval; SocketConnection.SetCulture(); if (SocketConnection.getUIClient().Connected) { ScreenshareSender.SetWinHandle(); // Send the unity window handle for receiving images } if (SocketConnection.switchScene) { SocketConnection.switchScene = false; TABSSceneManager.LoadScene(SocketConnection.newScene, true); // Instantly load the new scene } if (SocketConnection.switchMap) { //SocketConnection.WriteToUI("SHOWMSG|Loading a map!"); // Debug SocketConnection.switchMap = false; CampaignPlayerDataHolder.StartedPlayingSandbox(); // Change the game state TABSSceneManager.LoadMap(GetMap(SocketConnection.newMap)); // Load the new map } if (SocketConnection.updateBudget) // Refresh the UI's budget { SocketConnection.updateBudget = false; UpdateUIBudget(); } while (SocketConnection.tickCommands.TryDequeue(out string newData)) { if (newData.StartsWith("SPAWNUNIT")) { string[] split = newData.Split('|'); string entName = split[1]; Team team = (Team)Enum.Parse(typeof(Team), split[2]); Vector3 pos = StrToVec3(split[3]); UnitBlueprint blueprint = GetUnitBlueprint(entName); GetBrushBehaviorOfUnitBrush(GameObject.FindObjectOfType <UnitBrush>()).Place(blueprint, team, pos); // Add the unit with the brush ServiceLocator.GetService <BattleBudget>().SpendAmount(team, (int)blueprint.UnitCost); // Update the budget UpdateUIBudget(); } else if (newData.StartsWith("REMOVEUNIT")) { string[] split = newData.Split('|'); Vector3 pos = StrToVec3(split[1]); Team team = (Team)Enum.Parse(typeof(Team), split[2]); Unit unit = FindClosestUnit(pos); // Get the nearest unit of the pos if (unit != null && unit.Team == team) { GetBrushBehaviorOfUnitBrush(GameObject.FindObjectOfType <UnitBrush>()).Remove(unit, team); // Remove the unit with the brush ServiceLocator.GetService <BattleBudget>().ReturnAmount(team, (int)unit.unitBlueprint.UnitCost); // Update the budget UpdateUIBudget(); } } else if (newData.StartsWith("CLEAR")) { bool red = bool.Parse(newData.Split('|')[1]); Team team = red ? Team.Red : Team.Blue; PlacementUI pui = GameObject.FindObjectOfType <PlacementUI>(); // Get the placement UI // Clear the right area without triggering an echo UnitLayoutManager.ClearTeam(team); GetClearButtonDelegate(pui)(team); } else if (newData.StartsWith("AUDIO")) { string[] split = newData.Split('|'); string soundRef = split[1]; float volMulti = float.Parse(split[2]); Vector3 relPos = StrToVec3(split[3]); SoundEffectVariations.MaterialType matType = (SoundEffectVariations.MaterialType)Enum. Parse(typeof(SoundEffectVariations.MaterialType), split[4]); Vector3 worldPos = Camera.main.transform.position + relPos; // Get the world pos from the relative one ServiceLocator.GetService <SoundPlayer>().PlaySoundEffect(soundRef, volMulti, worldPos, matType); } } } }
private static PlacementUI.ClearButtonDelegate GetClearButtonDelegate(PlacementUI pui) { return((PlacementUI.ClearButtonDelegate) typeof(PlacementUI).GetMethod("GetOnClickedClear").Invoke(pui, null)); }
// Use this for initialization void Start() { Instance = this; placementUISelection = GameObject.Find("placementUISelection"); }