public static void Assassinate(TroopScript Assassin, TroopScript Victim)
 {
     int AssassinChance = Mathf.RoundToInt(((float)Assassin.GetEnergy()/(float)Assassin.GetMaxEnergy())*900+((float)Assassin.GetNumber()/(float)Assassin.GetmaxNumber())*100);
     int VictimChance = Mathf.RoundToInt(((float)Victim.GetEnergy()/(float)Victim.GetMaxEnergy())*100+((float)Victim.GetNumber()/(float)Victim.GetmaxNumber())*900);
     if (AssassinChance>VictimChance && Victim.boss == false)
         Victim.SetNumber(0);
 }
Beispiel #2
0
 public void SummonTrashEffect(TroopScript Caster,Tile TargetTile)
 {
     muhSkills thisSkill = muhSkills.SummonTrash;
     TroopScript Target = null;
     for (int i = 0;i<GameManager.instance.players.Count;i++)
     if (GameManager.instance.players[i].gridPosition == TargetTile.gridPosition){
         Target = GameManager.instance.players[i];
         NewFightScript.SummonYogurtOntoPlayer(Target,Caster);
     }
     if (Target == null)
         GameManager.instance.SummonYogurt (TargetTile.gridPosition,Caster);
     Caster.SetEnergy(Caster.GetEnergy()-Skill.FromListOfSkills(thisSkill).EnergyCost);
     if (Skill.FromListOfSkills(thisSkill).DepleteEnergy == true)
         Caster.SetEnergy(0);
     SwitchThis = muhSkills.NoSkill;
     Caster.SkillRecoveryTime = Skill.FromListOfSkills(thisSkill).SkillRecoveryTime;
     Caster.actionPoints--;
 }
    public static void MeleeFightingScript(TroopScript Attacker, TroopScript Defender, Skill SkillUsed)
    {
        int AttackerBattlefieldEffect = 1; //still to impement
        int DefenderBattlefieldEffect = 1; //still to impement
        int DamageOnAtk = 0;
        int DamageOnDef = 0;
        TroopScript DefenderGuarder = Defender.GuardedBy;
        float 	DefenderGuardPercent = (float)Defender.GuardedByPercent/100;
        if (SkillUsed.CancelsPreparation == true && Defender.isMagicGuarded == false){
            Defender.CancelPreparation();
            Defender.FlushPreparationTarget();
        }
        if (SkillUsed.ReducesEnergy == true && Defender.isMagicGuarded == false){
            Defender.SetEnergy(Defender.GetEnergy()-1);
            if (Defender.GetEnergy() <0)
                Defender.SetEnergy(0);
        }
        if (SkillUsed.RemoveBuffs == true && Defender.isMagicGuarded == false)Defender.RemoveAllbuffs();
        if (SkillUsed.AppliesPoison == true && Defender.Poisoned == 0) Defender.Poisoned = 1;
        if (SkillUsed.Freezes == true && !Defender.Frozen) Defender.Frozen = true;
        if (SkillUsed.Penetrating == true || DefenderGuarder == null){
        DamageOnDef = CalculateDamage(Attacker,Defender,SkillUsed,AttackerBattlefieldEffect);
            Debug.Log("Damage on "+Defender.GetChief().GetName()+":"+DamageOnDef);
            Defender.SetNumber(Defender.GetNumber()-DamageOnDef);
            if (Defender.GetNumber()<0) Defender.SetNumber(0);
        if (CanCounter(Attacker,Defender,SkillUsed)){

        float CounterScaling = CounterAttackDamage(Defender.GetChief().GetCounterAttack(),Defender.GetArmor().CounterAttackValue+Defender.GetWeapon().CounterAttackValue);
            DamageOnAtk = CalculateCounterDamage(Defender,Attacker,CounterScaling,DefenderBattlefieldEffect);
            Attacker.SetNumber(Attacker.GetNumber()-DamageOnAtk);
                if (Attacker.GetNumber()<0) Attacker.SetNumber(0);}}

        else if (SkillUsed.Penetrating == false && DefenderGuarder != null){

            DamageOnDef = CalculateDamage(Attacker,Defender,SkillUsed,AttackerBattlefieldEffect);
            if (SkillUsed.AffectRating) RatingFromDamage(Attacker,DamageOnDef);
            if (DefenderGuarder){
                if (DefenderGuarder.GetNumber()<= 0){
                    Defender.GuardedBy = null;
                    Defender.GuardedByPercent = 0;
                    DamageOnDef = CalculateDamage(Attacker,Defender,SkillUsed,AttackerBattlefieldEffect);
                    Debug.Log("Damage on "+Defender.GetChief().GetName()+":"+DamageOnDef);
                    Defender.SetNumber(Defender.GetNumber()-DamageOnDef);
                    if (Defender.GetNumber()<0) Defender.SetNumber(0);
                    if (CanCounter(Attacker,Defender,SkillUsed)){

                        float CounterScaling = CounterAttackDamage(Defender.GetChief().GetCounterAttack(),Defender.GetArmor().CounterAttackValue+Defender.GetWeapon().CounterAttackValue);
                        DamageOnAtk = CalculateCounterDamage(Defender,Attacker,CounterScaling,DefenderBattlefieldEffect);
                        Attacker.SetNumber(Attacker.GetNumber()-DamageOnAtk);
                        if (Attacker.GetNumber()<0) Attacker.SetNumber(0);}
                }else{
                DefenderGuarder.SetNumber(DefenderGuarder.GetNumber()-Mathf.RoundToInt(DamageOnDef*DefenderGuardPercent));
                if (DefenderGuarder.GetNumber()<0) DefenderGuarder.SetNumber(0);
                Defender.SetNumber(Defender.GetNumber()-Mathf.RoundToInt(DamageOnDef*(1-DefenderGuardPercent)));
                if (Defender.GetNumber()<0) Defender.SetNumber(0);
                if (CanCounter(Attacker,DefenderGuarder,SkillUsed)){
                    float CounterScaling = CounterAttackDamage(DefenderGuarder.GetChief().GetCounterAttack(),DefenderGuarder.GetArmor().CounterAttackValue+DefenderGuarder.GetWeapon().CounterAttackValue);
                    DamageOnAtk = CalculateCounterDamage(DefenderGuarder,Attacker,CounterScaling,DefenderBattlefieldEffect);
                    Attacker.SetNumber(Attacker.GetNumber()-DamageOnAtk);
                    if (Attacker.GetNumber()<0) Attacker.SetNumber(0);
            }
                }}
        }
    }
 public static void ConvertAction(TroopScript Caster,TroopScript Target, Skill SkillUsed)
 {
     int Value = SkillUsed.EnergyCost;
     if (Caster.GetEnergy()>=Value){
         Caster.SetEnergy(Caster.GetEnergy()-Value);
         Target.SetEnergy(Target.GetEnergy()+Value);
     if (Target.GetEnergy() > Target.GetMaxEnergy())
             Target.SetEnergy(Target.GetMaxEnergy());}
 }