Exemplo n.º 1
0
    bool IsInRange()
    {
        // 自己追敌相信客户端;
        if (!GameController.IsConntrller(Owner))
        {
            return(false);
        }
        Character skillTarget = mSkillContext.SkillTarget;

        if (skillTarget == null)
        {
            return(true);
        }
        float maxDist  = mSkillInfo.maxDistance;
        float distance = SkillUtility.GetDistance(Owner, mSkillContext.SkillTarget, DistanceCalcType.OuterB);

        if (distance > maxDist)
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 2
0
    bool IsInRange()
    {
        // 主角追敌相信客户端;
        if (Owner.Type == CharacterType.Player)
        {
            return(false);
        }
        Character skillTarget = mSkillContext.SkillTarget;

        if (skillTarget == null)
        {
            return(true);
        }
        float maxDist  = mSkillInfo.maxDistance;
        float distance = SkillUtility.GetDistance(Owner, mSkillContext.SkillTarget, DistanceCalcType.OuterB);

        if (distance > maxDist)
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 3
0
    public void UpdateVisible(Character cha)
    {
        uint index = GetCellIndex(cha.Position);

        if (index != cha.mVisibleIndex)
        {
            UpdateCellIndex(cha.mVisibleIndex, index, cha);
            cha.mVisibleIndex = index;
        }

        for (int i = cha.mVisibleObjs.Count - 1; i >= 0; --i)
        {
            Character visibleCha = cha.mVisibleObjs[i];
            if (SkillUtility.GetDistance(cha, visibleCha, DistanceCalcType.Center) > mScnList.viewDist)
            {
                int       lastIndex = cha.mVisibleObjs.Count - 1;
                Character tmp       = visibleCha;
                cha.mVisibleObjs[i]         = cha.mVisibleObjs[lastIndex];
                cha.mVisibleObjs[lastIndex] = tmp;

                cha.mVisibleObjs.RemoveAt(lastIndex);

                cha.OnExitView(tmp);

                tmp.mVisibleObjs.Remove(cha);
                tmp.OnExitView(cha);
            }
        }

        int     minIndexX, minIndexZ;
        int     maxIindexX, maxIndexZ;
        Vector3 minPos   = cha.Position - mScnList.viewDist;
        Vector3 maxPos   = cha.Position + mScnList.viewDist;
        uint    minIndex = GetCellIndex(minPos);
        uint    maxIndex = GetCellIndex(maxPos);

        DecodeCellIndex(minIndex, out minIndexX, out minIndexZ);
        DecodeCellIndex(maxIndex, out maxIindexX, out maxIndexZ);

        for (int x = minIndexX; x <= maxIindexX; ++x)
        {
            for (int z = minIndexZ; z <= maxIndexZ; ++z)
            {
                uint idx = EncodeCellIndex(x, z);

                List <Character> visibles;
                if (!mVisibleObjs.TryGetValue(idx, out visibles))
                {
                    continue;
                }
                for (int i = 0; i < visibles.Count; ++i)
                {
                    Character c = visibles[i];
                    if (SkillUtility.GetDistance(cha, c, DistanceCalcType.Center) <= mScnList.viewDist)
                    {
                        if (cha.mVisibleObjs.Contains(c) || c == cha)
                        {
                            continue;
                        }
                        cha.mVisibleObjs.Add(c);
                        c.mVisibleObjs.Add(cha);

                        cha.OnEnterView(c);
                        c.OnEnterView(cha);
                    }
                }
            }
        }
    }