public string GetAnimationName(CombatantAnimation type)
 {
     string name = "";
     if(CombatantAnimation.IDLE.Equals(type)) name = this.idle.name;
     else if(CombatantAnimation.WALK.Equals(type)) name = this.walk.name;
     else if(CombatantAnimation.RUN.Equals(type)) name = this.run.name;
     else if(CombatantAnimation.SPRINT.Equals(type)) name = this.sprint.name;
     else if(CombatantAnimation.JUMP.Equals(type)) name = this.jump.name;
     else if(CombatantAnimation.FALL.Equals(type)) name = this.fall.name;
     else if(CombatantAnimation.LAND.Equals(type)) name = this.land.name;
     else if(CombatantAnimation.ATTACK.Equals(type)) name = this.attack.name;
     else if(CombatantAnimation.DEFEND.Equals(type)) name = this.defend.name;
     else if(CombatantAnimation.ITEM.Equals(type)) name = this.item.name;
     else if(CombatantAnimation.SKILL.Equals(type)) name = this.skill.name;
     else if(CombatantAnimation.DAMAGE.Equals(type)) name = this.damage.name;
     else if(CombatantAnimation.EVADE.Equals(type)) name = this.evade.name;
     else if(CombatantAnimation.DEATH.Equals(type)) name = this.death.name;
     else if(CombatantAnimation.REVIVE.Equals(type)) name = this.revive.name;
     return name;
 }
Esempio n. 2
0
    public CombatantAnimation[] Calculate(Combatant[] ts, float damageFactor)
    {
        if(DataHolder.BattleCam().blockAnimationCams)
        {
            if(ts.Length == 1 && ts[0].prefabInstance != null)
            {
                DataHolder.BattleCam().SetLatestDamage(ts[0].prefabInstance.transform);
            }
            else if(ts.Length > 1)
            {
                DataHolder.BattleCam().SetLatestDamage(
                            DataHolder.BattleSystem().GetGroupCenter(ts).transform);
            }
        }

        CombatantAnimation[] anims = new CombatantAnimation[ts.Length];
        doCounter = new bool[ts.Length];
        if(user != null && ts.Length > 0 && ts[0] != null &&
            ((!user.isDead && !this.IsDeath()) || this.IsDeath()))
        {
            if((this.IsAttack() || this.IsCounter()) && !user.IsBlockAttack())
            {
                bool hit = false;
                if(this.IsAttack())
                {
                    hit = user.UseBaseAttack(ts[0], this, true, damageFactor, this.damageMultiplier);
                }
                else if(this.IsCounter())
                {
                    hit = user.UseBaseAttack(ts[0], this, false, damageFactor, this.damageMultiplier);
                }
                if(hit)
                {
                    anims[0] = CombatantAnimation.DAMAGE;
                    ts[0].CheckEffectsAttack();
                }
                else
                {
                    anims[0] = CombatantAnimation.EVADE;
                }
            }
            else if(this.IsSkill() && !user.IsBlockSkills() && DataHolder.Skill(this.useID).CanUse(user, this.useLevel))
            {
                // check for reflect
                if(ts != null && ts.Length > 0 &&
                    DataHolder.Skill(this.useID).level[this.useLevel].reflectable)
                {
                    for(int i=0; i<ts.Length; i++)
                    {
                        if(ts[i].HasReflect())
                        {
                            ts[i] = user;
                        }
                    }
                }
                anims = DataHolder.Skill(this.useID).Use(user, ts, this, !this.userConsumeDone,
                        this.useLevel, damageFactor, this.damageMultiplier);
                this.userConsumeDone = true;
            }
            else if(this.IsItem() && !user.IsBlockItems())
            {
                anims = DataHolder.Item(this.useID).Use(user, ts, this, this.useID, damageFactor, this.damageMultiplier);
            }
            else if(this.IsDefend() && !user.IsBlockDefend())
            {
                user.isDefending = true;
            }
            else if(this.IsEscape() && !user.IsBlockEscape())
            {
                for(int i=0; i<ts.Length; i++)
                {
                    if(DataHolder.GameSettings().GetRandom() <=
                            (DataHolder.Formula(DataHolder.BattleSystem().escapeFormula).
                                Calculate(user, ts[i]) + user.GetEscapeBonus()))
                    {
                        user.Escape();
                    }
                }
            }
            else if(this.IsDeath())
            {
                anims[0] = CombatantAnimation.DEATH;
            }
        }
        return anims;
    }
Esempio n. 3
0
 /*
 ============================================================================
 Animation functions
 ============================================================================
 */
 public override string GetAnimationName(CombatantAnimation type)
 {
     string name = base.GetAnimationName(type);
     for(int i=0; i<this.equipment.Length; i++)
     {
         if(this.equipment[i].IsWeapon())
         {
             Weapon wpn = DataHolder.Weapon(this.equipment[i].equipID);
             if(wpn.ownBaseAnimations)
             {
                 name = wpn.battleAnimations.GetAnimationName(type);
                 break;
             }
         }
     }
     return name;
 }
Esempio n. 4
0
    /*
    ============================================================================
    Use functions
    ============================================================================
    */
    public CombatantAnimation[] Use(Combatant user, Combatant[] target, BattleAction ba, int id, float damageFactor, float damageMultiplier)
    {
        AudioClip clip = null;
        if(this.audioName != "")
        {
            clip = (AudioClip)Resources.Load(ItemData.AUDIO_PATH+this.audioName, typeof(AudioClip));
        }

        CombatantAnimation[] anims = new CombatantAnimation[target.Length];
        // global event
        if(this.callGlobalEvent)
        {
            GameHandler.GetLevelHandler().CallGlobalEvent(this.globalEventID);
        }
        // use item
        else
        {
            for(int j=0; j<target.Length; j++)
            {
                if(clip != null && target[j].prefabInstance != null)
                {
                    AudioSource s = target[j].prefabInstance.GetComponentInChildren<AudioSource>();
                    if(s == null) s = target[j].prefabInstance.AddComponent<AudioSource>();
                    if(s != null)
                    {
                        s.PlayOneShot(clip);
                    }
                }

                anims[j] = CombatantAnimation.NONE;
                for(int i=0; i<this.valueChange.Length; i++)
                {
                    if(!target[j].isDead || (target[j].isDead && this.revive && !target[j].noRevive))
                    {
                        if(this.revive && target[j].isDead && !target[j].noRevive)
                        {
                            target[j].isDead = false;
                            anims[j] = CombatantAnimation.REVIVE;
                        }
                        if(this.valueChange[i].active)
                        {
                            int oldVal = target[j].status[i].GetValue();
                            int change = this.valueChange[i].ChangeValue(i, -1, user, target[j], true, damageFactor, damageMultiplier);
                            if(!(this.revive && target[j].isDead && !target[j].noRevive) && ((this.valueChange[i].IsSub() && change > 0) ||
                                (this.valueChange[i].IsAdd() && change < 0) ||
                                (this.valueChange[i].IsSet() && change < oldVal)))
                            {
                                anims[j] = CombatantAnimation.DAMAGE;
                            }
                        }
                    }
                }
            }
            if(ItemSkillType.USE.Equals(this.itemSkill))
            {
                anims = DataHolder.Skill(this.skillID).Use(user, target, ba, false, this.skillLevel-1, damageFactor, damageMultiplier);
            }
            else if(ItemSkillType.LEARN.Equals(this.itemSkill))
            {
                for(int j=0; j<target.Length; j++)
                {
                    if(target[j] is Character)
                    {
                        Character t = (Character)target[j];
                        t.LearnSkill(this.skillID, this.skillLevel);
                    }
                }
            }
            if(ItemVariableType.SET.Equals(this.itemVariable))
            {
                GameHandler.SetVariable(this.variableKey, this.variableValue);
            }
            else if(ItemVariableType.REMOVE.Equals(this.itemVariable))
            {
                GameHandler.RemoveVariable(this.variableKey);
            }
            for(int j=0; j<target.Length; j++)
            {
                this.ApplyEffects(user, target[j]);
            }
        }
        // consume
        if(user is Character)
        {
            DataHolder.Statistic.ItemUsed(id);
            if(this.learnRecipe) GameHandler.LearnRecipe(this.recipeID);
            if(this.consume) GameHandler.RemoveItem(id);
        }
        return anims;
    }