示例#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);
            }
        }
    }
示例#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());
        }
    }
示例#3
0
    // ------------------------------------------------------------------------
    // Functions - Unity
    // ------------------------------------------------------------------------

    // Use this for initialization
    public void Start()
    {
        this.player        = GameObject.FindGameObjectWithTag("player2");
        this.state         = MoleStateFactory.creaLook4Player();
        this.attackType    = new MeleeHandAttackType(this);
        this.currentHealth = this.healthStart;
        this.isAlive       = true;
        this.isBlocking    = false;
        this.isRunningAway = false;
    }
示例#4
0
 // ------------------------------------------------------------------------
 // Override functions - StateBehavior
 // ------------------------------------------------------------------------
 public void DoAttack(MoleEnemyController c, GameObject o)
 {
     // Is is charging and reached the melee range, give a freaking motherf*****g big hit in your face
     if (c.IsAtMeleeRange() && c.isCharging)
     {
         //Debug.Log("[CHARGE]: charge just reached it's destination: poor player...");
         c.attack(); // Take that ugly player!
         c.SetState(MoleStateFactory.creaMeleeAttack());
     }
     // Else, is in range but must load it's charge (Move do the job)
 }
示例#5
0
 /**
  * Call a friend for help
  * Check on all GameObject with the specific tag for friends
  *
  * return true if one friend found, otherwise, return false
  */
 public bool CallForHelp()
 {
     // This function will ask one friend currently fighting to block player (Change state to block)
     GameObject[] friends = GameObject.FindGameObjectsWithTag("enemy");
     foreach (GameObject o in friends)
     {
         MoleEnemyController friend = o.GetComponent <MoleEnemyController>();
         if (friend.isFighting == true)
         {
             friend.SetState(MoleStateFactory.creaBlockAttack());
             return(true);
         }
     }
     return(false);
 }
示例#6
0
    public float hitByTarget(AttackActor actor, float damages)
    {
        Debug.Log("[HIT] Enemy receives damage (damage: " + damages + ")");
        //TODO receive damage

        this.currentHealth = this.currentHealth - damages;
        this.currentHealth = this.currentHealth >= 0 ? this.currentHealth : 0;
        if (currentHealth <= 0)
        {
            this.isAlive = false;
        }
        Debug.Log("[HIT] Enemy hit player (Damage: " + damages + ", health: " + this.currentHealth + ")");
        if (this.IsLowLife())
        {
            this.SetState(MoleStateFactory.creaRunAway());
        }
        if (this.IsAlive() == false)
        {
            Debug.Log("[DEAD] Enemy just die");
            Destroy(this.gameObject, this.timeBeforeDeadRemoved);
        }
        //TODO Add anims
        return(damages);
    }
示例#7
0
 public void StopBlocking()
 {
     // Same remarks as "StopRunningAway" -> this is a design issue
     this.SetState(MoleStateFactory.creaMeleeAttack());
 }
示例#8
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());
 }