Esempio n. 1
0
    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);
            }
        }
    }
Esempio n. 2
0
    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());
        }
    }
Esempio n. 3
0
 public void StopRunningAway()
 {
     // This function is a for state behavior. It's actually a design issue and should be handled in RunAway state
     // However, for simplicity for this game jam, I put it here for now
     this.SetState(MoleStateFactory.creaChargePlayer());
 }