void OnTriggerEnter(Collider other) { if (teleportCoordinates == Vector3.zero) { return; } else if (other.gameObject.tag == "Player" && canTeleport) { // Return point when player goes to bonus stage playerController.returnPosition = other.gameObject.transform.position; // Teleport player to specified coordinates playerController.retryPosition = teleportCoordinates; other.gameObject.transform.position = teleportCoordinates; playerController.inBonus = true; Vector3 cameraCoordinates = teleportCoordinates; CameraSmoothFollow cam = Camera.main.GetComponent <CameraSmoothFollow>(); cameraCoordinates.x -= cam.offset.x; cameraCoordinates.y -= cam.offset.y; cameraCoordinates.z -= cam.offset.z; Camera.main.transform.position = cameraCoordinates; //Debug.Log(Camera.main.transform.position); GameObject smoke = (GameObject)Instantiate(Resources.Load("Smoke")); smoke.transform.position = other.gameObject.transform.position; smoke.transform.localScale = new Vector3(2f, 2f, 2f); canTeleport = false; } }
//Lockdown Timer Variables //private float runTimer; //private bool timerActive; //private bool switchedRooms; public void Initialize() { controllerInput = FindObjectOfType <ControllerInputSystem>().GetComponent <ControllerInputSystem>(); levelGenerator = GetComponent <LevelGeneration>(); roomManager = GetComponent <RoomManager>(); cameraFollow = GameObject.Find("Main Camera").GetComponent <CameraSmoothFollow>(); minimapCamera = FindObjectOfType <MinimapCamera>(); audienceManager = FindObjectOfType <AudienceInteractable>().GetComponent <AudienceInteractableManager>(); websiteData = new WebsiteScript(connectWebsite); StartCoroutine(websiteData.LockFaction(2, 0, "")); screenUI = FindObjectOfType <ScreenUISystem>().GetComponent <ScreenUISystem>(); enemyManager = new EnemyManager(); // Setup level layout levelGenerator.CreateLayout(); roomManager.SpawnLayout(levelGenerator.GetGridSpaces(), levelGenerator.GetSecureRoomNum()); audienceManager.InitializeInteractables(); player = FindObjectOfType <PlayerController>(); timer = 0; // Game Variables moneyCollected = 0; //runTimer = 600; //switchedRooms = false; }
void Awake() { main = this; ChangeState <IdleState>(null); haloView = GetComponentInChildren <HaloView>(); blockMovement = BlockMovement.AddBlockMovement(gameObject, airBox, solidLayer); blockMovement.staticExtrusion = true; jumpSkill.Init(() => Input.GetButton("Jump"), this); rushSkill.Init(() => Input.GetButton("Rush"), this); swapSkill.Init(() => Input.GetButton("Swap"), this); swapCharges.Init(this); //swap energe update StartCoroutine(SwapDetect()); cameraEdge = new CameraEdge(); cameraEdge.edge = GameObject.Find("SceneEdge").GetComponent <BoxCollider2D>(); cameraEdge.cameraPos = CameraPos.main; follow = new CameraSmoothFollow(); follow.mainPos = true; follow.posGetter = () => cameraEdge.UpdatePos(blockMovement.Position); //follow.posGetter = () => blockMovement.Position; follow.distanceSpeedCurve = followDistanceSpeedCurve; follow.priority = 2; follow.Register(this); playerPosDisQueue = new PositionDistanceQueue(() => PositionWithoutHalo , posQueueDisMax , posQueueCountMax); StartCoroutine(playerPosDisQueue.Update()); scaleAd = ApCtrl.CreateAlphaData(ApCtrl.TransformScaleXY(transform), this); StartCoroutine(TransforDetect()); sound = GetComponentInChildren <AudioSource>(); }
IEnumerator RestartTimer() { yield return(new WaitForSeconds(invulnerableTime)); if (inBonus) { transform.position = retryPosition; Vector3 cameraCoordinates = retryPosition; CameraSmoothFollow cam = Camera.main.GetComponent <CameraSmoothFollow>(); cameraCoordinates.x -= cam.offset.x; cameraCoordinates.y -= cam.offset.y; cameraCoordinates.z -= cam.offset.z; Camera.main.transform.position = cameraCoordinates; //Debug.Log(Camera.main.transform.position); GameObject smoke = (GameObject)Instantiate(Resources.Load("Smoke")); smoke.transform.position = transform.position; smoke.transform.localScale = new Vector3(2f, 2f, 2f); health = 2 + healthBonus; animator.Play("PlumIdle", -1, 0.0f); } else { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }
public int FocusCam = 0; // Select in the inspector The view you want to use. use -1 for the Exit trigger void Start() { GameObject tmp = GameObject.Find("Pivot_Cam"); if (tmp) { cam = tmp.GetComponent <CameraSmoothFollow>(); // Access Component CameraSmoothFollow from the main camera } }
private bool CamStyle2D = false; // Use to know if a 2D camera is used void Start() { anim = GetComponent <Animator>(); // Access to the Animator Component obj_Pivot_Cam = GameObject.Find("Pivot_Cam"); // Find object named Pivot_Cam on the hierarchy cameraSmoothFollow = obj_Pivot_Cam.GetComponent <CameraSmoothFollow>(); // Access to the CameraSmoothFollow Component from obj_Pivot_Cam AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); // know what animation is active if (stateInfo.fullPathHash == MoveStateHash) { cameraSmoothFollow.Player_Change_Camera(8); // if MoveStateHash is set at default layer state } else { cameraSmoothFollow.Player_Change_Camera(1); // if IdleStateHash_1 is set at default layer state } LastView = CamView; GameObject tmp = GameObject.Find("PauseAndView"); // Find Gameobject Text_Camera if (tmp != null) { Transform[] children = tmp.GetComponentsInChildren <Transform>(true); foreach (Transform child in children) { if (child.name == "Text_Camera") { Txt = child.GetComponent <Text>(); // Access the component UI.Text tmp = GameObject.Find("PauseAndView"); } } if (tmp != null) { Transform[] children2 = tmp.GetComponentsInChildren <Transform>(true); foreach (Transform child in children2) { if (child.name == "btn_Mobile_Pause") { Txt.transform.SetParent(child); // Make the gameObject child of btn_Mobile_Pause gameObject Txt.gameObject.SetActive(true); // Set active this gamObject } } } } if (cameraSmoothFollow.Return_CamStyle()) { CamStyle2D = true; // Cam 2D is used } }
void Start() { if (Screen.width < Screen.height) { OneTime = false; } else { OneTime = true; } lCD_Screen.transform.position = cam.ViewportToWorldPoint( // --> Choose the LCD Screen position relative to object cam new Vector3(Screen_Position_X, Screen_Position_Y, Screen_Position_Z)); // Transforms position from viewport space into world space. GameObject tmp = GameObject.Find("Pivot_Cam"); MainCam = tmp.GetComponent <CameraSmoothFollow>(); }
private CameraSmoothFollow pivotCam; // access component CameraSmoothFollow. Use to avoid that the camera move too harshly when the ball respawn on the plunger void Start() { Box = GetComponent <BoxCollider>(); source = GetComponent <AudioSource>(); if (obj_Game_Manager == null) // Connect the Mission to the gameObject : "Manager_Game" { obj_Game_Manager = GameObject.Find("Manager_Game"); } //if (obj_Game_Manager != null) // gameManager = obj_Game_Manager.GetComponent<Manager_Game>(); GameObject tmp = GameObject.Find("Pivot_Cam"); if (tmp) { pivotCam = tmp.GetComponent <CameraSmoothFollow>(); // Access Component CameraSmoothFollow from the main camera } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { // Teleport player to specified coordinates other.gameObject.transform.position = teleportCoordinates; Vector3 cameraCoordinates = teleportCoordinates; CameraSmoothFollow cam = Camera.main.GetComponent <CameraSmoothFollow>(); cameraCoordinates.x -= cam.offset.x; cameraCoordinates.y -= cam.offset.y; cameraCoordinates.z -= cam.offset.z; Camera.main.transform.position = cameraCoordinates; //Debug.Log(Camera.main.transform.position); GameObject smoke = (GameObject)Instantiate(Resources.Load("Smoke")); smoke.transform.position = other.gameObject.transform.position; smoke.transform.localScale = new Vector3(2f, 2f, 2f); } }
IEnumerator ReturnTimer() { yield return(new WaitForSeconds(invulnerableTime)); transform.position = returnPosition; Vector3 cameraCoordinates = returnPosition; CameraSmoothFollow cam = Camera.main.GetComponent <CameraSmoothFollow>(); cameraCoordinates.x -= cam.offset.x; cameraCoordinates.y -= cam.offset.y; cameraCoordinates.z -= cam.offset.z; Camera.main.transform.position = cameraCoordinates; //Debug.Log(Camera.main.transform.position); GameObject smoke = (GameObject)Instantiate(Resources.Load("Smoke")); smoke.transform.position = transform.position; smoke.transform.localScale = new Vector3(2f, 2f, 2f); inBonus = false; }
private void Start() { cam = CameraSmoothFollow.instance; }
private void Awake() { instance = this; }
private void OnTriggerEnter(Collider other) { if (other.tag == "Key") { // Equip the item and destroy it when colliding with it if (equippedItem == 0) { Destroy(other.gameObject); equippedItem = 1; } else if (equippedItem == 2 && (Time.time - lastSwitchedItem) > 1) { Destroy(other.gameObject); Instantiate(Resources.Load("Umbrella"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 1; Destroy(other.gameObject); } else if (equippedItem == 3 && (Time.time - lastSwitchedItem) > 1) { Destroy(other.gameObject); Instantiate(Resources.Load("Bubblewand"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 1; Destroy(other.gameObject); } audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxBean, 1f); } if (other.tag == "Umbrella") { if (equippedItem == 0) { Destroy(other.gameObject); equippedItem = 2; } else if (equippedItem == 1 && (Time.time - lastSwitchedItem) > 1.0f) { Instantiate(Resources.Load("Key"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 2; Destroy(other.gameObject); } else if (equippedItem == 3 && (Time.time - lastSwitchedItem) > 1) { Destroy(other.gameObject); Instantiate(Resources.Load("Bubblewand"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 2; Destroy(other.gameObject); } audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxBean, 1f); } if (other.tag == "Bubblewand") { if (equippedItem == 0) { Destroy(other.gameObject); equippedItem = 3; } else if (equippedItem == 1 && (Time.time - lastSwitchedItem) > 1.0f) { Instantiate(Resources.Load("Key"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 3; Destroy(other.gameObject); } else if (equippedItem == 2 && (Time.time - lastSwitchedItem) > 1) { Destroy(other.gameObject); Instantiate(Resources.Load("Umbrella"), other.transform.position, Quaternion.identity); lastSwitchedItem = Time.time; equippedItem = 3; Destroy(other.gameObject); } audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxBean, 1f); } if (other.tag == "Healthup") { // Heal and destroy item when colliding with it if (health < (2 + healthBonus)) { Destroy(other.gameObject); health = 2 + healthBonus; audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxHeal, 0.3f); } } if (other.tag == "Bean") { // Increment bean counter and destroy item when colliding with it HudBeans hudBeans = beanCount.GetComponent <HudBeans>(); Destroy(other.gameObject); beans++; //beans = 50; if (beans == hudBeans.beansTotal) { GameObject Beanstalk = GameObject.Find("Beanstalk"); Animator BeanstalkAnim = Beanstalk.GetComponent <Animator> (); GameObject Camera = GameObject.Find("Main Camera"); Camera.GetComponent <CameraSmoothFollow> ().setInstantFocus(Beanstalk.transform, new Vector3(0, -6, 14)); BeanstalkAnim.SetTrigger("Rise"); } audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxBean, 1f); if (beanFade != null) { StopCoroutine(beanFade); } beanFade = StartCoroutine(hudBeans.VisibilityTimer()); } if (other.tag == "Bean50") { HudBeans hudBeans = beanCount.GetComponent <HudBeans>(); beans = hudBeans.beansTotal; Destroy(other.gameObject); GameObject Beanstalk = GameObject.Find("Beanstalk"); Animator BeanstalkAnim = Beanstalk.GetComponent <Animator> (); GameObject Camera = GameObject.Find("Main Camera"); Camera.GetComponent <CameraSmoothFollow> ().setInstantFocus(Beanstalk.transform, new Vector3(0, -6, 14)); BeanstalkAnim.SetTrigger("Rise"); audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxBean, 1f); if (beanFade != null) { StopCoroutine(beanFade); } beanFade = StartCoroutine(hudBeans.VisibilityTimer()); } if (other.tag == "HealthBonus") { // Increase maximum health by 1 and destroy item when colliding with it Destroy(other.gameObject); HealthBonusController healthBonusController = other.GetComponent <HealthBonusController>(); if (healthBonusController.alreadyObtained == false) { healthBonus++; HealthBonusController.obtainedBonuses[healthBonusController.stageIndex] = true; } health = 2 + healthBonus; audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxHeal, 0.3f); StartCoroutine("ReturnTimer"); } if (other.tag == "Tutorial") { // Change tutorial text to collider's string tutorialText.GetComponent <Text>().text = other.gameObject.GetComponent <TutorialTextController>().tutorialString; if (hideTutorialText != null) { StopCoroutine(hideTutorialText); } showTutorialText = StartCoroutine(tutorialText.GetComponent <HudTutorial>().ShowTimer()); } if (other.tag == "Kill Zone") { // Restart the scene when colliding with a kill zone if (inBonus) { transform.position = retryPosition; Vector3 cameraCoordinates = retryPosition; CameraSmoothFollow cam = Camera.main.GetComponent <CameraSmoothFollow>(); cameraCoordinates.x -= cam.offset.x; cameraCoordinates.y -= cam.offset.y; cameraCoordinates.z -= cam.offset.z; Camera.main.transform.position = cameraCoordinates; //Debug.Log(Camera.main.transform.position); GameObject smoke = (GameObject)Instantiate(Resources.Load("Smoke")); smoke.transform.position = transform.position; smoke.transform.localScale = new Vector3(2f, 2f, 2f); health = 2 + healthBonus; } else { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } } if (other.tag == "Cactus") { if (invulnerable == false && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumCry")) { TakeDamage(); } } if (other.tag == "Firespot" && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumCry")) { if (invulnerable == false) { TakeDamage(); } } if (other.tag == "Castella Projectile") { if (invulnerable == false && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumKey") && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumCry")) { TakeDamage(); CastellaProjectileController castellaProjectile = other.gameObject.GetComponent <CastellaProjectileController>(); castellaProjectile.castellaC.projectileVolleys = 2 * (5 - castellaProjectile.castellaC.health); castellaProjectile.MakeSmoke(); Destroy(other.gameObject); CastellaController castella = GameObject.FindWithTag("Castella").GetComponent <CastellaController>(); castella.StartCoroutine("AttackTimer"); Debug.Log("Set attack timer on player hurt"); } } if (other.tag == "Castella Pillar" && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumCry")) { if (invulnerable == false) { TakeDamage(); } } if (other.tag == "Tornado") { if (moveDirection.y > 2f) { moveDirection.y = 2f; } audioSource.pitch = (Random.Range(0.9f, 1.1f)); audioSource.PlayOneShot(sfxTornado, 1f); } if (other.tag == "Lightning") { if (invulnerable == false && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumBlock") && !animator.GetCurrentAnimatorStateInfo(0).IsName("PlumCry")) { // Deal damage to player if not invulnerable and not spinning, then make the player invulnerable for a short time TakeDamage(); } } if (other.tag == "Bubble") { if (controller.isGrounded) { transform.Translate(0f, .1f, 0f); moveDirection.y = jumpForce; } else { moveDirection.y = jumpForce; Destroy(other.gameObject); } } if (other.tag == "Gem") { other.gameObject.GetComponent <GemController>().bossDoor.gems++; Destroy(other.gameObject); } }
CameraSmoothFollow() { _instance = this; }