예제 #1
0
    void OnNextTurn()
    {
        countTillNextTurn -= 1;
        if (countTillNextTurn == 0)
        {
            turn -= 1;

            if (turn == 0)
            {
                GameControlTB.onNextTurnE -= OnNextTurn;
                UnitTB.onUnitDestroyedE   -= OnUnitDestroyed;
                delay = 0;
                DelayDestruct();
            }
            else
            {
                if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
                {
                    countTillNextTurn = UnitControl.activeFactionCount;
                }
                else
                {
                    countTillNextTurn = UnitControl.GetAllUnitCount();
                }
            }
        }
    }
예제 #2
0
 void OnEnable()
 {
     if (mode == _DelayMode.RealTime)
     {
         DelayDestruct();
     }
     else if (mode == _DelayMode.Round)
     {
         GameControlTB.onNewRoundE += OnNewRound;
     }
     else if (mode == _DelayMode.Turn)
     {
         GameControlTB.onNextTurnE += OnNextTurn;
         UnitTB.onUnitDestroyedE   += OnUnitDestroyed;
         if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
         {
             countTillNextTurn = UnitControl.activeFactionCount;
         }
         else
         {
             countTillNextTurn = UnitControl.GetAllUnitCount();
         }
     }
 }
예제 #3
0
    //apply a unit ability to the tile
    public void ApplyAbility(UnitAbility ability)
    {
        //spawn effect if any
        if (ability.effectTarget != null)
        {
            StartCoroutine(SpawnAbilityEffect(ability.effectTarget, ability.effectTargetDelay, pos));
        }

        //loop through the effect list and change the modifier
        //commented effect are disabled for tile
        foreach (EffectAttr effectAttr in ability.effectAttrs)
        {
            if (effectAttr.type == _EffectAttrType.HPDamage)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                HPGainModifier  -= (int)effectAttr.value;
                if (unit != null)
                {
                    unit.ApplyDamage((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.HPGain)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                HPGainModifier  += (int)effectAttr.value;
                if (unit != null)
                {
                    unit.ApplyHeal((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.APDamage)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                APGainModifier  += (int)effectAttr.value;
                if (unit != null)
                {
                    unit.GainAP(-(int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.APGain)
            {
                effectAttr.value = Random.Range(effectAttr.value, effectAttr.valueAlt);
                APGainModifier  -= (int)effectAttr.value;
                if (unit != null)
                {
                    unit.GainAP((int)effectAttr.value);
                }
            }
            else if (effectAttr.type == _EffectAttrType.Damage)
            {
                damageModifier += (int)effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.MovementRange){
            //~ movementModifier+=(int)effectAttr.value;
            //~ }
            else if (effectAttr.type == _EffectAttrType.AttackRange)
            {
                attRangeModifier += (int)effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.Speed){
            //~ speedModifier+=(int)effectAttr.value;
            //~ }
            else if (effectAttr.type == _EffectAttrType.HitChance)
            {
                attackModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.DodgeChance)
            {
                defendModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.CriticalChance)
            {
                criticalModifier += effectAttr.value;
            }
            else if (effectAttr.type == _EffectAttrType.CriticalImmunity)
            {
                critDefModifier += effectAttr.value;
            }
            //~ else if(effectAttr.type==_EffectAttrType.ExtraAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.ExtraCounterAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.Stun){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableAttack){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableMovement){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.DisableAbility){

            //~ }
            //~ else if(effectAttr.type==_EffectAttrType.Teleport){

            //~ }
        }

        if (activeUnitAbilityEffectList.Count == 0)
        {
            SubscribeEvent();
            if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
            {
                countTillNextTurn = UnitControl.activeFactionCount;
            }
            else
            {
                countTillNextTurn = UnitControl.GetAllUnitCount();
            }
        }

        if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
        {
            ability.countTillNextTurn = UnitControl.activeFactionCount;
        }
        else
        {
            ability.countTillNextTurn = UnitControl.GetAllUnitCount();
        }

        //add the ability to the list so it can be keep tracked
        activeUnitAbilityEffectList.Add(ability);
    }
예제 #4
0
    void OnNextTurn()
    {
        for (int i = 0; i < activeUnitAbilityEffectList.Count; i++)
        {
            UnitAbility uAB = activeUnitAbilityEffectList[i];
            uAB.countTillNextTurn -= 1;
            if (uAB.countTillNextTurn == 0)
            {
                if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
                {
                    uAB.countTillNextTurn = UnitControl.activeFactionCount;
                }
                else
                {
                    uAB.countTillNextTurn = UnitControl.GetAllUnitCount();
                }

                bool flag = CalulateEffect(uAB);

                //false means no more effect active for the ability, remove the ability
                if (!flag)
                {
                    activeUnitAbilityEffectList.RemoveAt(i);
                    i -= 1;

                    //if not more ability, stop listening to any event
                    if (activeUnitAbilityEffectList.Count == 0)
                    {
                        UnsubscribeEvent();
                    }
                }
            }
        }

        //apply the effect, this is placed here so it only runs when there are active effect
        countTillNextTurn -= 1;
        if (countTillNextTurn == 0)
        {
            //apply the effect on unit
            if (unit != null)
            {
                if (HPGainModifier > 0)
                {
                    unit.ApplyHeal(HPGainModifier);
                }
                else if (HPGainModifier < 0)
                {
                    unit.ApplyDamage(HPGainModifier);
                }
                if (APGainModifier != 0)
                {
                    unit.GainAP(APGainModifier);
                }
            }

            if (GameControlTB.GetTurnMode() == _TurnMode.FactionAllUnitPerTurn)
            {
                countTillNextTurn = UnitControl.activeFactionCount;
            }
            else
            {
                countTillNextTurn = UnitControl.GetAllUnitCount();
            }
        }
    }