public override void OnDestroy() { if (Instance == this) { Instance = null; } }
public override void OnAwake() { if (!Instance) { Instance = this; } else { Destroy(this); return; } cam = gameObject.GetComponent <Camera>(); Canvas = cam.AddCanvas(); #region Timer stuff Timer = Canvas.Add("00:00"); //Timer.scale = new Vector2(2f); Timer.scale = new Vector2(0.6f); Timer.position = new Vector2(0.4975f, -0.005f); Timer.color = Color.Black; //Timer.font = Numbers; Timer.origin = new Vector2(0.5f, 0); Timer.depth = 0.8f; if (TimerBGTexture != null) { TimerBG = Canvas.Add(TimerBGTexture); TimerBG.position = new Vector2(0.5f, 0); TimerBG.origin = new Vector2(0.5f, 0); TimerBG.scale = new Vector2(0.6f, 0.7f); TimerBG.color = Color.GhostWhite; TimerBG.depth = 0.9f; //Left of the timer if (ScoreBGTexture != null) { Score1BG = Canvas.Add(ScoreBGTexture); Score1BG.origin = new Vector2(0.5f, 0); Score1BG.position = TimerBG.position - new Vector2((TimerBG.size.x + Score1BG.size.x) / 2, 0); Score1BG.color = MatchSystem.instance.Teams[TEAM_TYPE.TEAM_1].Color; Score1BG.depth = 1; Score1BG.scale = new Vector2(1, 0.7f); Score1BG.flip = new Vector2(0, 1); //Right of the timer Score2BG = Canvas.Add(ScoreBGTexture); Score2BG.origin = new Vector2(0.5f, 0); //for clarity Score2BG.position = TimerBG.position + new Vector2((TimerBG.size.x + Score1BG.size.x) / 2, 0); Score2BG.color = MatchSystem.instance.Teams[TEAM_TYPE.TEAM_2].Color; Score2BG.depth = 1; Score2BG.scale = new Vector2(1, 0.7f); } } Score1 = Canvas.Add(""); //Score1.scale = new Vector2(1.6f); Score1.scale = new Vector2(0.5f); Score1.origin = new Vector2(0.5f, 0); Score1.position = Score1BG.position + new Vector2(0.005f, -0.004f); Score1.outline = true; Score1.color = Color.White; //Score1.font = Numbers; Score1.depth = 0.8f; Score2 = Canvas.Add(""); //Score2.scale = new Vector2(1.6f); Score2.scale = new Vector2(0.5f); Score2.origin = new Vector2(0.5f, 0); Score2.position = Score2BG.position + new Vector2(-0.009f, -0.004f); Score2.outline = true; Score2.color = Color.White; //Score2.font = Numbers; Score2.depth = 0.8f; #endregion #region Announcement stuff Announcement1 = Canvas.Add(""); Announcement1.position = new Vector2(0.5f); //Announcement1.scale = new Vector2(2); //Announcement1.font = AnnouncementFont; Announcement1.color = Color.Green; Announcement1.origin = new Vector2(0.5f); Announcement2 = Canvas.Add(""); Announcement2.position = new Vector2(0.5f); //Announcement2.scale = new Vector2(2); //Announcement2.font = AnnouncementFont; Announcement2.color = Color.Green; Announcement2.origin = new Vector2(0.5f); if (AnnouncementBackground != null) { AnnouncementBG = Canvas.Add(AnnouncementBackground); AnnouncementBG.position = new Vector2(0.5f); AnnouncementBG.scale = Vector2.Zero; AnnouncementBG.origin = new Vector2(0.5f); AnnouncementBG.depth = 1; } #endregion #region Aiming Stuff if (CrosshairTexture != null) { Crosshair = Canvas.Add(CrosshairTexture); Crosshair.origin = new Vector2(0.5f); Crosshair.position = new Vector2(0.5f); Crosshair.scale = new Vector2(0.5f, 0.5f); Crosshair.rendering = false; } if (ChargeBarOutlineTexture != null) { ChargeBarOutline = Canvas.Add(ChargeBarOutlineTexture); ChargeBarOutline.origin = new Vector2(0.5f, 0); ChargeBarOutline.scale = new Vector2(0.4f, 1.8f); ChargeBarOutline.position = new Vector2(0.5f) + new Vector2(Crosshair.size.x, -ChargeBarOutline.size.y / 2); ChargeBarOutline.rendering = false; } if (ChargeBarTexture != null) { ChargeBar = Canvas.Add(ChargeBarTexture); ChargeBar.position = ChargeBarOutline.position + new Vector2(0, ChargeBarOutline.size.y); /*new Vector2(0.9f, 0.1f + ((ChargeBarTexture.height * 9.0f) / 1080.0f))*/; //Need to move the bar its own height down one step. ChargeBar.rendering = false; ChargeBar.origin = new Vector2(0.5f, 0); ChargeBar.rotation = MathHelper.Pi; //Need to rotate the bar 180, because positive x is down on the screen. } #endregion if (BallArrowTexture != null) { BallArrow = Canvas.Add(BallArrowTexture); BallArrow.origin = new Vector2(0.5f); BallArrow.scale = new Vector2(4); BallArrow.position = new Vector2(-1000); BallArrow.color = Score1BG.color + Score2BG.color; } if (HeldObjectIconBall != null) { HeldObjectIcon = Canvas.Add(HeldObjectIconBall); HeldObjectIcon.position = new Vector2(0.1f, 0.9f); HeldObjectIcon.origin = new Vector2(0.5f, 0.5f); HeldObjectIcon.rendering = false; } }
public override void Start() { #region Init GUI if (Camera == null) { Debug.Log("Camera Master cannot find camera"); } JoinHost = gameObject.GetComponent <GUIJoinHost>(); if (JoinHost == null) { Debug.Log("Camera Master cannot find GUI script for join/host"); } MainMenu = gameObject.GetComponent <GUIMainMenu>(); if (MainMenu == null) { Debug.Log("Camera master could not find GUI script for main menu"); } SelectTeam = gameObject.GetComponent <GUISelectTeam>(); if (SelectTeam == null) { Debug.Log("Camera Master cannot find GUI script for select"); } ExitMenu = gameObject.GetComponent <GUIExitMenu>(); if (ExitMenu == null) { Debug.Log("Camera Master cannot find GUI script for exit"); } HostMenu = gameObject.GetComponent <GUIHostMenu>(); if (HostMenu == null) { Debug.Log("Camera Master cannot find GUI script for host"); } OptionsMenu = gameObject.GetComponent <GUIOptionsMenu>(); if (OptionsMenu == null) { Debug.Log("Camera Master cannot find GUI script for Options"); } LoadingScreen = gameObject.GetComponent <GUILoadingScreen>(); if (LoadingScreen == null) { Debug.Log("Camera Maser cannot find GUI script for loading screen"); } ChadCam = gameObject.GetComponent <ChadCam>(); if (ChadCam == null) { Debug.Log("Camera Master cannot find ChadCam"); } else { ChadCam.enabled = false; } SpectatorCam = gameObject.GetComponent <SpectatorCam>(); if (SpectatorCam == null) { Debug.Log("Camera Master cannot find SpectatorCam"); } else { SpectatorCam.enabled = false; } Hud = gameObject.GetComponent <ChadHud>(); if (Hud == null) { Debug.Log("Camera Master could not find Hud"); } ReplayCam = gameObject.GetComponent <ReplayCamera>(); ReplayCam.enabled = false; #endregion #region Chad Hats string settingsHat = UserSettings.GetSetting("Hat"); if (settingsHat != null) { SelectedHat = System.Convert.ToInt32(settingsHat); } else { SelectedHat = (int)(Random.Range(0.0f, 1.0f) * (HatManager.Instance.Hats.Count - 2)) + 1; settingsHat = SelectedHat.ToString(); UserSettings.AddOrUpdateAppSetting("Hat", settingsHat); } if (ChadMainMenu != null) { ChadMMHat = ChadMainMenu.GetComponent <Hatter>(); ChadMMHat.SetHat(SelectedHat); } if (ChadTeam1 != null) { ChadT1Hat = ChadTeam1.GetComponent <Hatter>(); ChadT1Hat.SetHat(SelectedHat); } if (ChadTeam1 != null) { ChadT2Hat = ChadTeam2.GetComponent <Hatter>(); ChadT2Hat.SetHat(SelectedHat); } #endregion SetState(CAM_STATE.MAIN_MENU); }