private void Init() { Time.timeScale = 1.0f; gamePaused = false; m_prevPlatform = m_firstJumpPoint; m_nextPlatform = m_firstJumpPoint.GetComponent <PlatformJumpPointView>().NextPlatform; transform.position = m_firstJumpPoint.Position + Vector3.up; SetLookTarget(m_nextPlatform, m_nextPlatform); LookTargetSmooth = m_nextPlatform.Position; transform.LookAt(LookTargetSmooth); var current = m_firstJumpPoint.GetComponent <PlatformJumpPointView>(); while (current != null) { if (current.NextPlatform != null) { current.NextPlatform.GetComponent <PlatformJumpPointView>().PrevPlatform = current; current = current.NextPlatform.GetComponent <PlatformJumpPointView>(); } else { current = null; } } gameMusic.Play(); }
private void SetLookTarget(JumpPointView prevJumpPoint, JumpPointView nextJumpPoint) { Vector3 direction = nextJumpPoint.NativePosition - prevJumpPoint.NativePosition; direction = direction.normalized * 4.0f; Vector3 lookTarget = nextJumpPoint.NativePosition + direction; SetLookTarget(lookTarget); }
private void Awake() { var playViewPresenterGameObject = GameObject.Find("PlayView"); m_playViewPresenter = playViewPresenterGameObject.GetComponent <PlayViewPresenter>(); m_playViewPresenter.RetryPressed.AddListener(() => { UiEvent_Reset(); }); //m_soundJump = transform.Find("Jump").GetComponent<AudioSource>(); //m_soundLand = transform.Find("Land").GetComponent<AudioSource>(); m_dudeCamera = transform.Find("CameraAnimRoot").GetComponent <DureCamera>(); if (m_firstJumpPoint == null) { var track = GameObject.Find("Track"); if (track != null && track.transform.childCount > 1) { m_firstJumpPoint = track.transform.GetChild(0).GetComponent <PlatformJumpPointView>(); } } }
private void OnTriggerEnter(Collider collider) { // Ignore collisions if falling down. if (m_isFallingDown) { return; } var bodyCollider = collider.gameObject.GetComponent <BodyCollider>(); if (bodyCollider != null && !bodyCollider.m_platform.Visited) { OnBodyCollision(bodyCollider); return; } var platform = collider.gameObject.GetComponent <Platform>(); if (!platform) { return; } if (platform.Visited) { return; } platform.Visited = true; PlatformsScored++; var platformJumpPoint = platform.GetComponent <PlatformJumpPointView>(); m_prevPlatform = platformJumpPoint; m_nextPlatform = platformJumpPoint.NextPlatform; platformJumpPoint.NotifyJump(); // We've reached the last platform. if (m_nextPlatform == null) { m_playViewPresenter.ShowWinnerPanel(); Time.timeScale = 0.0f; // SceneManager.LoadScene(SceneManager.GetActiveScene().name); return; } SetLookTarget(m_prevPlatform, m_nextPlatform); Jump(m_nextPlatform.NativePosition, m_prevPlatform.GetJumpSpeed(), m_prevPlatform.GetJumpAngle()); m_dudeCamera.PlayPlatformJumpAnimation(); switch (collider.tag) { case "platformNormal": dudeSFX.PlayOneShot(sndPlatformNormal); break; case "platformEject": dudeSFX.PlayOneShot(sndPlatformEject); break; case "platformSlide": dudeSFX.PlayOneShot(sndPlatformSlide); break; } m_canJump = true; }