public override void Start() { base.Start(); // Assign zoom and pan controller if these values are null. if (_zoomController == null) { _zoomController = GameObject.FindObjectOfType <ZoomController>(); } if (_panController == null) { _panController = GameObject.FindObjectOfType <PanController>(); } // Load level based on set from menu. StartCoroutine(ChangeLevel(LoadLevel.Value)); }
private void Awake() { if (_instantiated) { Debug.LogError("Trying to instantiate multiple game managers !"); Destroy(this); } else { _instantiated = true; } if (Instance == null) { Instance = this; } else { Destroy(this); } Application.targetFrameRate = 60; zoomer = FindObjectOfType <ZoomController>(); Random.InitState((int)System.DateTime.Now.Ticks); advancedStructures = new[] { StructureChoice.Torii, StructureChoice.Temple2, StructureChoice.Statue, StructureChoice.Guillotine, StructureChoice.Gateway }; EasyStructures = new List <StructureChoice>(); EasyStructures.Add(StructureChoice.Dolmen); EasyStructures.Add(StructureChoice.LittleTree); EasyStructures.Add(StructureChoice.Pyramid); EasyStructures.Add(StructureChoice.Triangle); }
// Use this for initialization void Start () { _startPos = transform.position; _zoomController = Camera.main.GetComponent<ZoomController>(); }
void Start() { scoreObj = GameObject.FindGameObjectWithTag("Score"); goalObj = GameObject.FindGameObjectWithTag("Goal"); opObj = GameObject.FindGameObjectWithTag("Operation"); sliderObj = GameObject.Find("ScoreSlider"); arrowLRSprite = GameObject.Find("Red Arrow"); arrowUDSprite = GameObject.Find("Orange Arrow"); //audioSource = GameObject.FindGameObjectWithTag("MainMusic").GetComponent<AudioSource>(); arrowLROriginPos = new Vector3(-25, 0, 0); arrowUDOriginPos = new Vector3(-25, 0, 0); if (sliderObj) { scoreSlider = sliderObj.GetComponent <Slider>(); } mainCamera = GameObject.Find("Main Camera").GetComponent <ZoomController>(); //audioClips = GameObject.FindGameObjectsWithTag("MainMusic"); addSound = GameObject.FindGameObjectWithTag("AddSound"); subSound = GameObject.FindGameObjectWithTag("SubSound"); divSound = GameObject.FindGameObjectWithTag("DivSound"); mulSound = GameObject.FindGameObjectWithTag("MulSound"); subUpSound = GameObject.Find("SubUpSound"); subDownSound = GameObject.Find("SubDownSound"); replaySound = GameObject.Find("Replay Sound"); clickSound = GameObject.Find("Click Sound"); mainSound = GameObject.Find("Tetris"); unlockedObj = GameObject.Find("UnlockedText"); if (unlockedObj) { unlockedText = unlockedObj.GetComponent <Text>(); unlockedObj.SetActive(false); } if (addSound) { addSoundClip = addSound.GetComponent <AudioSource>(); } if (subSound) { subSoundClip = subSound.GetComponent <AudioSource>(); } if (divSound) { divSoundClip = divSound.GetComponent <AudioSource>(); } if (mulSound) { mulSoundClip = mulSound.GetComponent <AudioSource>(); } if (replaySound) { replaySoundClip = replaySound.GetComponent <AudioSource>(); } if (clickSound) { clickSoundClip = clickSound.GetComponent <AudioSource>(); } if (subUpSound) { subUpSoundClip = subUpSound.GetComponent <AudioSource>(); } if (subDownSound) { subDownSoundClip = subDownSound.GetComponent <AudioSource>(); } if (mainSound) { mainSoundClip = mainSound.GetComponent <AudioSource>(); String scene = SceneManager.GetActiveScene().name; if (mainSoundClip) { if (!mainSoundClip.isPlaying && scene != "Over" && scene != "Over2P") { mainSoundClip.Play(); } } } if (scoreObj) { Data.score = 0.0f; score = 0.0f; scoreSlider.value = score; Data.fallSpeed = 0.4f; goal = Data.goal; //Data.goal = 50; scoreText = scoreObj.GetComponent <Text>(); scoreText.text = "SCORE: 0.00"; goalText = goalObj.GetComponent <Text>(); goalText.text = goal.ToString(); opText = opObj.GetComponent <Text>(); } spawnerObj = GameObject.Find("Spawner"); if (spawnerObj) { spawner = spawnerObj.GetComponent <Spawner>(); } Reset(); }
private void Awake() { _camera = Camera.main; _objectRotation = FindObjectOfType <ObjectRotation>(); _zoomController = FindObjectOfType <ZoomController>(); }
public void Start() { mat = GetComponent <Renderer>().material; zoomController = FindObjectOfType <ZoomController>(); initialPosition = transform.localPosition; }
public void AssignImage() { transform.parent.localScale = GetOneScale(); // Scale parent instead to autoscale everything else // Set the image material here. MeshRenderer renderer = GetComponent <MeshRenderer>(); renderer.material = GameMgr.CurrentIsInverted() ? materialInverted : material; renderer.material.SetTexture("_MainTex", GameMgr.CurrentTex2D()); // Now we need to calculate the image and make a best fit to the current screen dimensions. float screenRatio = ((float)Screen.width) / ((float)Screen.height); float imageRatio = GameMgr.CurrentSizeRatio(); // Calculate zoom sizes here. Debug.LogFormat("Screen ratio versus image ratio {0} {1}", screenRatio, imageRatio); float actualScreenRatio = (ScreenArea.rect.width / ScreenArea.rect.height); Debug.LogFormat("Screen area {0} {1} {2}", ScreenArea.rect.width, ScreenArea.rect.height, actualScreenRatio); if (_zoomController == null) { _zoomController = Camera.main.GetComponent <ZoomController>(); } if (_zoomController != null) { // The max orthographic size to fill the Y-axis is 0.621f. // Currently assumes test image is 1:1 square. float defaultZoom = MAX_SCALE_Y; // If actual screen ratio is landscape, we need to fill in the // X-axis. if (actualScreenRatio > 1f) { defaultZoom = MAX_SCALE_Y / actualScreenRatio; } //float defaultZoom = actualScreenRatio * MAX_SCALE_Y; //if (defaultZoom > MAX_SCALE_Y) // defaultZoom = MAX_SCALE_Y; GameMgr.Instance.CurrentLevel.ZoomSizes = new Vector2(defaultZoom, defaultZoom * smallestZoomAmount); _zoomController.UpdateZoomSizes(); } if (_panController == null) { _panController = Camera.main.GetComponent <PanController>(); } if (_panController != null) { _panController.ResetSliders(); // Set to initial pan amounts. float defaultPanX = 0.1f; float defaultPanY = 0.1f; // If screen area is landscape, then there should be no horizontal // panning and only vertical panning. if (actualScreenRatio > 1f) { defaultPanX = 0.1f; defaultPanY = (actualScreenRatio - MAX_SCALE_Y) * 0.25f; } else { defaultPanX = (actualScreenRatio - MAX_SCALE_Y) * 0.5f; defaultPanY = 0.1f; } GameMgr.Instance.CurrentLevel.PanAmount = new Vector2(defaultPanX, defaultPanY); float zoomedPanX = 0.5f; float zoomedPanY = 0.5f; GameMgr.Instance.CurrentLevel.ZoomedInPanAmount = new Vector2(zoomedPanX, zoomedPanY); _panController.HorizontalPanRange = GameMgr.PanAmount().x; _panController.VerticalPanRange = GameMgr.PanAmount().y; //_panController.HideHorizontalSlider(); //_panController.HideVerticalSlider(); if (Mathf.Abs(defaultPanX) > 0.01f) { _panController.ShowHorizontalSlider(); } if (Mathf.Abs(defaultPanY) > 0.01f) { _panController.ShowVerticalSlider(); } // Force showing pan slider. if (GameMgr.CNV_TOOL) { _panController.ShowHorizontalSlider(); _panController.HideVerticalSlider(); } } _assigned = true; }
public void Start() { // Find components if possible at this point. _zoomController = Camera.main.GetComponent <ZoomController>(); _panController = Camera.main.GetComponent <PanController>(); }