Esempio n. 1
0
 public CSkillBehavior()
 {
     m_bClosed     = false;
     m_pOwner      = null;
     m_GameObject  = null;
     m_CtrlSkelton = null;
 }
Esempio n. 2
0
 private void CalSkillEffect(CSceneEntity pBeAtcker, CSkill pSkill)
 {
     if (pBeAtcker != null)
     {
         pBeAtcker.OnBeAttacked(m_pOwner, pSkill, false, false, false);
     }
 }
Esempio n. 3
0
    public void CalculateDmg(CSceneEntity pBeAtcker, CSkill pSkill, string strActEff)
    {
        bool bCrit = false;

        if (!CalculateBlock(pBeAtcker, pSkill))
        {
            pBeAtcker.OnBeAttacked(m_pOwner, pSkill, false, true, false);
            return;
        }

        /*
         * if (!CalculateHit ( pBeAtcker, pSkill) )
         * {
         *      // miss 了
         *      pBeAtcker.OnBeAttacked( m_pOwner, pSkill, false, false, false );
         *      return ;
         * }
         */

        if (strActEff != "")
        {
            CalActionEffect(pBeAtcker, strActEff);
        }

        CalSkillEffect(pBeAtcker, pSkill);


        float fDmg = CalculateBaseDmg(pBeAtcker, pSkill);

        pBeAtcker.ChangeHP(m_pOwner, pSkill, -(int)fDmg, bCrit);
    }
Esempio n. 4
0
 //---------------------------------------------------------------------------------
 // 被攻击
 //---------------------------------------------------------------------------------
 public virtual void OnBeAttacked(CSceneEntity pSrc, CSkill pSkill, bool bHited, bool bBlock, bool bCrited)
 {
     if (CNGUISys.Inst != null && gameObject.transform.tag == "Player")
     {
         //if( CNGUISys.Inst.m_CombatUI != null )
         //	CNGUISys.Inst.m_CombatUI.SendMessage( "ShowBeAttackEffect" );
     }
 }
Esempio n. 5
0
 //-----------------------------------------------------------------------------------------
 // 初始化本行为的所有者
 //-----------------------------------------------------------------------------------------
 public virtual void InitFSM(CSceneEntity pNPC)
 {
     m_pOwner = pNPC;
     if (m_pOwner != null)
     {
         m_CtrlSkelton = m_pOwner.m_CtrlSkelton;
     }
 }
Esempio n. 6
0
 public CNormBehavior( )
 {
     m_pSkill      = null;
     m_pOwner      = null;
     m_bClose      = true;
     m_SegIndex    = 0;
     m_StepSeg     = NormalizeSeg.NATK_Null;
     m_CtrlSkelton = null;
 }
Esempio n. 7
0
 public void InitFSM(CSceneEntity pNPC)
 {
     m_pOwner     = pNPC;
     m_GameObject = m_pOwner.gameObject;
     if (m_GameObject != null)
     {
         m_CtrlSkelton = m_GameObject.GetComponent <CtrolAnimation>();
     }
 }
Esempio n. 8
0
    public CAIController(CNPCEntity pNPC)
    {
        m_pOwner        = pNPC;
        m_pProto        = m_pOwner.m_pProto;
        m_pTarget       = null;
        m_eCurAIState   = AIStateType.AIST_Idle;
        m_pCurrentState = CIdleAI.Instance();
        m_pTransition   = new GuardTransition();

        m_GameObject = m_pOwner.gameObject;
        m_vBornPos   = m_GameObject.transform.position;
    }
Esempio n. 9
0
    private void PlayBeAttackEffect(CSceneEntity pBeAtcker, string strEffect)
    {
        Transform effectpos = null;

        effectpos                 = (UnityEngine.GameObject.Instantiate(Resources.Load(strEffect)) as GameObject).transform;
        effectpos.parent          = pBeAtcker.gameObject.transform;
        effectpos.localPosition   = Vector3.zero;
        effectpos.gameObject.name = strEffect + "BeHit";
        effectpos.localRotation   = Quaternion.Euler(Vector3.zero);
        UnityEngine.GameObject.Destroy(effectpos.gameObject, 1);
        effectpos.parent = null;
    }
Esempio n. 10
0
    public override void OnDead(CSceneEntity pKiller, CSkill pSkill)
    {
        if (IsInState(EState.ES_Dead))
        {
            return;
        }

        //SetState (EState.ES_Dead);

        if (pKiller != null)
        {
            pKiller.OnKill(this);
        }
    }
Esempio n. 11
0
    public void StartLookForEnemy( )
    {
        if (m_pProto.eType == ECreatureType.ECT_NPC)
        {
            return;
        }

        float fMaxDist = m_pProto.fLookdistance;

        GameObject[] EnemyList = GetFronEnemy(fMaxDist);


        CHeroEntity phero = null;

        foreach (var Enemy in EnemyList)
        {
            CPlayerCompent pAI = Enemy.GetComponent <CPlayerCompent>();
            if (pAI.m_pOwner == null)
            {
                continue;
            }

            if (pAI.m_pOwner.IsDead())
            {
                continue;
            }

            if (pAI.m_pOwner.IsInState(EState.ES_Lurk))
            {
                continue;
            }

            float fDis = (m_GameObject.transform.position - Enemy.transform.position).magnitude;
            if (fDis < fMaxDist)
            {
                phero    = pAI.m_pOwner;
                fMaxDist = fDis;
            }
        }

        if (phero != null)
        {
            m_pTarget = phero;
        }

        ReSetLookForTargetTime();
    }
Esempio n. 12
0
    private float CalculateBaseDmg(CSceneEntity bBaker, CSkill pSkill)
    {
        float fBaseDmg = 1.0f;

        float fMinWeaponDmg = m_pOwner.GetAttValue(ERoleAttribute.ERA_WeaponDmgMin);
        float fMaxWeaponDmg = m_pOwner.GetAttValue(ERoleAttribute.ERA_WeaponDmgMax);
        float fWeaponDmg    = UnityEngine.Random.Range(fMinWeaponDmg, fMaxWeaponDmg);

        int nSkillDmg = 0;

        nSkillDmg = pSkill.GetDmg();

        if (pSkill.GetDmgType() == ESkillDmgType.ESDGT_Physical)
        {
            if (nSkillDmg > 100000)
            {
                fBaseDmg = fWeaponDmg * ((float)(nSkillDmg - 100000) / 100000.0f);
            }
            else
            {
                fBaseDmg = fWeaponDmg + nSkillDmg;
            }

            fBaseDmg = fBaseDmg * (1.0f + (float)m_pOwner.GetAttValue(ERoleAttribute.ERA_ExAttack) / 100.0f);
        }

        if (pSkill.GetDmgType() == ESkillDmgType.ESDGT_Energy)
        {
            if (nSkillDmg > 100000)
            {
                fBaseDmg = fWeaponDmg * ((float)(nSkillDmg - 100000) / 100000.0f);
            }
            else
            {
                fBaseDmg = fWeaponDmg + nSkillDmg;
            }

            fBaseDmg = fBaseDmg * (1.0f + (float)m_pOwner.GetAttValue(ERoleAttribute.ERA_InAttack) / 100.0f);
        }

        return(fBaseDmg);
    }
Esempio n. 13
0
    private bool CalculateBlock(CSceneEntity bBaker, CSkill pSkill)
    {
        float fBlock = 20.0f;

        if (fBlock < 0.0f)
        {
            fBlock = 0.0f;
        }
        if (fBlock > 1.0f)
        {
            fBlock = 1.0f;
        }

        float fradom = UnityEngine.Random.Range(0, 100);

        if (fradom < fBlock * 100)
        {
            return(true);
        }
        return(false);
    }
Esempio n. 14
0
    private bool CalculateCritRate(CSceneEntity bBaker, CSkill pSkill)
    {
        float fCrit = 2.0f * (m_pOwner.GetAttValue(ERoleAttribute.ERA_Crit_Rate) * m_pOwner.m_nLevel - m_pOwner.GetAttValue(ERoleAttribute.ERA_Technique) * bBaker.m_nLevel) / (m_pOwner.m_nLevel + bBaker.m_nLevel) * 1000.0f;

        if (fCrit < 0.01f)
        {
            fCrit = 0.01f;
        }
        else if (fCrit > 0.3f)
        {
            fCrit = 0.3f;
        }

        float fradom = UnityEngine.Random.Range(0, 100);

        if (fradom < fCrit * 100)
        {
            return(true);
        }
        return(false);
    }
Esempio n. 15
0
    private bool CalculateHit(CSceneEntity bBaker, CSkill pSkill)
    {
        float fHit = 0.0f;

        fHit = 0.9f * (1.0f - (float)(bBaker.GetAttValue(ERoleAttribute.ERA_Dodge) - m_pOwner.GetAttValue(ERoleAttribute.ERA_HitRate))) / 10000.0f;
        if (fHit < 0.0f)
        {
            fHit = 0.0f;
        }
        if (fHit > 1.0f)
        {
            fHit = 1.0f;
        }

        float fradom = UnityEngine.Random.Range(0, 100);

        if (fradom < fHit * 100)
        {
            return(true);
        }
        return(false);
    }
Esempio n. 16
0
    //---------------------------------------------------------------------------------
    // 游戏物体 HP 改变
    //---------------------------------------------------------------------------------
    public void ChangeHP(CSceneEntity pSrc, CSkill pSkill, int nValue, bool bCrit)
    {
        if (0 == nValue)
        {
            return;
        }

        ModAttValue(ERoleAttribute.ERA_HP, nValue);

        // 如果是见血事件
        if (nValue < 0)
        {
            if (GetAttValue(ERoleAttribute.ERA_HP) <= 0)
            {
                SetAttValue(ERoleAttribute.ERA_HP, 0, false);
                OnDead(pSrc, pSkill);
            }

            ShowHPEffect(-nValue);
        }

        OnAttChangeEvent();
    }
Esempio n. 17
0
    public CreatureFSM(CNPCEntity pOwner)
    {
        m_pOwner = pOwner;

        m_arrayBehavir = new CBehavior[14];
        CIdleBehavior Idle = new CIdleBehavior();

        Idle.InitFSM(pOwner);
        m_arrayBehavir[0] = null;
        m_arrayBehavir[0] = Idle;

        CMoveBehavior walk = new CMoveBehavior();

        walk.InitFSM(m_pOwner);
        m_arrayBehavir[1] = null;
        m_arrayBehavir[1] = walk;

        CAttackBehavior attack = new CAttackBehavior();

        attack.InitFSM(m_pOwner);
        m_arrayBehavir[2] = null;
        m_arrayBehavir[2] = attack;

        CDeadBehavior Dead = new CDeadBehavior();

        Dead.InitFSM(m_pOwner);
        m_arrayBehavir[3] = null;
        m_arrayBehavir[3] = Dead;

        CBeAtkBehavior BeAtk = new CBeAtkBehavior();

        BeAtk.InitFSM(m_pOwner);
        m_arrayBehavir [4] = BeAtk;

        CHitFlyBehavior HitFly = new CHitFlyBehavior();

        HitFly.InitFSM(m_pOwner);
        m_arrayBehavir[5] = null;
        m_arrayBehavir[5] = HitFly;

        CRepelBehavior Repel = new CRepelBehavior();

        Repel.InitFSM(m_pOwner);
        m_arrayBehavir[6] = null;
        m_arrayBehavir[6] = Repel;

        CAssaultBehavior Assault = new CAssaultBehavior();

        Assault.InitFSM(m_pOwner);
        m_arrayBehavir[7] = null;
        m_arrayBehavir[7] = Assault;

        CPullBehavior Pull = new CPullBehavior();

        Pull.InitFSM(m_pOwner);
        m_arrayBehavir[8] = null;
        m_arrayBehavir[8] = Pull;

        CDazzyBehavior Dazzy = new CDazzyBehavior();

        Dazzy.InitFSM(m_pOwner);
        m_arrayBehavir[9] = null;
        m_arrayBehavir[9] = Dazzy;

        CTieBehavior Tie = new CTieBehavior();

        Tie.InitFSM(m_pOwner);
        m_arrayBehavir[10] = null;
        m_arrayBehavir[10] = Tie;

        CSoporBehavior Sopor = new CSoporBehavior();

        Sopor.InitFSM(m_pOwner);
        m_arrayBehavir[11] = null;
        m_arrayBehavir[11] = Sopor;

        CHitDownBehavior HitDown = new CHitDownBehavior();

        HitDown.InitFSM(m_pOwner);
        m_arrayBehavir[12] = null;
        m_arrayBehavir[12] = HitDown;

        CSuspensionBehavior Susp = new CSuspensionBehavior();

        Susp.InitFSM(m_pOwner);
        m_arrayBehavir[13] = null;
        m_arrayBehavir[13] = Susp;
    }
Esempio n. 18
0
 //---------------------------------------------------------------------------------
 // 怪物死亡
 //---------------------------------------------------------------------------------
 public virtual void OnDead(CSceneEntity pKiller, CSkill pSkill)
 {
 }
Esempio n. 19
0
 public CBehavior()
 {
     m_pOwner      = null;
     m_CtrlSkelton = null;
 }
Esempio n. 20
0
    private void CalActionEffect(CSceneEntity pBeAtcker, string strActEffect)
    {
        if (pBeAtcker != null && m_pOwner != null)
        {
            int   iCmd   = int.Parse(strActEffect.Split('|')[0]);
            float fParam = float.Parse(strActEffect.Split('|')[1]);


            if (iCmd == 0)
            {
                if (pBeAtcker.gameObject.transform.tag == "Monster")
                {
                    CNPCEntity pNPC = (CNPCEntity)pBeAtcker;
                    if (pNPC.m_FSM == null)
                    {
                        return;
                    }

                    if (!pNPC.m_FSM.IsInBehavior(BehaviorType.EState_Suspension))
                    {
                        pNPC.m_FSM.Change2BeAtkBeHavior();
                    }
                }

                if (pBeAtcker.gameObject.transform.tag == "Player")
                {
                    CHeroEntity pNPC = (CHeroEntity)pBeAtcker;
                    if (pNPC != null && pNPC.m_FSM != null)
                    {
                        pNPC.m_FSM.Change2BeAtkBeHavior();
                    }
                }

                iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam);
            }

            if (iCmd == 1)
            {
                if (pBeAtcker.gameObject.transform.tag != "Monster")
                {
                    return;
                }

                CNPCEntity pNPC = (CNPCEntity)pBeAtcker;
                if (pNPC.m_FSM == null)
                {
                    return;
                }

                if (pNPC.m_FSM.IsInBehavior(BehaviorType.EState_Suspension))
                {
                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam, 0.1f);

                    pNPC.m_FSM.ChangeBeHavior(BehaviorType.EState_Suspension, 0);
                }
                else
                {
                    pNPC.m_FSM.Change2BeAtkBeHavior();

                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam);
                }
            }

            if (iCmd == 2)
            {
                if (pBeAtcker.gameObject.transform.tag != "Monster")
                {
                    return;
                }

                CNPCEntity pNPC = (CNPCEntity)pBeAtcker;
                if (pNPC.m_FSM == null)
                {
                    return;
                }

                if (pNPC.m_FSM.IsInBehavior(BehaviorType.EState_Suspension))
                {
                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam, 0.1f);
                }
                else
                {
                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam, float.Parse(strActEffect.Split('|')[2]));
                }

                pNPC.m_FSM.ChangeBeHavior(BehaviorType.EState_Suspension, 0);
            }

            if (iCmd == 3)
            {
                if (pBeAtcker.gameObject.transform.tag != "Monster")
                {
                    return;
                }

                CNPCEntity pNPC = (CNPCEntity)pBeAtcker;
                if (pNPC.m_FSM == null)
                {
                    return;
                }

                if (pNPC.m_FSM.IsInBehavior(BehaviorType.EState_Suspension))
                {
                    pNPC.m_FSM.ChangeBeHavior(BehaviorType.EState_Suspension, 0);
                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject, fParam, 0.1f);

                    CtrolAnimation pCtrlAnim = pNPC.gameObject.GetComponent <CtrolAnimation>();
                    pCtrlAnim.SetPlaySpeed(0.01f);
                }


                else
                {
                    iTween.MoveToMy(pBeAtcker.gameObject, m_pOwner.gameObject,
                                    (fParam + 3) / Vector3.Distance(m_pOwner.gameObject.transform.position,
                                                                    pBeAtcker.gameObject.transform.position));
                }
            }

            if (iCmd == 4)
            {
                if (pBeAtcker.gameObject.transform.tag != "Monster")
                {
                    return;
                }

                CNPCEntity pNPC = (CNPCEntity)pBeAtcker;
                if (pNPC.m_FSM == null)
                {
                    return;
                }

                CtrolAnimation pCtrlAnim = pNPC.gameObject.GetComponent <CtrolAnimation>();
                if (pNPC.m_FSM.IsInBehavior(BehaviorType.EState_Suspension))
                {
                    pCtrlAnim.SetPlaySpeed(0.001f);
                }
            }

            PlayBeAttackEffect(pBeAtcker, "effect/spark 04");
        }
    }
Esempio n. 21
0
 //----------------------------------------------------------------------------------
 // 生物击杀
 //----------------------------------------------------------------------------------
 public virtual void OnKill(CSceneEntity pTarget)
 {
 }
Esempio n. 22
0
 public void InitCombat(CSceneEntity pOwer)
 {
     m_pOwner = pOwer;
 }
Esempio n. 23
0
 public override void OnKill(CSceneEntity pTarget)
 {
 }
Esempio n. 24
0
 public CombatHandler()
 {
     m_pOwner = null;
 }
Esempio n. 25
0
 public void ExpReward(CSceneEntity pReward, bool bKill)
 {
 }
Esempio n. 26
0
 public override void OnBeAttacked(CSceneEntity pSrc, CSkill pSkill, bool bHited, bool bBlock, bool bCrited)
 {
 }
Esempio n. 27
0
 public override void InitFSM(CSceneEntity pNPC)
 {
     m_pOwner = pNPC;
     m_norAttack.InitFSM(pNPC);
     m_actAttack.InitFSM(pNPC);
 }