void CatScratch() { if (Target != null) { if (Body.mPS.pushesBottom && !Body.mPS.pushedBottom) { MeleeAttack attack = mAttackManager.meleeAttacks[0]; attack.Activate(); mBossState = BossState.Aggrivated; return; } else if (Body.mPS.pushesBottom && Body.mPS.pushedBottom) { if (Target.Position.y > Position.y) { EnemyBehaviour.Jump(this, jumpHeight); } } if (Vector2.Distance(Target.Position, Position) < 64) { //Replace this with pathfinding to the target if (!mAttackManager.rangedAttacks[0].mIsActive) { Debug.Log("Claw Swipe is not active."); MeleeAttack attack = mAttackManager.meleeAttacks[0]; attack.Activate(); mBossState = BossState.Aggrivated; jumped = false; } else { Debug.Log("Claw Swipe is active."); } } else { Body.mSpeed.x = GetMovementSpeed() * (int)mDirection; if (Body.mPS.pushesLeftTile && !Body.mPS.pushedLeftTile || Body.mPS.pushesRightTile && !Body.mPS.pushedRightTile) { mDirection = (EntityDirection)((int)mDirection * -1); mBossState = BossState.Aggrivated; } } } else { mBossState = BossState.Aggrivated; jumped = false; } }
public override void EntityUpdate() { //This is just a test, probably dont need to do it this way EnemyBehaviour.CheckForTargets(this); if (Body.mPS.inWater) { Body.mIgnoresGravity = true; mMovingSpeed = baseMovementSpeed; jumpHeight = baseJumpHeight; } else { Body.mIgnoresGravity = false; mMovingSpeed = baseMovementSpeed / 2; jumpHeight = baseJumpHeight / 2; } switch (mEnemyState) { case EnemyState.Idle: Renderer.SetAnimState("Idle"); break; case EnemyState.Moving: if (Target != null) { Renderer.SetAnimState("Attack"); Vector2 dir = (Target.Body.mAABB.Center - (Body.mAABB.Center)).normalized; if (Body.mPS.inWater) { Body.mSpeed = ((Vector2)Target.Position - Position).normalized * GetMovementSpeed(); } else { Body.mSpeed.x = (int)mDirection * GetMovementSpeed(); } if (Vector2.Distance(Position, Target.Position) < 64 && Target.Position.y > Position.y) { EnemyBehaviour.Jump(this, jumpHeight, dir); } //Replace this with pathfinding to the target if (dir.x < 0) { mDirection = EntityDirection.Left; } else { mDirection = EntityDirection.Right; } if (!mAttackManager.meleeAttacks[0].OnCooldown()) { MeleeAttack attack = mAttackManager.meleeAttacks[0]; attack.Activate(); } } else { Renderer.SetAnimState("Idle"); if (Body.mPS.pushesLeft && mDirection == EntityDirection.Left) { mDirection = EntityDirection.Right; } else if (Body.mPS.pushesRight && mDirection == EntityDirection.Right) { mDirection = EntityDirection.Left; } Body.mSpeed.x = GetMovementSpeed() * (int)mDirection; } break; case EnemyState.Jumping: if (Body.mSpeed.y <= 0 && Body.mPS.inWater) { mEnemyState = EnemyState.Moving; break; } if (Body.mPS.pushesBottom) { mEnemyState = EnemyState.Moving; } if (Target != null) { Renderer.SetAnimState("Attack"); if (!mAttackManager.meleeAttacks[0].OnCooldown()) { MeleeAttack attack = mAttackManager.meleeAttacks[0]; attack.Activate(); } } else { Renderer.SetAnimState("Idle"); } break; } base.EntityUpdate(); //HurtBox.mCollisions.Clear(); //UpdatePhysics(); //make sure the hitbox follows the object }