public void Init(int p) { PlayerNumber = p; m_SmartPlatformController = GetComponent <SmartPlatformController>(); m_SmartPlatformController.Init(p); m_PlayerControl = GetComponent <PlayerControl>(); m_PlayerControl.Init(p); }
private void Awake() { groundCheck = transform.Find("groundCheck"); frontCheck = transform.Find("frontCheck").transform; Check_top = transform.Find("topCheck").transform; Check_back = transform.Find("backCheck").transform; m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_animator = GetComponent <Animator>(); m_SmartPlatformController = GetComponent <SmartPlatformController>(); }
void OnTriggerEnter2D(Collider2D other) { SmartPlatformController playerCtrl = other.gameObject.GetComponent <SmartPlatformController>(); if (playerCtrl != null && !m_swithInProgress) { m_player = playerCtrl; m_swithInProgress = true; m_spriteRenderer.color = Color.red; } }
// Use this for initialization void Start() { m_ballParent = transform.Find("BallParent"); m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_animator = GetComponent <Animator>(); m_SmartPlatformController = GetComponent <SmartPlatformController>(); m_BoxCollider2D = GetComponent <BoxCollider2D>(); SetState(eActorState.Idle); m_SmartPlatformCollider = GetComponent <SmartPlatformCollider>(); m_SmartPlatformCollider.OnSideCollision = OnSideCollisionDelegate; }
public void Init(ePlayerType type, int psIndex) { PlayerType = type; m_SmartPlatformController = GetComponent <SmartPlatformController>(); m_SmartPlatformController.Init(psIndex); m_PlayerControl = GetComponent <PlayerControl>(); m_PlayerControl.Init(psIndex); if (PlayerType == ePlayerType.Boss) { StartCoroutine(ShowTalk(0)); } initByPlayerType(type); }
void OnTriggerEnter2D(Collider2D other) { SmartPlatformController playerCtrl = other.gameObject.GetComponent <SmartPlatformController>(); if (playerCtrl != null) { RedMushroomBehaviour comp = other.gameObject.AddComponent <RedMushroomBehaviour>(); comp.WasEaten = true; comp.TargetScale = TargetScale; comp.TransformationTime = TransformationTime; comp.EffectDuration = EffectDuration; comp.GrowingUpTime = GrowingUpTime; Destroy(comp, EffectDuration); //StartCoroutine(_SleepingCR()); gameObject.SetActive(false); InvokeRepeating("WakeUp", GrowingUpTime, 0f); } }
void OnTriggerEnter2D(Collider2D other) { SmartPlatformController playerCtrl = other.gameObject.GetComponent <SmartPlatformController>(); if (playerCtrl != null) { if (playerCtrl.CheckPoint != null) { CheckPoint checkPoint = playerCtrl.CheckPoint.GetComponent <CheckPoint>(); if (checkPoint != null) { checkPoint.FlagSprRenderer.sprite = Deactivated; } } playerCtrl.CheckPoint = this.transform; FlagSprRenderer.sprite = Activated; } }
void Update() { // FindObjectsOfType<SmartRectCollider2D>() will be called once per frame, instead make every PlanetBehaviour call it if (Time.frameCount != s_frameCnt) { ++s_fixedFrameCnt; s_frameCnt = Time.frameCount; s_aSmartRectColliders = FindObjectsOfType <SmartRectCollider2D>(); } // Apply planet rotation, translation and scaling, only if not grounded // Because for them grounded, SmartRectCollider2D is already doing that using the moving platform feature for (int i = 0; i < m_attractedCollidersNotGrounded.Count; ++i) { KeyValuePair <Transform, KeyValuePair <Vector3, Vector3> > kvp = m_attractedCollidersNotGrounded[i]; // if transform was destroyed, continue if (kvp.Key != null) { Transform smartColliderTrans = kvp.Key; KeyValuePair <Vector3, Vector3> kvpInvPrev = kvp.Value; smartColliderTrans.position += transform.TransformPoint(kvpInvPrev.Key) - kvpInvPrev.Value; } } m_attractedCollidersNotGrounded.Clear(); for (int i = 0; i < s_aSmartRectColliders.Length; ++i) { SmartRectCollider2D smartRectCollider = s_aSmartRectColliders[i]; Vector2 vDiff = transform.position - smartRectCollider.transform.position; if (vDiff.magnitude <= GravityField) { if (smartRectCollider.gameObject == m_playerCtrl.gameObject) { m_camera2D.Zoom = Mathf.SmoothStep(m_camera2D.Zoom, 6f / GravityField, 0.1f);; } // destroy objects when they are close to the center if (vDiff.magnitude <= 0.5) { SmartPlatformController playerCtrl = smartRectCollider.gameObject.GetComponent <SmartPlatformController>(); if (playerCtrl != null) { #if UNITY_5_3 || UNITY_5_3_OR_NEWER UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex); #else Application.LoadLevel(Application.loadedLevel); #endif } Destroy(smartRectCollider.gameObject); } else { // register the smart collider is it's grounded if (!smartRectCollider.SkinBottomRayContacts.Contains(true)) { KeyValuePair <Vector3, Vector3> kvp = new KeyValuePair <Vector3, Vector3>(transform.InverseTransformPoint(smartRectCollider.transform.position), smartRectCollider.transform.position); m_attractedCollidersNotGrounded.Add(new KeyValuePair <Transform, KeyValuePair <Vector3, Vector3> >(smartRectCollider.transform, kvp)); } if (Gravity > 0f) { if (smartRectCollider.RigidBody2D != null) { smartRectCollider.RigidBody2D.velocity += vDiff.normalized * Gravity * Time.deltaTime / vDiff.sqrMagnitude; } else if (smartRectCollider.RigidBody != null) { smartRectCollider.RigidBody.velocity += (Vector3)vDiff.normalized * Gravity * Time.deltaTime / vDiff.sqrMagnitude; } if (smartRectCollider.SkinBottomRayContacts.Contains(true)) { // avoid player ground flickering smartRectCollider.transform.position += (Vector3)vDiff.normalized * 100 * SmartRectCollider2D.k_SkinMinWidth; } } float rot_z = Mathf.Atan2(vDiff.y, vDiff.x) * Mathf.Rad2Deg; Quaternion dstRot = Quaternion.Euler(0f, 0f, rot_z + 90); float angDiff = Quaternion.Angle(smartRectCollider.transform.rotation, dstRot); // NOTE: (n / angDiff), n will be the angle degrees per second to be rotated. Small values make the collider swipe over moving circular platforms. // and high values make it move to fast when two planets are trying to rotate the same collider smartRectCollider.transform.rotation = Quaternion.Lerp(smartRectCollider.transform.rotation, dstRot, (360f / angDiff) * Time.deltaTime); } } } }
void Start() { m_camera2D = FindObjectOfType <PixelPerfectCameraCtrl>(); m_playerCtrl = FindObjectOfType <SmartPlatformController>(); }