protected virtual void CheckState() { // prevents the state from changing if (!m_lockState) { m_data.m_anim.SetBool("KOd", m_data.m_squished); if (m_data.m_squished) { m_newState = E_PLAYER_STATES.KO; } if (m_newState != E_PLAYER_STATES.NULL && m_newState != m_currentState && m_states2D[(int)m_newState]) { // tells the old state is is being left and the new state is being entered GetCurrentState().Exit(); m_states2D[(int)m_newState].Enter(); // shows the state transition that took place Debug.Log(m_currentState + " -> " + m_newState); // sets the new state to be used m_currentState = m_newState; } } }
public void FixedCycle() { m_newState = GetCurrentState().PhysCycle(m_inputs); CheckState(); for (int z = 0; z < 4; z++) { m_data.m_contacts[z] = false; m_data.m_InteractableContacts[z] = false; } }
public virtual void OnCollisionStay(Collision Other) { float angle = Vector2.Angle(Other.contacts[0].normal, Vector2.up); E_DIRECTIONS dir = E_DIRECTIONS.TOP; if (Mathf.Approximately(angle, 0.0f)) { dir = E_DIRECTIONS.BOTTOM; Rigidbody rigb = Other.gameObject.GetComponent <Rigidbody>(); if (!rigb && gameObject.transform.parent) { rigb = gameObject.transform.parent.GetComponent <Rigidbody>(); } if (rigb && Other.gameObject.tag != "Box") { //m_data.m_velocity.y += rigb.velocity.y; m_data.AddVelocity(0.0f, rigb.velocity.y, 0.0f); if (m_data.m_use3D) { Vector3 platformVelToLocalVel = transform.InverseTransformDirection(rigb.velocity); //m_data.m_velocity.x += platformVelToLocalVel.z; //m_data.m_velocity.z += platformVelToLocalVel.x; m_data.AddVelocity(platformVelToLocalVel.z, 0.0f, platformVelToLocalVel.x); } else { //m_data.m_velocity.x += rigb.velocity.x; //m_data.m_velocity.z += rigb.velocity.z; m_data.AddVelocity(rigb.velocity.x, 0.0f, rigb.velocity.z); } } } else if (Mathf.Approximately(angle, 180.0f)) { dir = E_DIRECTIONS.TOP; } m_newState = GetCurrentState().Colide(dir, Other.gameObject.tag); CheckState(); }
public virtual void Cycle() { m_newState = GetCurrentState().Cycle(m_inputs); CheckState(); }
void OnTriggerExit(Collider other) { m_newState = GetCurrentState().LeaveTrigger(other.gameObject.tag); CheckState(); }
public virtual void OnTriggerStay(Collider other) { m_newState = GetCurrentState().InTrigger(other.gameObject.tag, m_inputs); CheckState(); }
void OnCollisionExit(Collision Other) { m_newState = GetCurrentState().LeaveColision(Other.gameObject.tag); CheckState(); }