コード例 #1
0
 /// <summary>
 /// Checks if we hit herbivore during charge
 /// </summary>
 /// <param name="herb"></param>
 private void HitCheck(Character herb)
 {
     if (herb.GetType() == typeof(Herbivore) && charging)
     {
         Herbivore vor = herb as Herbivore;
         Debug.Log("charge");
         if ((momentumTimer / chargeTime) >= 0.4f)
         {
             Debug.Log("Kill herbivore");
             //Kill target
             vor.GetEaten(damage * 2);
             EatHerbivore(0.5f, vor.Health);
         }
         else
         {
             Debug.Log("Hurt herbivore");
             //1 damage
             vor.GetEaten(damage);
         }
         hitTarget = true;
     }
     else if (collided && charging)
     {
         Debug.Log("osu");
         hitTarget = true;
         //Stun for 1.5s
     }
 }
コード例 #2
0
 /// <summary>
 /// Damages the herbivore if player presses the eat button
 /// </summary>
 /// <param name="col"></param>
 private void Eat(Character col)
 {
     if (InputManager.Instance.GetButton("Eat"))
     {
         Herbivore vor = col as Herbivore;
         Debug.Log("mums, mums....");
         EatHerbivore(slowDown, vor.Health);
         vor.GetEaten(damage);
     }
 }
コード例 #3
0
ファイル: Terrain.cs プロジェクト: mmaxner/SGDA_SETEarth
    public float EatAnimal()
    {
        if (grazers.Count == 0)
        {
            return(0.0f);
        }

        int       index = Random.Range(0, grazers.Count);
        Herbivore meal  = grazers[index];
        float     meat  = meal.GetEaten();

        grazers.RemoveAt(index);
        return(meat);
    }