void OnStateChanged(M8.State state) { var active = state == stateMove; if (mIsActive != active) { mIsActive = active; if (mIsActive) { if (body) { body.simulated = true; } } } }
void OnEntityChangedState(M8.State state) { StopRoutine(); if (stateControl.state == despawnState) { if (despawnDisablePhysics) { if (body) { body.simulated = false; } } mRout = StartCoroutine(DoDespawn()); } }
void OnStateChanged(M8.State state) { if (mCurRout != null) { StopCoroutine(mCurRout); mCurRout = null; } animator.animScale = 1f; bool physicsEnable = false; if (state == stateSpawn) { //reset move anim. states moveSprite.flipX = false; //apply checkpoint if (Checkpoint.localAvailable) { transform.position = Checkpoint.localPosition; transform.eulerAngles = new Vector3(0f, 0f, Checkpoint.localRotation); } else //apply current to checkpoint local { Checkpoint.localPosition = transform.position; Checkpoint.localRotation = transform.eulerAngles.z; } mCurRout = StartCoroutine(DoSpawn()); } else if (state == stateDespawn) { mCurRout = StartCoroutine(DoDespawn()); } else if (state == stateDeath) { deathCount++; mCurRout = StartCoroutine(DoDeath()); } else if (state == stateQuit) { mCurRout = StartCoroutine(DoQuitter()); } else if (state == stateNormal) { physicsEnable = true; } if (physicsEnable) { bodyControl.body.simulated = true; bodyControl.enabled = true; } else { bodyControl.body.simulated = false; bodyControl.body.velocity = Vector2.zero; bodyControl.body.angularVelocity = 0f; bodyControl.enabled = false; } input.enabled = inputEnabled; }