// Update is called once per frame void Update() { if (transform.position.y < -5f) { Destroy(gameObject); } //grounde = isGrounded (); distToPlayer = Vector2.Distance(transform.position, Player.transform.position); //Debug.Log (distToPlayer); //Debug.Log (State); //if (postDash && inThrowRange) { //for throw during dash // postDash = false; // playerThrow(); //} if ((distToPlayer < AttackDist) && (State == DinoState.IDLE)) { State = DinoState.ATTACK; } if (State == DinoState.ATTACK && isDash()) //enemy is about to dash! { dashRdy = false; //turn off dashing Invoke("dashOn", dashCD); //turn it back on again after a cooldown State = DinoState.DASH; } Act(); }
public void aggro() { if(State != DinoState.STUN) { postDash = false; State = DinoState.ATTACK; } }
public void aggro() { if (State != DinoState.STUN) { postDash = false; State = DinoState.ATTACK; } }
private void endStun() { Animator.Play("dino_walk"); gameObject.GetComponent <SpriteRenderer>().color = Color.white; postDash = false; //resets dashCD State = DinoState.ATTACK; stunned = false; }
// // OnCollisionStay2D(): Sent each frame where a collider on another object is touching this object's collider (2D physics only // void OnCollisionStay2D(Collision2D other) { // Debug.Log("colliding..."); // } // OnCollisionEnter2D(): keep track when dino hits ground void OnCollisionEnter2D(Collision2D other) { Debug.Log("entering..."); if (dinoState == DinoState.jumping) { dinoState = DinoState.running; } }
public void Reset() { Position = startPosition; State = DinoState.Running; Velocity = Vector2.Zero; CurrentFrame = Frames[0]; score = 0; }
public void Jump() { if (State == DinoState.Running || State == DinoState.Standing) { preciseY = runningPosition.Y; Velocity = new Vector2(0, -700); State = DinoState.Jumping; CurrentFrame = Frames[0]; } }
public Dinosaur(Rectangle position, Texture2D spriteSheet, Vector2 velocity, params AnimationFrame[] animationPositions) : base(position, spriteSheet, velocity, animationPositions) { runningPosition = position.Location; startPosition = position; State = DinoState.Standing; FrameIndex = 2; CurrentFrame = Frames[0]; score = 0; }
// Jump(): make dino jump, set dinoState to jumping void Jump() { if (dinoState != DinoState.jumping) { Rigidbody2D rb = GetComponent <Rigidbody2D>(); rb.velocity = new Vector2(0.0f, jumpHeight); dinoState = DinoState.jumping; audioArray[1].Play(); } }
virtual public void Hurt(float damage) { if (State == DinoState.IDLE) { State = DinoState.ATTACK; } health -= damage; if (health <= 0) { money.At(transform.position, Random.Range((int)(10 * Multiplier.moneyDrop), (int)(50 * Multiplier.moneyDrop))); HYPECounter.incrementHype(true); //Increment HYPE twice for big kill HYPECounter.incrementHype(true); Destroy(gameObject); } }
void OnCollisionEnter2D(Collision2D colObj) { if (colObj.collider.tag == "Player") { colObj.gameObject.GetComponent <PlayerHealth>().Hurt(10); if (transform.position.x > colObj.transform.position.x) { Player.GetComponent <Rigidbody2D>().AddForce(new Vector2(-200, 375)); } else if (transform.position.x < colObj.transform.position.x) { Player.GetComponent <Rigidbody2D>().AddForce(new Vector2(200, 375)); } Player.GetComponent <CharControl>().hitAnim(); } if (State == DinoState.DASH && colObj.collider.tag == "wall" && !inNotStunRange) { wallPos = colObj.gameObject; State = DinoState.STUN; } }
public virtual void Update(GameTime gameTime, Queue <Obstacle> obstacles) { timeSinceLastFrame += gameTime.ElapsedGameTime; if (State == DinoState.Dead) { } else { score += gameTime.ElapsedGameTime.TotalMilliseconds / 25; foreach (Obstacle osbtacle in obstacles) { if (Position.Intersects(osbtacle.Position)) { State = DinoState.Dead; break; } } if (State == DinoState.Running) { Position = startPosition; if (timeSinceLastFrame > CurrentFrame.Length) { timeSinceLastFrame = TimeSpan.Zero; if (FrameIndex == 2) { FrameIndex = 3; } else if (FrameIndex == 3) { FrameIndex = 2; } CurrentFrame = Frames[FrameIndex]; } } else if (State == DinoState.Jumping) { float gravity = 1600; Velocity = new Vector2(0, Velocity.Y + (float)(gravity * gameTime.ElapsedGameTime.TotalSeconds)); preciseY += (Velocity.Y * gameTime.ElapsedGameTime.TotalSeconds); if (preciseY < runningPosition.Y) { Position = new Rectangle(runningPosition.X, (int)preciseY, Position.Width, Position.Height); } else { CurrentFrame = Frames[2]; Velocity = new Vector2(0, 0); Position = new Rectangle(runningPosition, CurrentFrame.Position.Size); State = DinoState.Running; } } else if (State == DinoState.Ducking) { if (Position.Bottom < startPosition.Bottom) { float gravity = 2500; Velocity = new Vector2(0, Velocity.Y + (float)(gravity * gameTime.ElapsedGameTime.TotalSeconds)); preciseY += (Velocity.Y * gameTime.ElapsedGameTime.TotalSeconds); if ((preciseY + Texture.Height) < startPosition.Bottom) //Not touched ground { Position = new Rectangle(runningPosition.X, (int)preciseY, Position.Width, Position.Height); } else { CurrentFrame = Frames[2]; Velocity = new Vector2(0, 0); Position = new Rectangle(new Point(startPosition.X, startPosition.Bottom - CurrentFrame.Position.Height), CurrentFrame.Position.Size); } } } } }
public void Duck() { State = DinoState.Ducking; CurrentFrame = Frames[4]; Position = new Rectangle(Position.Location, new Point(CurrentFrame.Position.Width, CurrentFrame.Position.Height)); }
public virtual void Hurt(float damage) { if(State == DinoState.IDLE) { State = DinoState.ATTACK; } health -= damage; if (health <= 0) { Game.incBossesKilled(); //Game.incBounty(8); money.At (transform.position, Random.Range ((int)(10 * Multiplier.moneyDrop),(int)(50 * Multiplier.moneyDrop))); HYPECounter.incrementHype(true); //Increment HYPE twice for big kill HYPECounter.incrementHype(true); ScoreKeeper.EnemiesKilled += 1; //Increment # of kills in current run ledgeAnimator.SetBool ("fall", true); Destroy (gameObject); } }
// Update is called once per frame void Update() { if(transform.position.y < -5f) Destroy (gameObject); //grounde = isGrounded (); distToPlayer = Vector2.Distance (transform.position, Player.transform.position); //Debug.Log (distToPlayer); //Debug.Log (State); //if (postDash && inThrowRange) { //for throw during dash // postDash = false; // playerThrow(); //} if ((distToPlayer < AttackDist) && (State == DinoState.IDLE)) { State = DinoState.ATTACK; } if (State == DinoState.ATTACK && isDash ()) //enemy is about to dash! { dashRdy = false; //turn off dashing Invoke ("dashOn", dashCD); //turn it back on again after a cooldown State = DinoState.DASH; } Act(); }
void OnCollisionEnter2D(Collision2D colObj) { if (colObj.collider.tag == "Player") { colObj.gameObject.GetComponent<PlayerHealth>().HurtPlus(10, gameObject); } if(State == DinoState.DASH && colObj.collider.tag == "wall" && !inNotStunRange) { wallPos = colObj.gameObject; State = DinoState.STUN; } }
private void endStun() { Animator.Play ("dino_walk"); gameObject.GetComponent<SpriteRenderer>().color = Color.white; postDash = false; //resets dashCD State = DinoState.ATTACK; stunned = false; }