Exemple #1
0
    int     CalcDamage(sdActorInterface monster)
    {
        bool shakeCamera = ((int)info["shakeCamera"] == 1);

        if (shakeCamera)
        {
            float shakelevel = ((int)info["ShakeLevel"]) * 0.0001f;
            sdGameLevel.instance.mainCamera.addRandomCameraShake(0.3f, 0.3f * shakelevel, 60.0f, 3.0f);
        }
        //鎾?斁鍛戒腑涔嬪悗鐨勭垎鐐哥壒鏁囘濡傛灉瀛樺湪鐖嗙偢鐗规晥 鍒欓渶瑕佺敤summon涓?寖鍥撮噸鏂拌?绠椾激瀹冲垽瀹欗
        object ExplosionEffect = info["ExplosionEffect"];

        if (ExplosionEffect != null)
        {
            string strExplosion = ExplosionEffect as string;
            if (strExplosion.Length > 0)
            {
                if (bPlayExplosion)
                {
                    int   ExplosionEffectLife = (int)info["ExplosionEffectLife"];
                    float flife = (float)ExplosionEffectLife * 0.001f;
                    sdActorInterface.AddHitEffect(strExplosion, null, flife, transform.position, true);
                }

                return(sdGameLevel.instance.battleSystem.DoSDAttack(
                           castActor,
                           info,
                           transform.position,
                           0,
                           cb));
            }
        }
        HeaderProto.ESkillEffect eSkilleffect = HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_HP;
        if (info.ContainsKey("bySkillEffect"))
        {
            eSkilleffect = (HeaderProto.ESkillEffect)(info["bySkillEffect"]);
        }
        List <sdActorInterface> lstMonster = new List <sdActorInterface>();

        lstMonster.Add(monster);
        return(OnHit(lstMonster, eSkilleffect));
    }
Exemple #2
0
    public DamageResult testHurt(sdActorInterface _gameActor, Hashtable _state, sdActorInterface targetActor, int hitPointIndex, HeaderProto.ESkillEffect bySkillEffect)
    {
        DamageResult dr;

        dr.damage     = 0;
        dr.bubbleType = Bubble.BubbleType.eBT_BaseHurt;
        dr.attracker  = _gameActor;

        Hashtable recProp = targetActor.GetProperty();

        if (recProp == null)
        {
            return(dr);
        }
        SkillProperty skillProp = new SkillProperty();

        int   dmgMin            = (int)_gameActor["AtkDmgMin"];
        int   dmgMax            = (int)_gameActor["AtkDmgMax"];
        int   iceAtt            = (int)_gameActor["IceAtt"];
        int   fireAtt           = (int)_gameActor["FireAtt"];
        int   poisonAtt         = (int)_gameActor["PoisonAtt"];
        int   thunerAtt         = (int)_gameActor["ThunderAtt"];
        int   intervalPerAttack = (int)_gameActor["AttSpeed"];       // ms per attack
        float attackPerSecond   = 1000.0f / (float)intervalPerAttack;
        int   d10000            = ((int[])_state["dwAtkPowerPer[10]"])[hitPointIndex];
        int   dx = ((int[])_state["dwDmg[10]"])[hitPointIndex];
        int   byPeriodicDamageType = 0;                   //(int)_state.stateData["byPeriodicDamage"];

        Hashtable attTable = new Hashtable();
        int       phyAtt   = dmgMin;

        //如果最小攻击力 大于 最大攻击力 直接取最小攻击力...
        if (dmgMax > dmgMin)
        {
            phyAtt = Random.Range(dmgMin, dmgMax);
        }

        float iPercentFix = 0.0f;
        int   iDamageFix  = 0;

        switch ((EPeriodicDamage)byPeriodicDamageType)
        {
        ///每波伤害相同...
        case    EPeriodicDamage.PERIODIC_DAMAGE_SAME: {} break;

        ///固定值递增:Data + DataPeriodic * (Index)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_INCREASE: {
            iDamageFix = (int)_state["dwPeriodicTraumaHP"] * (hitPointIndex + 1);
        } break;

        ///百分比递增:HP*(Data + DataPeriodic * (Index))...
        case        EPeriodicDamage.PERIODIC_DAMAGE_INCREASE_PERCENT: {
            iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f) * (hitPointIndex + 1);
        } break;

        ///固定值递减:Data - DataPeriodic * (Index)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_DECREASE: {
            iDamageFix = -(int)_state["dwPeriodicTraumaHP"] * (hitPointIndex + 1);
        } break;

        ///百分比递减:HP*(Data - DataPeriodic * (Index))...
        case    EPeriodicDamage.PERIODIC_DAMAGE_DECREASE_PERCENT: {
            iPercentFix = -((int)_state["dwPeriodicTraumaHP"] / 10000.0f) * (hitPointIndex + 1);
        } break;

        ///第一波伤害最大,其余伤害相同,第一波伤害计算公式:...
        ///固定值方式:Data - DataPeriodic...
        case    EPeriodicDamage.PERIODIC_DAMAGE_FIRST: {
            if (hitPointIndex == 0)
            {
                iDamageFix = (int)_state["dwPeriodicTraumaHP"];
            }
        } break;

        ///百分比方式:HP*(Data + DataPeriodic)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_FIRST_PERCENT: {
            if (hitPointIndex == 0)
            {
                iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f);
            }
        } break;

        ///最后一波伤害最大,其余伤害相同,第一波伤害计算公式:
        ///固定值方式:Data + DataPeriodic
        case        EPeriodicDamage.PERIODIC_DAMAGE_END: {
            if (hitPointIndex == -1)
            {
                iPercentFix = (int)_state["dwPeriodicTraumaHP"];
            }
        } break;

        ///百分比方式:HP*(Data + DataPeriodic)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_END_PERCENT: {
            if (hitPointIndex == -1)
            {
                iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f);
            }
        } break;
        }
        int skillHit    = (int)_state["dwHitPer"];
        int skillCri    = (int)_state["dwCriticalPer"];
        int skillCriDmg = (int)_state["dwCriticalDmgPer"];

        skillProp.atk        = phyAtt;
        skillProp.iceAtk     = iceAtt;
        skillProp.fireAtk    = fireAtt;
        skillProp.poisonAtk  = poisonAtt;
        skillProp.thunderAtk = thunerAtt;
        skillProp.Y          = (float)d10000 / 10000.0f;
        skillProp.Z          = dx;
        skillProp.YZFix      = iPercentFix;
        skillProp.ZFix       = iDamageFix;
        skillProp.hitRate    = (float)_gameActor["Hit"] * fPropertyScale + (float)_gameActor["HitPer"] * 0.0001f + (skillHit) * 0.0001f;
        int pierce = _gameActor["Pierce"];

        skillProp.passThrough = (float)pierce / (float)(pierce + (int)recProp["Level"] * 270 + 2700);

        skillProp.superAttack  = (float)_gameActor["CriDmg"] * 0.0001f + (skillCriDmg) * 0.0001f;
        skillProp.superRate    = (float)_gameActor["Cri"] * fPropertyScale + (float)_gameActor["CriPer"] * 0.0001f + (skillCri) * 0.0001f;
        skillProp.attPerSecond = attackPerSecond;
        if (_state.ContainsKey("dwDamagePer"))
        {
            skillProp.damagePer = ((int)_state["dwDamagePer"]) * 0.0001f;
        }
        else
        {
            skillProp.damagePer = 1.0f;
        }
        if (_gameActor.Property.ContainsKey("HurtOtherModify"))
        {
            skillProp.hurtOtherModify = ((int)_gameActor["HurtOtherModify"]) * 0.0001f;
        }
        else
        {
            skillProp.hurtOtherModify = 0.0f;
        }

        //属性修正aaa
        int attAttr = (int)_state["byDamegePro"];

        if (attAttr == 0)
        {
            skillProp.type = SkillType.Skill_Physic;
        }
        else if (attAttr == 1)
        {
            skillProp.type = SkillType.Skill_Ice;
        }
        else if (attAttr == 2)
        {
            skillProp.type = SkillType.Skill_Fire;
        }
        else if (attAttr == 3)
        {
            skillProp.type = SkillType.Skill_Poison;
        }
        else if (attAttr == 4)
        {
            skillProp.type = SkillType.Skill_Thunder;
        }
        skillProp.PropertyModify = CalulatePropertyModify(_gameActor, attAttr);
        ///体型修正aaaa
        skillProp.BodyTypeModify = CalulateBodyModify(_state, targetActor);
        //控制状态修正aaa
        skillProp.StateModify = CalulateStateModify(_gameActor, targetActor);

        SkillDefProperty defProp = new SkillDefProperty();

        defProp.level = (int)recProp["Level"];
        defProp.def   = (int)recProp["Def"];
        int dodge = (int)recProp["Dodge"];

        defProp.dodgeRate  = dodge * fPropertyScale;
        defProp.dodgeRate += ((int)recProp["DodgePer"]) * 0.0001f;
        defProp.fireDef    = (int)recProp["FireDef"];
        defProp.iceDef     = (int)recProp["IceDef"];
        defProp.poisonDef  = (int)recProp["PoisonDef"];
        int criDmgDef = (int)recProp["CriDmgDef"];

        defProp.superDef   = (float)criDmgDef * 0.0001f;
        defProp.thunderDef = (int)recProp["ThunderDef"];
        int flex = (int)recProp["Flex"];

        defProp.toughness = (float)flex * fPropertyScale;
        if (recProp.ContainsKey("BeHurtModify"))
        {
            defProp.beHurtModify = ((int)recProp["BeHurtModify"]) * 0.0001f;
        }
        else
        {
            defProp.beHurtModify = 0.0f;
        }

        bool isNormalAtk = false;

        if (attAttr == 0)
        {
            isNormalAtk = true;
        }

        bool isSuper;
        bool bDodge;

        dr.damage = CalculateAttack(skillProp, defProp, isNormalAtk, bySkillEffect, out isSuper, out bDodge);
        CalculateBubbleType(_state, _gameActor, targetActor, isSuper, bDodge, ref dr);
        if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_HP)
        {
            targetActor.AddHP(dr.damage);
        }
        else if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_MP)
        {
            targetActor.AddSP(dr.damage);
        }
        else if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_SP)
        {
            targetActor.AddSP(-dr.damage);
        }
        else
        {
            if (targetActor.CheckDebuffState(HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_UNBEAT))
            {
                dr.bubbleType = Bubble.BubbleType.eBT_Dodge;
                dr.damage     = 0;
            }
            targetActor.OnHurt(dr);
        }
        if (_state.Contains("WeaponHitType"))
        {
            targetActor.DoHittedAudio((string)_state["WeaponHitType"]);
        }
        if (targetActor.actorType == ActorType.AT_Monster && dr.damage > 0)
        {
            sdGameMonster monster     = (sdGameMonster)targetActor;
            int           monsterType = (int)monster.Property["BodyType"];
            if (_state.Contains("ParentID") && _state.Contains("dwTemplateID"))            //临时代码判断是技能伤害aa
            {
                int id = (int)_state["dwTemplateID"];
                _gameActor.OnAttackRestore(id, dr.damage, monsterType);
            }
        }
        //是否打断被击目标的某些buffer
        if (_state.ContainsKey("BreakState"))
        {
            int[] buffID = (int[])(_state["BreakState"]);
            if (buffID.Length == 2)
            {
                targetActor.RemoveBuff(buffID[0], buffID[1]);
            }
        }
        return(dr);
    }
Exemple #3
0
    public int CalculateAttack(SkillProperty skill, SkillDefProperty receiver, bool isNormalAtk, HeaderProto.ESkillEffect byskilleffect, out bool isSuper, out bool bDodge)
    {
        //首先判断是否命中...
        isSuper = false;
        bDodge  = false;
        float hitRate = skill.hitRate - receiver.dodgeRate;

        if (hitRate <= 0.0f)
        {
            bDodge = true;
            return(0);
        }
        int hit = Random.Range(0, 10001);

        if (hit > (int)(hitRate * 10000))
        {
            bDodge = true;
            return(0);
        }
        //判断是否暴击...
        float superAttack = 0.0f;
        float superRate   = skill.superRate - receiver.toughness;

        if (superRate > 0.0f)
        {
            int super = Random.Range(0, 10001);

            if (super <= (int)(superRate * 10000))
            {
                isSuper     = true;
                superAttack = skill.superAttack - receiver.superDef;
                if (superAttack < 1.0f)
                {
                    superAttack = 1.0f;
                }
                skill.atk        = (int)((float)skill.atk * superAttack);
                skill.iceAtk     = (int)((float)skill.iceAtk * superAttack);
                skill.fireAtk    = (int)((float)skill.fireAtk * superAttack);
                skill.thunderAtk = (int)((float)skill.thunderAtk * superAttack);
                skill.poisonAtk  = (int)((float)skill.poisonAtk * superAttack);
            }
        }
        float attPerSec = skill.attPerSecond;
        int   def       = receiver.def;

        if (skill.type == SkillType.Skill_Ice)
        {
            def = receiver.iceDef;
        }
        else if (skill.type == SkillType.Skill_Fire)
        {
            def = receiver.fireDef;
        }
        else if (skill.type == SkillType.Skill_Poison)
        {
            def = receiver.poisonDef;
        }
        else if (skill.type == SkillType.Skill_Thunder)
        {
            def = receiver.thunderDef;
        }

        def = (int)(def * (1.0f - skill.passThrough));
        //计算减伤...
        float hurtDec = def / ((float)def + receiver.level * 270 + 2700);
        //计算最终伤害...
        int damage = (int)((((skill.atk + skill.iceAtk + skill.fireAtk + skill.poisonAtk + skill.thunderAtk) * skill.Y + skill.Z) *
                            (1.0f + skill.YZFix) + skill.ZFix) * skill.damagePer);
        //伤害附加 减伤
        int hurt = 0;

        if (byskilleffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_HP ||
            byskilleffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_MP)
        {
            hurt = damage;
        }
        else
        {
            hurt = (int)(damage * (1.0f + skill.hurtOtherModify + skill.PropertyModify + skill.BodyTypeModify + skill.StateModify) * (1.0f - hurtDec) * (1.0f + receiver.beHurtModify));
        }
        if (hurt <= 0)
        {
            hurt = Random.Range(1, 6);
        }
        return(hurt);
    }
Exemple #4
0
 public virtual int OnHit(sdActorInterface _gameActor, List <sdActorInterface> lstMonster, int iHitPointIndex, object userdata, HeaderProto.ESkillEffect skilleffect)
 {
     return(0);
 }
Exemple #5
0
    public override int     OnHit(sdActorInterface _gameActor, List <sdActorInterface> lstMonster, int iHitPointIndex, object userdata, HeaderProto.ESkillEffect skilleffect)
    {
        int nRet = 0;

        if (lstMonster.Count == 0)
        {
            return(nRet);
        }
        List <Bubble.BubbleType> lstBubbleType = new List <Bubble.BubbleType>();

        if (bCalcDamage)
        {
            sdTuiTuLogic tuiTuLogic = sdGameLevel.instance.battleSystem.tuiTuLogic;
            bool         bMaincChar = (_gameActor == sdGameLevel.instance.mainChar);
            lstMonster.ForEach(delegate(sdActorInterface monster)
            {
                CallStateEvent(eStateEventType.eSET_hit);

                sdBattleSystem bs = sdGameLevel.instance.battleSystem;
                DamageResult dr   = bs.testHurt(
                    _gameActor,
                    stateData,
                    monster,
                    iHitPointIndex,
                    skilleffect
                    );

                //播放命中特效.闪避buff的不播放命中特效aaa
                if (dr.damage > 0)
                {
                    PlayHitEffect(monster);
                }
                lstBubbleType.Add(dr.bubbleType);
                if (Bubble.IsHurtOther(dr.bubbleType))
                {
                    nRet++;
                }
            });
        }
        AddSkillEffect(_gameActor, lstMonster, lstBubbleType, skillEffect, null, ((int)stateData["ParentID"]) / 100);
        return(nRet);
    }
Exemple #6
0
    // @describe 统一的攻击判定aa
    public override int DoSDAttack(sdActorInterface kAttacker,
                                   Hashtable kSkillInfo,
                                   int iStrikeType,
                                   Vector3 kStrikeCenter,
                                   float fStrikeDistance,
                                   int iStrikeAngle,
                                   int iHitPointIndex,
                                   sdAttackCB kCallback)
    {
        int nRet = 0;

        if (tuiTuLogic == null)
        {
            return(nRet);
        }

        if (gameLevel == null)
        {
            return(nRet);
        }

        if (kAttacker == null)
        {
            return(nRet);
        }

        if (kSkillInfo == null)
        {
            return(nRet);
        }

        HeaderProto.ESkillObjType objType     = (HeaderProto.ESkillObjType)kSkillInfo["byTargetType"];
        List <sdActorInterface>   kTargetList = gameLevel.actorMgr.FindActor(
            kAttacker,
            objType,
            kStrikeCenter,
            kAttacker.GetDirection(),
            iStrikeType,
            iStrikeAngle,
            fStrikeDistance,
            true);

        if (kTargetList == null)
        {
            return(nRet);
        }

        // AOE技能最大攻击目标aa
        if (kSkillInfo.ContainsKey("wAoeAimNum"))
        {
            int nMaxTarget = (int)kSkillInfo["wAoeAimNum"];
            if (kTargetList.Count > nMaxTarget)
            {
                kTargetList.RemoveRange(nMaxTarget, kTargetList.Count - nMaxTarget);
            }
        }

        // 技能特效aa
        HeaderProto.ESkillEffect skilleffect = HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_HP;
        if (kSkillInfo.ContainsKey("bySkillEffect"))
        {
            skilleffect = (HeaderProto.ESkillEffect)(kSkillInfo["bySkillEffect"]);
        }

        // 判定伤害aa
        if (kCallback != null)
        {
            return(kCallback.OnHit(kAttacker, kTargetList, iHitPointIndex, null, skilleffect));
        }
        else
        {
            sdBattleSystem kBattleSystem = sdGameLevel.instance.battleSystem;
            kTargetList.ForEach(delegate(sdActorInterface kActor)
            {
                DamageResult dr = kBattleSystem.testHurt(
                    kAttacker,
                    kSkillInfo,
                    kActor,
                    iHitPointIndex,
                    skilleffect
                    );
                if (Bubble.IsHurtOther(dr.bubbleType))
                {
                    ++nRet;
                }
            });
            return(nRet);
        }
    }
Exemple #7
0
    public static bool    Do(sdActorInterface actor, OpParameter param)
    {
        Hashtable table = sdConfDataMgr.Instance().GetTable("operation");

        Operation op = (Operation)table[param.id];

        switch (op.byOperationType)
        {
        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_NONE: {
            return(true);
        }

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_FOREVER: {
            if (param.doType == (int)HeaderProto.EDoOperationType.DO_OPERATION_TYPE_START ||
                param.doType == (int)HeaderProto.EDoOperationType.DO_OPERATION_TYPE_ADD
                )
            {
                if (actor == null)
                {
                    return(false);
                }
                Hashtable dst = actor.GetProperty();
                switch (op.dwOperationPara1)
                {
                case (int)HeaderProto.EOpreationFlag.OPREATION_FLAG_ADD: {
                    AddProperty(actor, dst, op, param);
                } break;

                case (int)HeaderProto.EOpreationFlag.OPREATION_FLAG_REDUCE: {
                    param.data = -param.data;
                    AddProperty(actor, dst, op, param);
                } break;

                case (int)HeaderProto.EOpreationFlag.OPREATION_FLAG_SET: {} break;
                }
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_STATE: {
            if (actor == null)
            {
                return(false);
            }
            if (param.doType == (int)HeaderProto.EDoOperationType.DO_OPERATION_TYPE_START)
            {
                HeaderProto.ECreatureActionState state = (HeaderProto.ECreatureActionState)param.data;
                actor.AddDebuffState(state);
            }
            else if (param.doType == (int)HeaderProto.EDoOperationType.DO_OPERATION_TYPE_REMOVE)
            {
                HeaderProto.ECreatureActionState state = (HeaderProto.ECreatureActionState)param.data;
                actor.RemoveDebuffState(state);
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_ADD_BUFF: {
            if (actor == null)
            {
                return(false);
            }
            actor.AddBuff(param.data, param.data1, param.attackActor);
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_DISPEL: {
            if (actor == null)
            {
                return(false);
            }
            if (op.dwOperationPara0 == 0)
            {
                actor.RemoveBuffbyClassType(op.dwOperationPara1);
            }
            else if (op.dwOperationPara0 == 1)
            {
                actor.RemoveBuff(op.dwOperationPara1, op.dwOperationPara2);
            }
            else if (op.dwOperationPara0 == 2)
            {
                actor.RemoveBuffbyID(param.data);
            }
            else if (op.dwOperationPara0 == 3)
            {
                actor.RemoveBuffbyProperty(op.dwOperationPara1);
            }
            else if (op.dwOperationPara0 == 4)
            {
            }
            else if (op.dwOperationPara0 == 5)
            {
                actor.RemoveAllBuff();
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_DO_BUFF_DAMAGE:
        {
            if (param.targetActor == null)
            {
                return(false);
            }
            Hashtable action = sdConfDataMgr.Instance().m_BuffAction[param.data]       as Hashtable;

            int strikeType = (int)action["byAoeAreaType"];
            int nCombo     = 0;
            if (strikeType == 0)
            {
                HeaderProto.ESkillEffect skilleffect = HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_HP;
                if (action.ContainsKey("bySkillEffect"))
                {
                    skilleffect = (HeaderProto.ESkillEffect)(action["bySkillEffect"]);
                }
                action["ParentID"] = 0;
                DamageResult dr = sdGameLevel.instance.battleSystem.testHurt(param.attackActor,
                                                                             action,
                                                                             param.targetActor,
                                                                             0,
                                                                             skilleffect);
                if (Bubble.IsHurtOther(dr.bubbleType))
                {
                    nCombo++;
                }
            }
            else
            {
                nCombo = sdGameLevel.instance.battleSystem.DoSDAttack(
                    param.attackActor,
                    action,
                    param.targetActor.transform.position,
                    0,
                    null);
            }
            if (param.attackActor == sdGameLevel.instance.mainChar && nCombo > 0)
            {
                sdUICharacter.Instance.ShowComboWnd(true, nCombo);
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_CLEAR_SKILL_COOLDOWN:
        {
            sdGameActor gameActor = (sdGameActor)actor;
            if (op.dwOperationPara0 == 0)                    //某个技能aa
            {
                int     skillID = param.data / 100;
                sdSkill skill   = gameActor.skillTree.getSkill(skillID);
                if (skill != null)
                {
                    if (op.dwOperationPara1 == 0)
                    {
                        skill.skillState = (int)sdSkill.State.eSS_OK;
                    }
                    else if (op.dwOperationPara1 == 1)
                    {
                        int time = CalculateSkillCoolDown(op.dwOperationPara2, op.dwOperationPara3, skill.GetCD(), param.data1);
                        sdUICharacter.Instance.SetShortCutCd(param.data, time, true);
                        skill.cooldown = time;
                        skill.Setct(0.0f);
                    }
                }
            }
            else if (op.dwOperationPara0 == 1)                   //某种形态的技能aa
            {
                foreach (DictionaryEntry de in gameActor.skillTree.AllSkill)
                {
                    sdSkill skill = de.Value as sdSkill;
                    if (skill.skillProperty.ContainsKey("byShape"))
                    {
                        int byShape = (int)skill.skillProperty["byShape"];
                        if (byShape == param.data)
                        {
                            if (op.dwOperationPara1 == 0)
                            {
                                skill.skillState = (int)sdSkill.State.eSS_OK;
                            }
                            else if (op.dwOperationPara1 == 1)
                            {
                                int time = CalculateSkillCoolDown(op.dwOperationPara2, op.dwOperationPara3, skill.cooldown, param.data1);
                                sdUICharacter.Instance.SetShortCutCd(skill.id, time, true);
                                skill.cooldown = time;
                                skill.Setct(0.0f);
                            }
                        }
                    }
                }
            }
            else if (op.dwOperationPara0 == 2)                   //所有技能aa
            {
                foreach (DictionaryEntry de in gameActor.skillTree.AllSkill)
                {
                    sdSkill skill = de.Value as sdSkill;
                    if (op.dwOperationPara1 == 0)
                    {
                        skill.skillState = (int)sdSkill.State.eSS_OK;
                    }
                    else if (op.dwOperationPara1 == 1)
                    {
                        int time = CalculateSkillCoolDown(op.dwOperationPara2, op.dwOperationPara3, skill.cooldown, param.data1);
                        sdUICharacter.Instance.SetShortCutCd(skill.id, time, true);
                        skill.cooldown = time;
                        skill.Setct(0.0f);
                    }
                }
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_SUMMON_MONSTER:                  //operator.txt byOperationType
        {
            iSummonUniqueID++;
            if (op.dwOperationPara0 == 1)
            {
                int     iAngle       = op.dwOperationPara2;
                int     iSummonID    = param.data;
                int     iSommonCount = param.data1;
                int     skillID      = param.data2;
                Vector3 v            = param.attackActor.GetDirection();
                v.y = 0.0f;
                v.Normalize();
                Quaternion tempQ = Quaternion.FromToRotation(new Vector3(0, 0, 1), v);
                if (v.z < -0.9999f)
                {
                    tempQ = Quaternion.AngleAxis(180.0f, new Vector3(0, 1, 0));
                }

                List <sdActorInterface> lstActor = null;
                if (op.dwOperationPara3 == 1 || op.dwOperationPara3 == 2)                        //1 方向并跟踪目标  2.方向不跟踪aaa
                {
                    List <sdActorInterface> actorList = null;
                    if (iAngle == 360)
                    {
                        actorList = sdGameLevel.instance.actorMgr.FindActor(
                            param.attackActor,
                            HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY,
                            param.attackActor.transform.position,
                            Vector3.zero,
                            1,
                            0,
                            15.0f,
                            true);
                    }
                    else
                    {
                        actorList = sdGameLevel.instance.actorMgr.FindActor(
                            param.attackActor,
                            HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY,
                            param.attackActor.transform.position,
                            param.attackActor.GetDirection(),
                            5,
                            iAngle,
                            15.0f,
                            true);
                    }
                    lstActor = sdGameLevel.instance.actorMgr.SortActor(param.attackActor.transform.position, actorList);
                }

                int i = 0;
                if (op.dwOperationPara3 == 1)
                {
                    for (; i < iSommonCount && i < lstActor.Count; i++)
                    {
                        sdActorInterface target  = lstActor[i];
                        SummonInfo       sumInfo = new SummonInfo();
                        Vector3          vDir    = target.transform.position - param.attackActor.transform.position;
                        vDir.y = 0.0f;
                        vDir.Normalize();
                        if (v.z < -0.99999f)
                        {
                            sumInfo.rotate = Quaternion.AngleAxis(180.0f, new Vector3(0, 1, 0));
                        }
                        else
                        {
                            sumInfo.rotate = Quaternion.FromToRotation(new Vector3(0, 0, 1), vDir);
                        }
                        sumInfo.pos      = param.trans.position;
                        sumInfo.userdata = target;
                        sumInfo.summonID = iSummonID;
                        sumInfo.skillID  = skillID;
                        param.attackActor.AddSummon(sumInfo, iSummonUniqueID);
                    }
                }
                else if (op.dwOperationPara3 == 2)
                {
                    for (; i < iSommonCount && i < lstActor.Count; i++)
                    {
                        sdActorInterface target = lstActor[i];
                        Vector3          vDir   = target.transform.position - param.attackActor.transform.position;
                        vDir.y = 0.0f;
                        vDir.Normalize();
                        SummonInfo sumInfo = new SummonInfo();
                        if (v.z < -0.99999f)
                        {
                            sumInfo.rotate = Quaternion.AngleAxis(180.0f, new Vector3(0, 1, 0));
                        }
                        else
                        {
                            sumInfo.rotate = Quaternion.FromToRotation(new Vector3(0, 0, 1), vDir);
                        }
                        sumInfo.pos      = param.trans.position;
                        sumInfo.summonID = iSummonID;
                        sumInfo.skillID  = skillID;
                        param.attackActor.AddSummon(sumInfo, iSummonUniqueID);
                    }
                }
                if (i < iSommonCount)
                {
                    if (iAngle == 360)
                    {
                        float iPerAngle = (float)iAngle / (float)(iSommonCount - i);
                        for (int j = 0; j < iSommonCount - i; j++)
                        {
                            SummonInfo sumInfo = new SummonInfo();
                            sumInfo.rotate   = Quaternion.AngleAxis(iPerAngle * j, new Vector3(0, 1, 0)) * tempQ;
                            sumInfo.pos      = param.trans.position;
                            sumInfo.summonID = iSummonID;
                            sumInfo.skillID  = skillID;
                            param.attackActor.AddSummon(sumInfo, iSummonUniqueID);
                        }
                    }
                    else
                    {
                        float iPerAngle   = (float)iAngle / (float)(iSommonCount - i + 1);
                        float iAngleStart = -iAngle * 0.5f + iPerAngle;
                        for (int j = 0; j < iSommonCount - i; j++)
                        {
                            SummonInfo sumInfo = new SummonInfo();
                            sumInfo.rotate   = Quaternion.AngleAxis(iAngleStart + iPerAngle * j, new Vector3(0, 1, 0)) * tempQ;
                            sumInfo.pos      = param.trans.position;
                            sumInfo.summonID = iSummonID;
                            sumInfo.skillID  = skillID;
                            param.attackActor.AddSummon(sumInfo, iSummonUniqueID);
                        }
                    }
                }
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_TELEPORT:
        {
            TeleportInfo tpInfo = new TeleportInfo();
            tpInfo.Type = op.dwOperationPara0;
            tpInfo.PlayActionProbality = op.dwOperationPara1;
            tpInfo.TeleportState       = (op.dwOperationPara2 == 1);
            tpInfo.MoveSpeed           = (float)param.data * 0.001f;
            tpInfo.MoveTime            = (float)param.data1 * 0.001f;
            tpInfo.castActor           = param.attackActor;
            tpInfo.castCenter          = param.attackActor.transform.position;
            if (actor != null)
            {
                actor.SetTeleportInfo(tpInfo);
            }
            else
            {
                float dis = tpInfo.MoveSpeed * tpInfo.MoveTime;
                List <sdActorInterface> lstActor = sdGameLevel.instance.actorMgr.FindActor(param.attackActor, HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY, tpInfo.castCenter, Vector3.zero, 1, 0, dis, true);
                if (lstActor != null)
                {
                    foreach (sdActorInterface a in lstActor)
                    {
                        a.SetTeleportInfo(tpInfo);
                    }
                }
            }
        } break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_DOACTION:
        {
            sdGameActor gameActor = (sdGameActor)(param.attackActor);
            sdBaseState baseState = (sdBaseState)gameActor.logicTSM.states[param.data];
            if (baseState != null)
            {
                int nCombo = sdGameLevel.instance.battleSystem.DoSDAttack(gameActor, baseState.stateData, gameActor.transform.position, 0, baseState);
                baseState.playEffectNow(gameActor);
                baseState.PlayAudioNow(gameActor);
                if (gameActor == sdGameLevel.instance.mainChar && nCombo > 0)
                {
                    sdUICharacter.Instance.ShowComboWnd(true, nCombo);
                }
            }
        }
        break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_COMBO:
        {
            if (param.attackActor.GetActorType() == ActorType.AT_Player)
            {
                sdGameActor gameActor = (sdGameActor)(param.attackActor);
                sdBaseState baseState = (sdBaseState)gameActor.logicTSM.states[param.data];
                if (baseState != null)
                {
                    baseState.bEnable = (param.data1 == 1);
                }
            }
        }
        break;

        case (int)HeaderProto.EOpreationType.OPREATION_TYPE_ATTACKGETHP:
        {
            AttackRestore data = new AttackRestore();
            data.upperLimit  = op.dwOperationPara1 * 0.0001f;
            data.restoreHp   = (op.dwOperationPara0 == 0);
            data.monsterType = op.dwOperationPara2;
            data.ratio       = param.data * 0.0001f;
            data.actionID    = param.data1;
            sdGameActor gameActor = (sdGameActor)(param.attackActor);
            gameActor.AddAttackRestore(data);
        }
        break;

        case (int)HeaderProto.EOpreationType.OPERATION_TYPE_SUMMON:
        {
            iSummonUniqueID++;
            switch (op.dwOperationPara0)
            {
            case 0:
            case 1:
                PointSummon(actor, param, op);
                break;

            case 2:
            case 3:
                RandomSummon(actor, param, op);
                break;

            case 4:
            case 5:
                RoundSummon(actor, param, op);
                break;
            }
        }
        break;

        case (int)HeaderProto.EOpreationType.OPERATION_TYPE_HIDESHOW:
        {
            HideShowInfo info = new HideShowInfo();
            info.actor     = param.attackActor;
            info.fHideTime = param.data * 0.001f;
            info.fDistance = param.data1 * 0.001f;
            sdHideShowMgr.Instance.AddActor(info);
        }
        break;

        case (int)HeaderProto.EOpreationType.OPERATION_TYPE_FLASH:
        {
            float fFront = 1.0f;
            if ((op.dwOperationPara0 & 1) == 1)
            {
                fFront = -1.0f;
            }
            float fDistance = (float)op.dwOperationPara3 * 0.001f;

            sdActorInterface castActor = param.attackActor;

            int playerLayer  = 1 << LayerMask.NameToLayer("Player");
            int petLayer     = 1 << LayerMask.NameToLayer("Pet");
            int monsterLayer = 1 << LayerMask.NameToLayer("Monster");
            int mask         = ~(playerLayer | petLayer | monsterLayer);

            switch (op.dwOperationPara0)
            {
            case 0:
            case 1:
            {
                fDistance = (float)param.data1 * 0.001f;
                Vector3 dir = castActor.GetDirection() * fFront;
                Vector3 pos = castActor.transform.position;



                int   oldLayer = castActor.gameObject.layer;
                int[] layer    = new int[] {
                    LayerMask.NameToLayer("Monster"),
                    LayerMask.NameToLayer("Pet"),
                    LayerMask.NameToLayer("Player")
                };
                bool[] oldcollision = new bool[3];
                for (int i = 0; i < 3; i++)
                {
                    oldcollision[i] = Physics.GetIgnoreLayerCollision(oldLayer, layer[i]);
                    Physics.IgnoreLayerCollision(oldLayer, layer[i]);
                }

                ((sdGameActor)castActor).moveInternal(dir * fDistance / Time.deltaTime);

                for (int i = 0; i < 3; i++)
                {
                    Physics.IgnoreLayerCollision(oldLayer, layer[i], oldcollision[i]);
                }
                castActor.gameObject.layer = oldLayer;

                Vector3 newPos = castActor.transform.position;

                sdGameLevel.instance.actorMgr.ManualCheckTrigger((sdGameActor)castActor, pos, newPos - pos);

                if (param.data > 0)
                {
                    HideShowInfo info = new HideShowInfo();
                    info.actor     = castActor;
                    info.fHideTime = param.data * 0.001f;
                    info.fDistance = 0.0f;
                    sdHideShowMgr.Instance.AddActorNoRandomPosition(info);
                }
            }
            break;

            case 2:
            case 3:
            {
                float fResearchDistance           = param.data1 * 0.001f;
                int   iAngle                      = op.dwOperationPara1;
                List <sdActorInterface> actorList = null;
                if (iAngle == 360)
                {
                    actorList = sdGameLevel.instance.actorMgr.FindActor(
                        param.attackActor,
                        HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY,
                        param.attackActor.transform.position,
                        Vector3.zero,
                        1,
                        0,
                        fResearchDistance,
                        true);
                }
                else
                {
                    actorList = sdGameLevel.instance.actorMgr.FindActor(
                        param.attackActor,
                        HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY,
                        param.attackActor.transform.position,
                        param.attackActor.GetDirection(),
                        5,
                        iAngle,
                        fResearchDistance,
                        true);
                }

                sdActorInterface targetActor = null;
                if (actorList != null)
                {
                    if (actorList.Count > 0)
                    {
                        if (op.dwOperationPara2 == 0)
                        {
                            targetActor = actorList[0];
                            float min = (castActor.transform.position - targetActor.transform.position).sqrMagnitude;
                            for (int i = 1; i < actorList.Count; i++)
                            {
                                Vector3 v = castActor.transform.position - actorList[i].transform.position;
                                if (v.sqrMagnitude < min)
                                {
                                    min         = v.sqrMagnitude;
                                    targetActor = actorList[i];
                                }
                            }
                        }
                        else
                        {
                            int index = Random.Range(0, actorList.Count);
                            if (index >= actorList.Count)
                            {
                                index = 0;
                            }
                            targetActor = actorList[index];
                        }
                    }
                }

                if (targetActor != null)
                {
                    if (fDistance < targetActor.getRadius() + castActor.getRadius())
                    {
                        fDistance = targetActor.getRadius() + castActor.getRadius();
                    }
                    Vector3    dir = targetActor.GetDirection() * fFront;
                    Vector3    pos = targetActor.transform.position + new Vector3(0, 0.1f, 0);
                    RaycastHit hit;
                    if (Physics.Raycast(pos, dir, out hit, fDistance * 2, mask))
                    {
                        if (hit.distance < fDistance)
                        {
                            fDistance = hit.distance;
                        }
                    }

                    castActor.transform.position = targetActor.transform.position + dir * fDistance;

                    dir.y = 0.0f;
                    dir.Normalize();

                    ((sdGameActor)castActor).spinToTargetDirection(-dir, true);
                    if (param.data > 0)
                    {
                        HideShowInfo info = new HideShowInfo();
                        info.actor     = castActor;
                        info.fHideTime = param.data * 0.001f;
                        info.fDistance = 0.0f;
                        sdHideShowMgr.Instance.AddActorNoRandomPosition(info);
                    }
                }
            } break;
            }
        }
        break;
        }
        return(true);
    }
    public override int     OnHit(sdActorInterface _gameActor, List <sdActorInterface> lstMonster, int iHitPointIndex, object userdata, HeaderProto.ESkillEffect skilleffect)
    {
        int nRet = 0;

        if (lstMonster.Count == 0)
        {
            sdGameActor ga = (sdGameActor)_gameActor;
            //如果没有怪物,停止闪电连...
            if (ga.logicTSM.nextState == null)
            {
                ga.logicTSM.nextState = ga.logicTSM.GetCurrentPassiveState();
            }
            if (control != null)
            {
                control.SetPositionArray(null);
            }
            return(nRet);
        }
        List <sdActorInterface> lstMonserHit = new List <sdActorInterface>();


        Vector3          vPos        = _gameActor.transform.position;
        sdActorInterface tempMonster = GetNearestMonster(lstMonserHit, vPos, lstMonster);

        lstMonserHit.Add(tempMonster);

        Vector3 v = lstMonserHit[0].transform.position - _gameActor.transform.position;

        v.y = 0.0f;
        v.Normalize();
        ((sdMainChar)_gameActor).spinToTargetDirection(v, true);

        int Count = 1;

        for (int i = 1; i < iMaxMonster; i++)
        {
            tempMonster = GetNearestMonster(lstMonserHit, vPos, lstMonster);
            if (tempMonster != null)
            {
                lstMonserHit.Add(tempMonster);
                Count++;
            }
        }


        GameObject[] vMonsterPos = new GameObject[Count];
        for (int i = 0; i < Count; i++)
        {
            sdActorInterface monster = lstMonserHit[i];
            vMonsterPos[i] = monster.gameObject;
        }
        if (control != null)
        {
            control.SetPositionArray(vMonsterPos);
        }
        //base.OnHit(_gameActor,lstMonserHit,iHitPointIndex,userdata);
        sdTuiTuLogic             tuiTuLogic    = sdGameLevel.instance.battleSystem.tuiTuLogic;
        List <Bubble.BubbleType> lstBubbleType = new List <Bubble.BubbleType>();

        for (int i = 0; i < lstMonserHit.Count; i++)
        {
            sdActorInterface monster = lstMonserHit[i];

            CallStateEvent(eStateEventType.eSET_hit);

            sdBattleSystem bs = sdGameLevel.instance.battleSystem;
            DamageResult   dr = bs.testHurt(
                _gameActor,
                stateData,
                monster,
                i,
                skilleffect
                );
            //播放命中特效.
            if (dr.damage > 0)
            {
                PlayHitEffect(monster);
            }
            lstBubbleType.Add(dr.bubbleType);
            if (Bubble.IsHurtOther(dr.bubbleType))
            {
                nRet++;
            }
        }
        AddSkillEffect(_gameActor, lstMonserHit, lstBubbleType, skillEffect, null, ((int)stateData["ParentID"]) / 100);
        return(nRet);
    }
Exemple #9
0
    public int     OnHit(List <sdActorInterface> lstactor, HeaderProto.ESkillEffect eSkileffect)
    {
        int CalcDamage = (int)info["CalcDamage"];

        info["ParentID"] = skillID * 100;
        int nRet = 0;
        List <Bubble.BubbleType> lstBubbleType = new List <Bubble.BubbleType>();

        for (int index = 0; index < lstactor.Count; ++index)
        {
            sdActorInterface actor = lstactor[index];

            if (PeriodTime == 0)
            {
                if (!actor.IsCanSummonAttack(uniqueID))
                {
                    lstBubbleType.Add(Bubble.BubbleType.eBT_Max);
                    continue;
                }
                actor.SetSummonAttackInfo(uniqueID);
            }
            DamageResult dr;
            dr.damage = 0;
            if (CalcDamage != 0)
            {
                dr = sdGameLevel.instance.battleSystem.testHurt(castActor, info, actor, 0, eSkileffect);
                lstBubbleType.Add(dr.bubbleType);
                if (Bubble.IsHurtOther(dr.bubbleType))
                {
                    ++nRet;
                }
            }
            else
            {
                lstBubbleType.Add(Bubble.BubbleType.eBT_Max);
            }

            string hitEffect = info["HitEffect"] as string;
            if (hitEffect.Length > 0 && dr.damage > 0)
            {
                int       life     = (int)info["HitEffectLife"];
                Transform bindnode = actor.transform;
                if (actor.actorType == ActorType.AT_Player)
                {
                    if (info.ContainsKey("HitDummy"))
                    {
                        int pos = (int)info["HitDummy"];
                        if (pos == 1)
                        {
                            sdGameActor gameactor = (sdGameActor)actor;
                            GameObject  chest     = gameactor.GetNode("Bip01 Spine");
                            if (chest != null)
                            {
                                bindnode = chest.transform;
                            }
                        }
                    }
                }
                else
                {
                    sdGameMonster monster = (sdGameMonster)actor;
                    if (monster.ChestPoint.Length > 0)
                    {
                        GameObject chest = monster.GetNode(monster.ChestPoint.Replace("\r\n", ""));
                        if (chest != null)
                        {
                            bindnode = chest.transform;
                        }
                    }
                }
                sdGameActor.AddHitEffect(hitEffect, bindnode, life * 0.001f, Vector3.zero, true);
            }
        }
        sdBaseState.AddSkillEffect(castActor, lstactor, lstBubbleType, skillEffect, transform, skillID);
        return(nRet);
    }
Exemple #10
0
    //浼ゅ?妫€娴媋aa
    int   CheckDamage()
    {
        int nRet = 0;

        HeaderProto.ESkillEffect eSkilleffect = HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_HP;
        if (info.ContainsKey("bySkillEffect"))
        {
            eSkilleffect = (HeaderProto.ESkillEffect)(info["bySkillEffect"]);
        }
        //鍛ㄦ湡鎬у彫鍞ょ墿
        if (PeriodTime != 0)
        {
            TriggerCount = 0;
            int iCurrentCount = CurrentLife / PeriodTime;
            TriggerCount = iCurrentCount - PeriodCount;
            PeriodCount  = iCurrentCount;

            if (TriggerCount != 0)
            {
                sdBaseState.AddSkillEffect(castActor, HeaderProto.ESkillTimingConditionType.SKILL_TIMING_CONDITION_TYPE_HIT, 0, skillEffect, null, transform, skillID);
                //璁$畻浼ゅ?
                List <sdActorInterface> lstActor = FindActor();
                if (lstActor != null)
                {
                    foreach (sdActorInterface a in lstActor)
                    {
                        if (a.IsActive() && a.GetCurrentHP() > 0)
                        {
                            List <sdActorInterface> listActor = new List <sdActorInterface>();
                            listActor.Add(a);
                            nRet += OnHit(listActor, eSkilleffect);
                        }
                    }
                }
                bool shakeCamera = ((int)info["shakeCamera"] == 1);
                if (shakeCamera)
                {
                    float shakelevel = ((int)info["ShakeLevel"]) * 0.0001f;
                    sdGameLevel.instance.mainCamera.addRandomCameraShake(0.3f, 0.3f * shakelevel, 60.0f, 3.0f);
                }
            }
            return(nRet);
        }
        //鍙?敓鏁堜竴娆$殑鎶€鑳既
        if (HitCount == 1)
        {
            sdActorInterface a = FindOneActor();
            if (a != null)
            {
                if (a.IsActive() && a.GetCurrentHP() > 0)
                {
                    nRet += CalcDamage(a);
                    End();
                }
            }
            return(nRet);
        }
        //浼氱敓鏁堝?娆$殑鎶€鑳忌		if(HitCount	>	1)
        {
            List <sdActorInterface> lstActor = FindActor();
            if (lstActor != null)
            {
                for (int i = 0; i < lstActor.Count; i++)
                {
                    sdActorInterface a           = lstActor[i];
                    bool             bInLastList = false;
                    for (int j = 0; j < LastActorList.Count; j++)
                    {
                        if (a == lstActor[j])
                        {
                            bInLastList = true;
                            break;
                        }
                    }
                    if (!bInLastList)
                    {
                        nRet += CalcDamage(a);
                        iCurrentHit++;
                        if (iCurrentHit >= HitCount)
                        {
                            End();
                        }
                    }
                }
                LastActorList = lstActor;
            }
            else
            {
                LastActorList.Clear();
            }
        }
        return(nRet);
    }
Exemple #11
0
 public override int     OnHit(sdActorInterface _gameActor, List <sdActorInterface> lstMonster, int iHitPointIndex, object userdata, HeaderProto.ESkillEffect eSkilleffect)
 {
     return(summon.OnHit(lstMonster, eSkilleffect));
 }