public void SwapMovement(movement movement) { bool switched = true; switch (movement) { case movement.wander: if (currentMovement != movement.waypoint_rand && currentMovement != movement.waypoint_seq && currentMovement != movement.shrink) { switched = false; break; } deactivateMovement(); waypoint.enabled = false; storedMovement = movement.wander; wander.enabled = true; childOff(); break; case movement.waypoint_seq: if (currentMovement != movement.waypoint_rand && currentMovement != movement.wander && currentMovement != movement.shrink) { switched = false; break; } transform.GetComponent <SpriteRenderer>().color = Color.white; deactivateMovement(); waypoint.enabled = true; waypoint.ToggleMovement(false); storedMovement = movement.waypoint_seq; childOn(); break; case movement.waypoint_rand: transform.GetComponent <SpriteRenderer>().color = Color.white; if (currentMovement != movement.wander && currentMovement != movement.waypoint_seq && currentMovement != movement.shrink) { switched = false; break; } deactivateMovement(); waypoint.enabled = true; waypoint.ToggleMovement(true); storedMovement = movement.waypoint_rand; childOn(); break; case movement.stunned_state: deactivateMovement(); stunnedState.enabled = true; stunnedState.setEggUp(EggUp); stunnedState.setStartPos(); childOff(); break; case movement.egg_state: deactivateMovement(); eggState.enabled = true; eggState.setEggUp(EggUp); eggState.setStartPos(); childOff(); break; case movement.CCW_Rotate: deactivateMovement(); childOn(); transform.GetComponent <SpriteRenderer>().color = Color.red; ccwState.enabled = true; ccwState.StartRotation(); break; case movement.CW_Rotate: deactivateMovement(); childOn(); cwState.enabled = true; cwState.StartRotation(); break; case movement.chase: deactivateMovement(); childOn(); chaseState.enabled = true; chaseState.StartChase(FindObjectOfType <Hero>()); break; case movement.enlarge: deactivateMovement(); childOn(); enlargeState.enabled = true; enlargeState.Enlarge(); break; case movement.shrink: deactivateMovement(); childOn(); shrinkState.enabled = true; shrinkState.Shrink(); break; } if (switched) { currentMovement = movement; } }