예제 #1
0
    //查找dis范围内与dir夹角最小的actor
    public sdActorInterface FindNearestAngle(sdActorInterface actor, HeaderProto.ESkillObjType objType, Vector3 dir, float dis, float angle)
    {
        sdActorInterface        ret = null;
        List <sdActorInterface> lst = new List <sdActorInterface>();

        lst = GetTargetActor(actor, objType, true);
        float fcos = Mathf.Cos(angle / 180.0f * Mathf.PI);

        for (int index = 0; index < lst.Count; ++index)
        {
            sdActorInterface target    = lst[index];
            Vector3          targetDir = target.transform.position - actor.transform.position;
            if (targetDir.magnitude > dis)
            {
                continue;
            }
            targetDir.y = 0;
            targetDir.Normalize();
            Vector3 faceDir = dir;
            faceDir.y = 0;
            faceDir.Normalize();
            float value = Vector3.Dot(targetDir, faceDir);
            if (value > fcos)
            {
                fcos = value;
                ret  = lst[index];
            }
        }
        return(ret);
    }
예제 #2
0
    // 摇杆模式下施放技能时辅助调整方向aa
    protected void JoyStickCastSkill(sdSkill s)
    {
        // 翻滚技能不使用辅助施放aaa
        if (s.id == 1002)
        {
            return;
        }

        // 自动选取朝向上的怪物aaaa
        HeaderProto.ESkillObjType objType = 0;
        if (statePointer.bPassive)
        {
            sdBaseState state = s.GetFirstValidAction();
            objType = (HeaderProto.ESkillObjType)state.stateData["byTargetType"];
        }
        else
        {
            objType = (HeaderProto.ESkillObjType)statePointer.stateData["byTargetType"];
        }

        float xbias = 0.0f;
        float ybias = 0.0f;

        sdGameLevel.instance.mainCharMoveControl(out xbias, out ybias);

        sdActorInterface actor    = null;
        bool             bTurnDir = false;

        // 释放技能前,检查下方向键方向范围内是否有目标,如果有就转向释放技能,没有就不转向aaa
        if (Mathf.Abs(xbias) > 0.1f || Mathf.Abs(ybias) > 0.1f)
        {
            Vector3 worldDir = Vector3.right * xbias + Vector3.forward * ybias;
            worldDir.y = 0.0f;
            worldDir.Normalize();
            actor = sdGameLevel.instance.actorMgr.FindNearestAngle(_gameActor, objType, worldDir, 5.0f, 80.0f);
            if (actor != null)
            {
                //_gameActor._moveVector = worldDir;
                _gameActor.TargetFaceDirection = worldDir;
                bTurnDir = true;
            }
        }

        // 在角色当前方向上寻找最小夹角的目标aaa
        if (!bTurnDir)
        {
            actor = sdGameLevel.instance.actorMgr.FindNearestAngle(_gameActor, objType, _gameActor.GetDirection(), 5.0f, 180.0f);
            if (actor != null)
            {
                Vector3 dir = actor.transform.position - _gameActor.transform.position;
                dir.y = 0;
                dir.Normalize();
                _gameActor.TargetFaceDirection = dir;
            }
        }
    }
예제 #3
0
    sdActorInterface        FindOneActor()
    {
        Vector3 center = colliShape.point;
        float   radius = colliShape.radius;

        if (colliShape.type == ShapeType.eCapsule)
        {
            center = colliShape.point + colliShape.dir * colliShape.length * 0.5f;
            radius = colliShape.length * 0.5f + colliShape.radius;
        }
        HeaderProto.ESkillObjType objType  = (HeaderProto.ESkillObjType)((int)info["byTargetType"]);
        List <sdActorInterface>   lstActor = sdGameLevel.instance.actorMgr.FindActor(castActor, objType, center, new Vector3(0, 0, 1), 1, 0, radius, true);

        if (lstActor == null)
        {
            return(null);
        }
        if (colliShape.type == ShapeType.eCapsule)
        {
            sdCapsuleShape actorShape = new sdCapsuleShape();
            for (int i = 0; i < lstActor.Count; i++)
            {
                sdActorInterface actor = lstActor[i];
                if (!actor.IsCanSummonAttack(uniqueID))
                {
                    continue;
                }
                if (actor.GetComponent <Collider>() != null)
                {
                    if (actor.GetComponent <Collider>().GetType() == typeof(CharacterController))
                    {
                        actorShape.SetInfo(actor.GetComponent <Collider>() as CharacterController);

                        if (actorShape.IsIntersect(colliShape))
                        {
                            return(actor);
                        }
                    }
                }
            }
        }
        else if (colliShape.type == ShapeType.eSphere)
        {
            if (lstActor.Count > 0)
            {
                return(lstActor[0]);
            }
        }
        return(null);
    }
예제 #4
0
    List <sdActorInterface> FindActor()
    {
        Vector3 center = colliShape.point;
        float   radius = colliShape.radius;

        if (colliShape.type == ShapeType.eCapsule)
        {
            center = colliShape.point + colliShape.dir * colliShape.length * 0.5f;
            radius = colliShape.length * 0.5f + colliShape.radius;
        }
        HeaderProto.ESkillObjType objType  = (HeaderProto.ESkillObjType)info["byTargetType"];
        List <sdActorInterface>   lstActor = sdGameLevel.instance.actorMgr.FindActor(castActor, objType, center, new Vector3(0, 0, 1), 1, 0, radius, true);

        if (lstActor == null)
        {
            return(null);
        }
        if (colliShape.type == ShapeType.eCapsule)
        {
            List <sdActorInterface> retActor   = new List <sdActorInterface>();
            sdCapsuleShape          actorShape = new sdCapsuleShape();
            for (int i = 0; i < lstActor.Count; i++)
            {
                sdActorInterface actor = lstActor[i];
                if (actor.GetComponent <Collider>() != null)
                {
                    if (actor.GetComponent <Collider>().GetType() == typeof(CharacterController))
                    {
                        actorShape.SetInfo(actor.GetComponent <Collider>() as CharacterController);
                        if (colliShape.IsIntersect(actorShape))
                        {
                            retActor.Add(actor);
                        }
                    }
                }
            }
            return(retActor);
        }
        else if (colliShape.type == ShapeType.eSphere)
        {
            return(lstActor);
        }
        return(null);
        //if(Physics.SphereCastAll(point,cc.radius,dir,halfheight*2.0f))
    }
예제 #5
0
    // 更新触发状态(继承自sdBehaviourState)aa
    public override void UpdateState()
    {
        if (mIsInState != true)
        {
            return;
        }

        if (mCurrentCount == 0)
        {
            return;
        }

        mCurrentDelayTime -= Time.deltaTime;
        if (mCurrentDelayTime <= 0.0f)
        {
            // 当前技能不存在则随机一个技能aa
            if (mCurrentSkillID == -1)
            {
                mCurrentSkillID = RandomSkill();
            }

            // 检查技能范围,尝试释放技能aa
            bool bCastSkill = false;
            if (mCurrentSkillID > 0)
            {
                MonsterAutoFight kMonsterAutoFight = mBehaviourAdvancedState.MonsterAutoFightComponent;
                sdGameMonster    kMonster          = kMonsterAutoFight.Monster;

                if (mDetectDistance)
                {
                    sdSkill kSkill = kMonster.skillTree.getSkill(mCurrentSkillID);
                    if (kSkill != null)
                    {
                        sdBaseState kState    = kSkill.actionStateList[0];
                        float       fDistance = (int)kState.stateData["CastDistance"] * 0.001f;
                        HeaderProto.ESkillObjType eTergetType = (HeaderProto.ESkillObjType)kState.stateData["byTargetType"];

                        float fCurrentDistance = 0.0f;
                        sdBehaviourStateBlock kBehaviourStateBlock = mBehaviourAdvancedState.BehaviourStateBlock;
                        if (eTergetType == HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY)
                        {
                            fCurrentDistance = kBehaviourStateBlock.UpdateDistanceOfNearestEnemy(mBehaviourAdvancedState);
                        }
                        else
                        {
                            fCurrentDistance = kBehaviourStateBlock.UpdateDistanceOfNearestFriend(mBehaviourAdvancedState);
                        }

                        if (fCurrentDistance < fDistance)
                        {
                            kMonster.CastSkill(mCurrentSkillID);
                            bCastSkill = true;
                        }
                    }
                }
                else
                {
                    kMonster.CastSkill(mCurrentSkillID);
                    bCastSkill = true;
                }
            }

            // 释放技能成功则延迟一个mIntervalTime,否则仅仅延迟2s检查一次直到释放成功aa
            if (bCastSkill)
            {
                mCurrentSkillID   = -1;
                mCurrentDelayTime = mIntervalTime;

                --mCurrentCount;
            }
            else
            {
                mCurrentDelayTime = 2.0f;
            }
        }
    }
예제 #6
0
    public List <sdActorInterface> FindActor(
        sdActorInterface actor,
        HeaderProto.ESkillObjType itt,
        Vector3 vPos,
        Vector3 vDir,
        int strikeType,
        int strikeAngle,
        float strikeDis,
        bool bActive
        )
    {
        List <sdActorInterface> lstActor = GetTargetActor(actor, itt, bActive);

        if (lstActor == null)
        {
            return(null);
        }
        if (lstActor.Count == 0)
        {
            return(null);
        }
        List <sdActorInterface> retList = new List <sdActorInterface>();

        foreach (sdActorInterface a in lstActor)
        {
            if ((a != null) &&
                a.IsActive() &&
                (a.GetCurrentHP() > 0))
            {
                bool hit = false;
                if (strikeType == 5)
                {
                    hit = SDGlobal.CheckHit(
                        vPos,
                        vDir,
                        strikeDis, strikeAngle * 0.5f,
                        a.transform.position,
                        a.getRadius());
                }
                else if (strikeType == 1)
                {
                    hit = SDGlobal.CheckRoundHit(
                        vPos,
                        strikeDis,
                        a.transform.position,
                        a.getRadius());
                }
                else if (strikeType == 7)
                {
                    hit = SDGlobal.CheckBoxHit(
                        vPos,
                        vDir,
                        strikeDis, strikeAngle * 0.001f,
                        a.transform.position,
                        a.getRadius());
                }
                if (hit)
                {
                    retList.Add(a);
                }
            }
        }
        return(retList);
    }
예제 #7
0
    public sdActorInterface        FindNearestActor(
        sdActorInterface actor,
        HeaderProto.ESkillObjType itt,
        Vector3 vPos,
        Vector3 vDir,
        int strikeType,
        int strikeAngle,
        float strikeDis,
        bool bActive)
    {
        List <sdActorInterface> lstActor = GetTargetActor(actor, itt, bActive);

        if (lstActor == null)
        {
            return(null);
        }
        if (lstActor.Count == 0)
        {
            return(null);
        }

        float                   fCurrentDis = 99999.0f;
        sdActorInterface        ret         = null;
        List <sdActorInterface> retList     = new List <sdActorInterface>();

        foreach (sdActorInterface a in lstActor)
        {
            if ((a != null) &&
                (a.GetCurrentHP() > 0) &&
                a.actorType != ActorType.AT_Static)
            {
                bool hit = false;
                if (strikeType == 5)
                {
                    hit = SDGlobal.CheckHit(
                        vPos,
                        vDir,
                        strikeDis, strikeAngle * 0.5f,
                        a.transform.position,
                        a.getRadius());
                }
                else if (strikeType == 1)
                {
                    hit = SDGlobal.CheckRoundHit(
                        vPos,
                        strikeDis,
                        a.transform.position,
                        a.getRadius());
                }
                else if (strikeType == 7)
                {
                    hit = SDGlobal.CheckBoxHit(
                        vPos,
                        vDir,
                        strikeDis, strikeAngle * 0.001f,
                        a.transform.position,
                        a.getRadius());
                }
                if (hit)
                {
                    Vector3 v = a.transform.position - vPos;
                    if (fCurrentDis > v.magnitude)
                    {
                        fCurrentDis = v.magnitude;
                        ret         = a;
                    }
                }
            }
        }
        return(ret);
    }
예제 #8
0
    public List <sdActorInterface> GetTargetActor(sdActorInterface actor, HeaderProto.ESkillObjType itt, bool bActive)
    {
        if (actor == null)
        {
            return(null);
        }
        int iGroupID = (int)actor.GetGroupID();
        List <sdActorInterface> lst = new List <sdActorInterface>();

        GroupType[,] gtArray = sdConfDataMgr.Instance().m_Group;

        switch ((int)itt)
        {
        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_SELF: {
            lst.Add(actor);
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_TEAM: {
            GetGroupActor(iGroupID, ref lst, bActive);
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_TEAM_EXCLOUD_SELF: {
            GetGroupActor(iGroupID, ref lst, bActive);
            lst.Remove(actor);
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_FRIENDLY_ROLE: {
            for (int i = 0; i <= (int)GroupIDType.GIT_MonsterB; i++)
            {
                GroupType t = gtArray[iGroupID, i];
                if (t == GroupType.GT_Friend)
                {
                    GetGroupActor(i, ref lst, bActive);
                }
            }
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_FRIENDLY: {
            for (int i = 0; i <= (int)GroupIDType.GIT_MonsterB; i++)
            {
                GroupType t = gtArray[iGroupID, i];
                if (t == GroupType.GT_Friend)
                {
                    GetGroupActor(i, ref lst, bActive);
                }
            }
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_ENEMY: {
            for (int i = 0; i <= (int)GroupIDType.GIT_MonsterB; i++)
            {
                GroupType t = gtArray[iGroupID, i];
                if (t == GroupType.GT_Enemy)
                {
                    GetGroupActor(i, ref lst, bActive);
                }
            }
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_ALL: {
            for (int i = 0; i <= (int)GroupIDType.GIT_MonsterB; i++)
            {
                GetGroupActor(i, ref lst, bActive);
            }
        } break;

        case (int)HeaderProto.ESkillObjType.SKILL_OBJ_ALL_EXCLOUD_SELF: {
            for (int i = 0; i <= (int)GroupIDType.GIT_MonsterB; i++)
            {
                GetGroupActor(i, ref lst, bActive);
            }
            lst.Remove(actor);
        } break;
        }

        return(lst);
    }
예제 #9
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);
        }
    }