Esempio n. 1
0
 public override void Run(System.Object context)
 {
     // verify if context doesn't match requirements of this animation
     if (!DoesContextMatch(context))
     {
         // context is not in scope of this animation
         // don't run
         return;
     }
     // verify if context matches battle context
     if (context is BattleContext)
     {
         // get destination unit party unit UI
         PartyUnitUI activePartyUnitUI = BattleContext.ActivePartyUnitUI;
         // verify if there is a party unit UI
         if (activePartyUnitUI != null)
         {
             Debug.Log("Run Heal Animation on active unit");
             // run text animation
             sourceUnitTextAnimation.Run(activePartyUnitUI.UnitInfoPanelText);
         }
         // get destination unit party unit UI
         PartyUnitUI destinationPartyUnitUI = BattleContext.DestinationUnitSlot.GetComponentInChildren <PartyUnitUI>();
         // verify if there is a party unit UI
         if (destinationPartyUnitUI != null)
         {
             Debug.Log("Run Damage Animation on destination unit");
             // run text animation
             destinationUnitTextAnimation.Run(destinationPartyUnitUI.UnitInfoPanelText);
         }
     }
 }
Esempio n. 2
0
    //public void DeactivateExpiredBuffs()
    //{
    //    // Deactivate expired buffs in UI
    //    // PartyUnit unit = GetComponent<PartyUnit>();
    //    UnitBuffIndicator[] buffsUI = GetUnitBuffsPanel().GetComponentsInChildren<UnitBuffIndicator>();
    //    foreach (UnitBuffIndicator buffUI in buffsUI)
    //    {
    //        // First decrement buff current duration
    //        buffUI.DecrementCurrentDuration();
    //        // Verify if it has timed out;
    //        if (buffUI.GetCurrentDuration() == 0)
    //        {
    //            // buff has timed out
    //            // deactivate it (it will be destroyed at the end of animation)
    //            buffUI.SetActiveAdvance(false);
    //            // deactivate it in unit properties too
    //            LPartyUnit.UnitBuffs[(int)buffUI.GetUnitBuff()] = UnitBuff.None;
    //        }
    //    }
    //}

    public void TriggerAppliedUniquePowerModifiers()
    {
        //Debug.Log("TriggerAppliedDebuffs");
        //UnitDebuffIndicator[] debuffsIndicators = GetUnitDebuffsPanel().GetComponentsInChildren<UnitDebuffIndicator>();
        ////UnitDebuffsUI unitDebuffsUI = unit.GetUnitDebuffsPanel().GetComponent<UnitDebuffsUI>();
        //foreach (UnitDebuffIndicator debuffIndicator in debuffsIndicators)
        //{
        //    Debug.Log(name);
        //    // as long as we cannot initiate all debuffs at the same time
        //    // we add debuffs to the queue and they will be triggered one after another
        //    // CoroutineQueue queue = unitDebuffsUI.GetQueue();
        //    // CoroutineQueue queue = transform.root.GetComponentInChildren<UIManager>().GetComponentInChildren<BattleScreen>(true).Queue;
        //    //if (queue == null)
        //    //{
        //    //    Debug.LogError("No queue");
        //    //}
        //    //if (debuffIndicator == null)
        //    //{
        //    //    Debug.LogError("No debuffIndicator");
        //    //}
        //    IEnumerator coroutine = debuffIndicator.TriggerDebuff(this);
        //    //if (coroutine == null)
        //    //{
        //    //    Debug.LogError("No coroutine");
        //    //}
        //    CoroutineQueueManager.Run(coroutine);
        //    // Trigger debuff against player
        //    // Decrement buff current duration
        //    debuffIndicator.DecrementCurrentDuration();
        //}
        // Loop through all UPMs on this party unit in backwards order (so we can remove items in a loop)
        for (int i = LPartyUnit.AppliedUniquePowerModifiersData.Count - 1; i >= 0; i--)
        {
            // get UPM config
            UniquePowerModifierConfig uniquePowerModifierConfig = LPartyUnit.AppliedUniquePowerModifiersData[i].GetUniquePowerModifierConfig();
            // verify if trigger condition matches
            if (uniquePowerModifierConfig.TriggerCondition == TriggerCondition.AtTurnStart)
            {
                // Gget UPM text animation config upfront, because UPMdata may be removed if unit is dead after Trigger
                TextAnimation upmTextAnimation = uniquePowerModifierConfig.UniquePowerModifierStausIconUIConfig.onTriggerTextAnimation;
                // Trigger UPM
                LPartyUnit.AppliedUniquePowerModifiersData[i].GetUniquePowerModifierConfig().Trigger(LPartyUnit, LPartyUnit.AppliedUniquePowerModifiersData[i]);
                // trigger animation to display damage done
                upmTextAnimation.Run(UnitInfoPanelText);
                // verify if unit is still alive
                if (LPartyUnit.UnitStatus != UnitStatus.Dead)
                {
                    // verify if UPM duration left is 0
                    if (LPartyUnit.AppliedUniquePowerModifiersData[i].DurationLeft == 0)
                    {
                        // UPM has expired
                        // trigger UPM removed event
                        //LPartyUnit.UnitEvents.uniquePowerModifierHasBeenRemovedEvent.Raise(LPartyUnit.UniquePowerModifiersData[i]);
                        LPartyUnit.AppliedUniquePowerModifiersData[i].GetUniquePowerModifierConfig().UniquePowerModifier.Events.DataHasBeenRemovedEvent.Raise(LPartyUnit.AppliedUniquePowerModifiersData[i]);
                        // remove it from the list
                        LPartyUnit.AppliedUniquePowerModifiersData.RemoveAt(i);
                    }
                }
                else
                {
                    // all UPMs data already should be removed in party unit UnitHealthCurr property
                    // exit this loop
                    break;
                }
            }
        }
    }