Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnStateEnter(State state)
- {
- switch (state)
- {
- case State.Idle:
- modelAnimation.CrossFade("idle" + Random.Range(1, 3), 0.25f);
- break;
- case State.Elevator:
- if (walk)
- {
- walk.Stop();
- walk.ToggleAgent(false);
- }
- modelAnimation.CrossFade("idle" + Random.Range(1, 3), 0.25f);
- break;
- case State.PushPull:
- if (walk)
- {
- walk.Stop();
- }
- modelAnimation.CrossFade("idle" + Random.Range(1, 3), 0.25f);
- float gridSize = 1.0f;
- Vector3 dir = transform.position - pushPull.transform.position;
- dir.y = 0.0f;
- Vector3 newPosition = transform.position;
- if (Mathf.Abs(dir.x) > Mathf.Abs(dir.z))
- {
- float oldZ = dir.z;
- dir.z = 0.0f;
- dir.Normalize();
- newPosition = new Vector3(pushPull.transform.position.x + dir.x, transform.position.y, pushPull.transform.position.z + dir.z);
- if (pushPull.grid.IsObstructed(newPosition))
- {
- dir.x = 0.0f;
- dir.z = oldZ;
- dir.Normalize();
- newPosition = new Vector3(pushPull.transform.position.x + dir.x, transform.position.y, pushPull.transform.position.z + dir.z);
- }
- }
- else
- {
- float oldX = dir.x;
- dir.x = 0.0f;
- dir.Normalize();
- newPosition = new Vector3(pushPull.transform.position.x + dir.x, transform.position.y, pushPull.transform.position.z + dir.z);
- if (pushPull.grid.IsObstructed(newPosition))
- {
- dir.z = 0.0f;
- dir.x = oldX;
- dir.Normalize();
- newPosition = new Vector3(pushPull.transform.position.x + dir.x, transform.position.y, pushPull.transform.position.z + dir.z);
- }
- }
- //dir.Normalize();
- transform.position = newPosition;
- //transform.position = new Vector3((int)(transform.position.x/gridSize) * gridSize, transform.position.y, (int)(transform.position.z/gridSize) * gridSize)
- //+ new Vector3(1, 0, 1) * gridSize * 0.5f;
- model.transform.forward = -dir;
- pushPullOffset = transform.position - pushPull.transform.position;
- break;
- case State.StandOn:
- if (walk)
- {
- walk.ToggleAgent(false);
- }
- modelAnimation.CrossFade("idle" + Random.Range(1, 3), 0.25f);
- break;
- case State.Sit:
- savePosition = transform.position;
- if (walk)
- {
- walk.Stop();
- walk.ToggleAgent(false);
- }
- modelAnimation.CrossFade("idle" + Random.Range(1, 3), 0.25f);
- break;
- case State.Walk:
- modelAnimation.CrossFade("walk", 0.25f);
- if (fat.state == Fat.State.Fat)
- {
- modelAnimation["walk"].speed = fatWalkAnimationSpeed;
- }
- else
- {
- modelAnimation["walk"].speed = walkAnimationSpeed;
- }
- break;
- case State.Run:
- modelAnimation.CrossFade("run", 0.25f);
- modelAnimation["run"].speed = runAnimationSpeed;
- break;
- case State.Slide:
- Global.cinematicCamera.state = CinematicCamera.State.TrackPlayerOnXY;
- Global.cinematicCamera.transform.forward = Vector3.forward;
- model.localEulerAngles = Vector3.zero;
- modelAnimation.CrossFade("idle1", 0.25f);
- break;
- case State.InsidePlant:
- if (walk)
- {
- walk.ToggleAgent(false);
- }
- modelAnimation.CrossFade("idle1", 0.25f);
- break;
- case State.FiredFromPlant:
- if (walk)
- {
- walk.ToggleAgent(false);
- }
- break;
- }
- }
- void OnStateExit(State state)
- {
- switch (state)
- {
- case State.FiredFromPlant:
- if (walk)
- {
- walk.ToggleAgent(true);
- }
- break;
- case State.Elevator:
- if (walk)
- {
- walk.ToggleAgent(true);
- }
- break;
- case State.Sit:
- transform.position = savePosition;
- if (walk)
- {
- walk.ToggleAgent(true);
- }
- //transform.position = savePosition;
- break;
- case State.Slide:
- Global.cinematicCamera.state = CinematicCamera.State.Static;
- break;
- case State.Fall:
- walk.Warp(transform);
- break;
- case State.PushPull:
- if (touchPushPull)
- {
- touchPushPull.Done();
- }
- touchPushPull = null;
- pushPull = null;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement