Ejemplo n.º 1
0
 protected override void Start()
 {
     actionComponent = GetComponent <ActionComponent>();
     unitInfo        = GetComponent <UnitInfo>();
     movement        = GetComponent <CharacterMovement>();
     ik = unitInfo.GetComponent <GenericIK>();
     unitInfo.AddDamageEvent(delegate(UnitInfo _causer, float _damage)
     {
         if (unitInfo.GetHP() <= 0)
         {
             SetState(AIState.die);
             return;
         }
         float[] roarHPs = { 75, 50, 25 };
         for (int i = 0; i < roarHPs.Length; i++)
         {
             if (unitInfo.GetLastHP() > roarHPs[i] && unitInfo.GetHP() <= roarHPs[i])
             {
                 if (unitInfo.GetCondition() >= ConditionData.UnitCondition.stuned)
                 {
                     unitInfo.GetComponent <ActionComponent>().UseSkill("WakeUp", true);
                 }
                 readyType = ActionReadyType.Roar;
                 unitInfo.RemoveCrowdControlAll();
             }
         }
     }
                             );
     unitInfo.AddStateChangeEvent(delegate(UnitInfo.UnitState _new, UnitInfo.UnitState _old)
     {
     }
                                  );
     weaknessPointObject.AddEvent(
         delegate(Transform caller)
     {
         Debug.Log(caller);
         StartCoroutine(DisappearWeakness());
         unitInfo.AddCrowdControl(ConditionData.UnitCondition.stuned, 5,
                                  delegate()
         {
             unitInfo.GetComponent <ActionComponent>().UseSkill("WakeUp", true);
             StartCoroutine(AppearWeakness(UnityEngine.Random.Range(0, weaknessPoints.Count)));
         }
                                  );
         actionComponent.StopAction();
         movement.Stop();
         movement.StopRotating();
     }
         );
     actionTarget = new GameObject(transform.name + " Action Target").transform;
     StartCoroutine(AppearWeakness(UnityEngine.Random.Range(0, weaknessPoints.Count)));
     base.Start();
     //actionTarget = pivot;
 }
Ejemplo n.º 2
0
    void UpdateHP()
    {
        UnitInfo currentUnit = ControlManager.Instance.GetCurrentUnit();

        if (currentUnit == null)
        {
            return;
        }
        if (hpBar)
        {
            hpBar.fillAmount = Mathf.Lerp(hpBar.fillAmount, currentUnit.GetHP() / currentUnit.GetMaxHP(), Time.deltaTime * 2);
        }
    }