public void DoMove(MoleEnemyController c, GameObject o) { // If is already chargin, continue if (c.isCharging) { EnemyMovements.MoveTowardPlayer(c, o, c.chargeSpeed); } // If is a charge range, chaaaarge!! if (c.IsAtChargeRange() == 0) { c.isCharging = true; //Debug.Log("[CHARGE]: Start charging!!!! (On chargerange = " + c.IsAtChargeRange() + ")"); EnemyMovements.MoveTowardPlayer(c, o, c.chargeSpeed); } // If is to far, move toward player if (c.IsAtChargeRange() == -1) { //Debug.Log("[CHARGE]: To far... (On chargerange = " + c.IsAtChargeRange() + ")"); EnemyMovements.MoveTowardPlayer(c, o, c.walkspeed); } // If is to close, try to go away (And is not already charging) if (c.IsAtChargeRange() == -2) { //Debug.Log("[CHARGE]: To close... (On chargerange = " + c.IsAtChargeRange() + ")"); EnemyMovements.MoveTowardPlayer(c, o, -(c.chargeFleeSpeed)); } }
public void DoMove(MoleEnemyController c, GameObject o) { // Look for player, can see only at specific distance // If player is not in vision, do nothing (Yeah, that's kind of stupid behavior, but time is running low) float distance = Mathf.Abs(o.transform.position.x - c.gameObject.transform.position.x); if (distance > c.seePlayerDistance) { return; // Do nothing XD (He's so stupid) } // Move toward player EnemyMovements.MoveTowardPlayer(c, o, c.walkspeed); if (c.IsAtChargeRange() == 0) { //If reached chargerange c.SetState(MoleStateFactory.creaChargePlayer()); } else if (c.IsAtMeleeRange()) { // If is not at chargerange but at meleerange c.SetState(MoleStateFactory.creaMeleeAttack()); } }
public void DoMove(MoleEnemyController c, GameObject o) { // Is in range, so he fight! if (c.IsAtMeleeRange() == true) { // Chance that he flee the fight to charge again! if (RandomHelper.tossRandom(c.chanceChargeInMelee * Time.deltaTime)) { //Debug.Log("[MELEE] Flee melee to charge again!!!! Yeeaaaah!"); c.SetState(MoleStateFactory.creaChargePlayer()); } } // Try to stay on range, if not, go on range // There is a little chance he try to charge again instead of following else if (c.IsAtMeleeRange() == false) { if (RandomHelper.tossRandom(c.changeChargeOnPlayerFlee * Time.deltaTime)) { //Debug.Log("[MELEE] Player Flee and enemy try to charge again!!"); c.SetState(MoleStateFactory.creaChargePlayer()); } else { //Debug.Log("[MELEE] Try to fight but enemy to far away"); EnemyMovements.MoveTowardPlayer(c, o, c.meleeWalkSpeed); } } }
public void DoMove(MoleEnemyController c, GameObject o) { // negative value because flee the player EnemyMovements.MoveTowardPlayer(c, o, -(c.runAwaySpeed)); }