public void Restart() { rage = GetComponent<RagePixelSprite> (); rage.PlayNamedAnimation ("idle"); hair = transform.GetChild (0).gameObject; hairRage = hair.GetComponent<RagePixelSprite> (); hair.active = false; }
void Start() { player = GameObject.FindGameObjectWithTag ("Player"); direction = (player.transform.position - transform.position); direction.Normalize (); direction.y = 0.0f; rage = GetComponent<RagePixelSprite> (); rage.SetTintColor (ColorUtils.RandomColor ()); rage.PlayNamedAnimation ("idle"); seekTime = Time.time + Random.Range (0f, 5.0f); }
// Use this for initialization void Start() { currentSpeed = swimSpeed; rotator = Vector2.zero; ragePixel = GetComponent<RagePixelSprite> (); ragePixel.PlayNamedAnimation ("Idle", false); goingLeft = true; mouthLeft = GameObject.Find ("Mouth Left"); mouthRight = GameObject.Find ("Mouth Right"); body = GameObject.FindGameObjectWithTag ("Body"); if (!body || !mouthLeft || !mouthRight) Debug.LogError ("MISSING MOUTH OR BODY"); mouthLeft.SetActive (true); mouthRight.SetActive (false); }
void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Bullet(Clone)") { Destroy(other.gameObject); ragePixel.PlayNamedAnimation("DEATH", false); isAlive = false; audio.PlayOneShot(death); GameObject Hero = GameObject.FindWithTag("Hero"); Vector3 position = Hero.transform.position; Camera.mainCamera.GetComponent <GameSceneCreator>().CreateEnemyNearBy(position); } else { ChangeDirection(); } }
void Update() { if (!isInSafeZone) { reduceHealth(1); } //Update Right Stick if (!castDirectionSet) { r_Xaxis = Input.GetAxis("R_XAxis_" + controllerNumber); r_Yaxis = -Input.GetAxis("R_YAxis_" + controllerNumber); } if (Input.GetButtonDown("RB_" + controllerNumber) || (Input.GetKey(KeyCode.Space) && controllerNumber == 1)) { casting = true; } if (!casting) { //Check the keyboard state and set the character state accordingly if (Input.GetAxis("L_XAxis_" + controllerNumber) < 0) { state = WalkingState.WalkLeft; } else if (Input.GetAxis("L_XAxis_" + controllerNumber) > 0) { state = WalkingState.WalkRight; } else { state = WalkingState.Standing; } if (Input.GetAxis("L_YAxis_" + controllerNumber) < 0) { if (state == WalkingState.WalkLeft) { state = WalkingState.WalkUpLeft; } else if (state == WalkingState.WalkRight) { state = WalkingState.WalkUpRight; } else { state = WalkingState.WalkUp; } } else if (Input.GetAxis("L_YAxis_" + controllerNumber) > 0) { if (state == WalkingState.WalkLeft) { state = WalkingState.WalkDownLeft; } else if (state == WalkingState.WalkRight) { state = WalkingState.WalkDownRight; } else { state = WalkingState.WalkDown; } } if (state == WalkingState.Standing) { getStandAnimation(lastState); ragePixel.PlayNamedAnimation(animation, false); } else { switch (state) { case (WalkingState.WalkLeft): //Flip horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(true); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WALK R", false); //Move direction. X grows right so left is -1. moveDirection = new Vector3(-1f, 0f, 0f); lastState = LastState.L; break; case (WalkingState.WalkRight): //Not flipping horizontally. Our animation is drawn to walk right. //ragePixel.SetHorizontalFlip(false); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("WALK R", false); //Move direction. X grows right so left is +1. moveDirection = new Vector3(1f, 0f, 0f); lastState = LastState.R; break; case (WalkingState.WalkUp): ragePixel.SetHorizontalFlip(false); moveDirection = new Vector3(0f, 1f, 0f); ragePixel.PlayNamedAnimation("WALK U", false); lastState = LastState.U; break; case (WalkingState.WalkDown): ragePixel.SetHorizontalFlip(false); moveDirection = new Vector3(0f, -1f, 0f); ragePixel.PlayNamedAnimation("WALK D", false); lastState = LastState.D; break; case (WalkingState.WalkUpLeft): ragePixel.SetHorizontalFlip(true); moveDirection = new Vector3(-1f, 1f, 0f) / Mathf.Pow(2f, 0.5f); ragePixel.PlayNamedAnimation("WALK UR", false); lastState = LastState.UL; break; case (WalkingState.WalkUpRight): ragePixel.SetHorizontalFlip(false); moveDirection = new Vector3(1f, 1f, 0f) / Mathf.Pow(2f, 0.5f); ragePixel.PlayNamedAnimation("WALK UR", false); lastState = LastState.UR; break; case (WalkingState.WalkDownLeft): ragePixel.SetHorizontalFlip(true); moveDirection = new Vector3(-1f, -1f, 0f) / Mathf.Pow(2f, 0.5f); ragePixel.PlayNamedAnimation("WALK DR", false); lastState = LastState.DL; break; case (WalkingState.WalkDownRight): ragePixel.SetHorizontalFlip(false); moveDirection = new Vector3(1f, -1f, 0f) / Mathf.Pow(2f, 0.5f); ragePixel.PlayNamedAnimation("WALK DR", false); lastState = LastState.DR; break; } } } else if (!castDirectionSet) { if ((Input.GetAxis("R_XAxis_" + controllerNumber) == 0 && Input.GetAxis("R_YAxis_" + controllerNumber) == 0)) { //getStandAnimation(lastState); if (lastState == LastState.R || lastState == LastState.DR || lastState == LastState.UR) { r_Xaxis = 1f; } else if (lastState == LastState.L || lastState == LastState.DL || lastState == LastState.UL) { r_Xaxis = -1f; } if (lastState == LastState.U || lastState == LastState.UR || lastState == LastState.UL) { r_Yaxis = 1f; } else if (lastState == LastState.D || lastState == LastState.DR || lastState == LastState.DL) { r_Yaxis = -1f; } } else { lastState = getCastAngle(); } getStandAnimation(lastState); ragePixel.PlayNamedAnimation(animation, false); castDirectionSet = true; } //Move the sprite into moveDirection at walkingSpeed pixels/sec //transform.Translate(moveDirection * Time.deltaTime * walkingSpeed); reset(); }
void Start() { ragePixel = GetComponent <RagePixelSprite>(); ragePixel.PlayNamedAnimation("WALK", false); }
// Use this for initialization void Start() { ragePixel = GetComponent<RagePixelSprite> (); ragePixel.PlayNamedAnimation("Swim", false); }
// Use this for initialization void Start() { _ragePixel = GetComponent<RagePixelSprite>(); _ragePixel.PlayNamedAnimation("sleep"); }
void Update() { if (!isAlive) { timeToRestart -= Time.deltaTime; if (timeToRestart <= 0) { Application.LoadLevel(Application.loadedLevel); } return; } if (timeFromArr > 0) { timeFromArr -= Time.deltaTime; } else { timeFromArr = BothBoundsRandoms(10, 20); audio.PlayOneShot(arr); } int vertical = (int)Input.GetAxis("Vertical"); int horizontal = (int)Input.GetAxis("Horizontal"); lastState = 0; switch (vertical) { case 1: state = WalkingState.WalkUp; break; case -1: state = WalkingState.WalkDown; break; default: break; } switch (horizontal) { case 1: state = WalkingState.WalkRight; break; case -1: state = WalkingState.WalkLeft; break; default: break; } lastState = state; switch (state) { case (WalkingState.RestDown): ragePixel.PlayNamedAnimation("REST_DOWN", false); break; case (WalkingState.RestUp): ragePixel.PlayNamedAnimation("REST_UP", false); break; case (WalkingState.RestLeft): ragePixel.PlayNamedAnimation("REST_LEFT", false); break; case (WalkingState.RestRight): ragePixel.PlayNamedAnimation("REST_RIGHT", false); break; case (WalkingState.WalkDown): ragePixel.PlayNamedAnimation("WALK_DOWN", false); break; case (WalkingState.WalkUp): ragePixel.PlayNamedAnimation("WALK_UP", false); break; case (WalkingState.WalkLeft): ragePixel.PlayNamedAnimation("WALK_LEFT", false); break; case (WalkingState.WalkRight): ragePixel.PlayNamedAnimation("WALK_RIGHT", false); break; } if (vertical == 0 && horizontal == 0) { this.rigidbody.velocity = new Vector3(0f, 0f, 0f); switch (lastState) { case (WalkingState.WalkDown): ragePixel.PlayNamedAnimation("REST_DOWN", false); break; case (WalkingState.WalkUp): ragePixel.PlayNamedAnimation("REST_UP", false); break; case (WalkingState.WalkLeft): ragePixel.PlayNamedAnimation("REST_LEFT", false); break; case (WalkingState.WalkRight): ragePixel.PlayNamedAnimation("REST_RIGHT", false); break; } } else { this.rigidbody.velocity = new Vector3(horizontal * walkingSpeed, vertical * walkingSpeed, 0); } }
void Start() { rage = GetComponent<RagePixelSprite> (); rage.PlayNamedAnimation("idle"); }
void Update() { //Check the keyboard state and set the character state accordingly if (Input.GetKey(KeyCode.LeftArrow)) { state = WalkingState.WalkLeft; } else if (Input.GetKey(KeyCode.RightArrow)) { state = WalkingState.WalkRight; } else { state = WalkingState.Standing; } Vector3 moveDirection = new Vector3(); switch (state) { case (WalkingState.Standing): //Reset the horizontal flip for clarity ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("STAY", false); if (arrowLeft != null) { arrowLeft.SetTintColor(Color.gray); } if (arrowRight != null) { arrowRight.SetTintColor(Color.gray); } break; case (WalkingState.WalkLeft): //Flip horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(true); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WALK", false); //Move direction. X grows right so left is -1. moveDirection = new Vector3(-1f, 0f, 0f); if (arrowLeft != null) { arrowLeft.SetTintColor(Color.white); } if (arrowRight != null) { arrowRight.SetTintColor(Color.gray); } break; case (WalkingState.WalkRight): //Not flipping horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(false); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WALK", false); //Move direction. X grows right so left is +1. moveDirection = new Vector3(1f, 0f, 0f); if (arrowLeft != null) { arrowLeft.SetTintColor(Color.gray); } if (arrowRight != null) { arrowRight.SetTintColor(Color.white); } break; } //Move the sprite into moveDirection at walkingSpeed pixels/sec transform.Translate(moveDirection * Time.deltaTime * walkingSpeed); }
public void SetAnimation(float Horizontal, float Vertical) { //Check the keyboard state and set the character state accordingly if (Horizontal < (float)0) { state = State.WalkLeft; } else if (Horizontal > (float)0) { state = State.WalkRight; } else if (Vertical < 0) { state = State.WalkToward; } else if (Vertical > 0) { state = State.WalkAway; } else { switch (state) { case (State.WalkToward): prevState = State.WalkToward; break; case (State.WalkAway): prevState = State.WalkAway; break; case (State.WalkLeft): prevState = State.WalkLeft; break; case (State.WalkRight): prevState = State.WalkRight; break; } state = State.Standing; } //Debug.Log(Input.GetAxisRaw("Vertical")); switch (state) { case (State.Standing): switch (prevState) { case (State.WalkAway): //Reset the horizontal flip for clarity ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("StayAway", true); break; case (State.WalkToward): //Reset the horizontal flip for clarity ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("StayToward", true); break; case (State.WalkRight): //Reset the horizontal flip for clarity ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("StayRight", true); break; case (State.WalkLeft): //Reset the horizontal flip for clarity ragePixel.SetHorizontalFlip(true); ragePixel.PlayNamedAnimation("StayRight", true); break; } break; case (State.WalkLeft): //Flip horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(true); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WalkRight", false); break; case (State.WalkRight): //Not flipping horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(false); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WalkRight", false); break; case (State.WalkToward): //Not flipping horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(false); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WalkToward", false); break; case (State.WalkAway): //Not flipping horizontally. Our animation is drawn to walk right. ragePixel.SetHorizontalFlip(false); //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts. ragePixel.PlayNamedAnimation("WalkAway", false); break; } }
void Start() { ragePixel = GetComponent <RagePixelSprite>(); ragePixel.SetHorizontalFlip(false); ragePixel.PlayNamedAnimation("StayToward", false); }