public override EntityParent GetTargetBySkillID(int skillID, TargetRangeType rangeType, float rushDistance = 0f)
        {
            Skill skill = DataReader <Skill> .Get(skillID);

            if (skill == null)
            {
                return(null);
            }
            float outerDistance   = -1f;
            float innerDistance   = 0f;
            int   angle           = -1;
            int   forwardFixAngle = 0;

            switch (rangeType)
            {
            case TargetRangeType.SkillRange:
                outerDistance = (float)skill.reach.get_Item(0) * 0.01f + rushDistance;
                if (skill.reach.get_Count() >= 2)
                {
                    angle = skill.reach.get_Item(1);
                }
                if (skill.reach.get_Count() >= 3)
                {
                    forwardFixAngle = skill.reach.get_Item(2);
                }
                innerDistance = skill.reachLimit * 0.01f;
                break;

            case TargetRangeType.Configure:
                outerDistance = (float)DataReader <Monster> .Get(this.owner.TypeID).range;

                break;
            }
            return(this.owner.GetTarget(rangeType, skill.targetType, outerDistance, innerDistance, angle, forwardFixAngle, skill.antiaircraft, skill.getTarget));
        }
Esempio n. 2
0
        public bool CheckTargetBySkillID(EntityParent entity, int skillID, TargetRangeType rangeType, float rushDistance = 0f)
        {
            if (entity == null)
            {
                return(false);
            }
            Skill skill = DataReader <Skill> .Get(skillID);

            if (skill == null)
            {
                return(false);
            }
            float outerDistance = -1f;
            int   angle         = -1;
            float innerDistance = 0f;

            if (rangeType != TargetRangeType.SkillRange)
            {
                if (rangeType != TargetRangeType.Configure)
                {
                }
            }
            else
            {
                outerDistance = ((float)skill.reach.get_Item(0) + rushDistance) * 0.01f;
                if (skill.reach.get_Count() >= 2)
                {
                    angle = skill.reach.get_Item(1);
                }
                innerDistance = skill.reachLimit * 0.01f;
            }
            return(this.owner.CheckTarget(entity, rangeType, skill.targetType, outerDistance, innerDistance, angle, skill.antiaircraft));
        }
Esempio n. 3
0
        public bool SetTargetFromLockOnTargetBySkillID(int skillID, TargetRangeType rangeType, bool isUseRushDistance)
        {
            if (EntityWorld.Instance.LockOnTarget == null)
            {
                return(false);
            }
            if (!EntityWorld.Instance.LockOnTarget.Actor)
            {
                return(false);
            }
            if (this.owner.GetSkillManager() == null)
            {
                return(false);
            }
            if (!DataReader <Skill> .Contains(skillID))
            {
                return(false);
            }
            float rushDistance = (float)((!isUseRushDistance) ? 0 : DataReader <Skill> .Get(skillID).rush);

            if (!this.owner.GetSkillManager().CheckTargetBySkillID(EntityWorld.Instance.LockOnTarget, skillID, rangeType, rushDistance))
            {
                return(false);
            }
            this.owner.AITarget = EntityWorld.Instance.LockOnTarget;
            return(true);
        }
Esempio n. 4
0
        public override bool Proc(IAIProc theOwner)
        {
            TargetRangeType rangeType = TargetRangeType.World;

            if (this.isUseConfigRange)
            {
                rangeType = TargetRangeType.Configure;
            }
            else if (this.isUseSkillRange)
            {
                rangeType = TargetRangeType.SkillRange;
            }
            return(theOwner.SetTargetBySkillIndex(this.skillIndex, rangeType, false, 50f));
        }
Esempio n. 5
0
        public virtual EntityParent GetTargetBySkillID(int skillID, TargetRangeType rangeType, float rushDistance = 0f)
        {
            Skill skill = DataReader <Skill> .Get(skillID);

            if (skill == null)
            {
                return(null);
            }
            float outerDistance   = -1f;
            float innerDistance   = 0f;
            int   angle           = -1;
            int   forwardFixAngle = 0;

            switch (rangeType)
            {
            case TargetRangeType.SkillRange:
                outerDistance = ((float)skill.reach.get_Item(0) + rushDistance) * 0.01f;
                if (skill.reach.get_Count() >= 2)
                {
                    angle = skill.reach.get_Item(1);
                }
                if (skill.reach.get_Count() >= 3)
                {
                    forwardFixAngle = skill.reach.get_Item(2);
                }
                innerDistance = skill.reachLimit * 0.01f;
                break;

            case TargetRangeType.Configure:
                return(null);
            }
            EntityParent target = this.owner.GetTarget(rangeType, skill.targetType, outerDistance, innerDistance, angle, forwardFixAngle, skill.antiaircraft, skill.getTarget);
            int          num    = 0;

            while (rangeType != TargetRangeType.World && num < skill.angle.get_Count() && target == null)
            {
                target = this.owner.GetTarget(rangeType, skill.targetType, outerDistance, innerDistance, skill.angle.get_Item(num), 0, skill.antiaircraft, skill.getTarget);
                num++;
            }
            return(target);
        }
Esempio n. 6
0
        public bool SetTargetBySkillID(int skillID, TargetRangeType rangeType, bool isUseRushDistance, float reuseRate = -1f)
        {
            if (this.owner.GetSkillManager() == null)
            {
                return(false);
            }
            if (!DataReader <Skill> .Contains(skillID))
            {
                return(false);
            }
            bool         flag         = (float)Random.Range(1, 101) < reuseRate;
            EntityParent aITarget     = this.owner.AITarget;
            float        rushDistance = (float)((!isUseRushDistance) ? 0 : DataReader <Skill> .Get(skillID).rush);
            bool         flag2        = this.owner.GetSkillManager().SetTargetBySkillID(skillID, rangeType, rushDistance);

            if (flag2 && flag && this.owner.GetSkillManager().CheckTargetBySkillID(aITarget, skillID, rangeType, rushDistance))
            {
                this.owner.AITarget = aITarget;
            }
            return(flag2);
        }
Esempio n. 7
0
        public bool PackTryToPressIconByLockOnTarget(int skillIndex, int count, int interval, int random, ComparisonOperator comparisonOperator1, float range1, ComparisonOperator comparisonOperator2, float range2, LogicalOperator logicalOperator, TargetRangeType rangeType)
        {
            int num;

            if (!this.GetSkillIDBySkillIndex(skillIndex, out num))
            {
                return(false);
            }
            if (!this.SetTargetFromLockOnTargetBySkillID(num, rangeType, true))
            {
                return(false);
            }
            if (comparisonOperator1 == ComparisonOperator.None && comparisonOperator2 == ComparisonOperator.None)
            {
                if (!this.CheckTargetDistanceBySkillIndex(skillIndex))
                {
                    return(false);
                }
            }
            else if (!this.CheckTargetDistance(comparisonOperator1, range1, comparisonOperator2, range2, logicalOperator))
            {
                return(false);
            }
            Skill skill = DataReader <Skill> .Get(num);

            return(this.owner.ActPoint + skill.actionPoint + this.owner.GetSkillActionPointVariationByType(skill.skilltype) >= 0 && this.CheckRandom(random) && this.PressIcon(skillIndex, count, interval));
        }
Esempio n. 8
0
 public bool SetTargetBySkillID(int skillID, TargetRangeType rangeType, float rushDistance = 0f)
 {
     this.owner.AITarget = this.GetTargetBySkillID(skillID, rangeType, rushDistance);
     return(this.owner.AITarget != null);
 }
Esempio n. 9
0
    public bool IsInSkillRange(int skillId, uint targetId)
    {
        var spellData = SkillAction.dataMap[SkillData.dataMap[skillId].skillAction[0]];

        // 目标类型 0 敌人, 1 自己  2 队友  3  友方
        //int targetType = spellData.targetType;
        // 攻击范围类型。  0  扇形范围 1  圆形范围, 2, 单体。 3  直线范围 4 前方范围
        int targetRangeType = spellData.targetRangeType;
        // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表
        List <float> targetRangeParam = spellData.targetRangeParam;
        // 最大攻击人数
        //int maxTargetCount = spellData.maxTargetCount;
        // 触发伤害特效帧数
        //int damageTriggerFrame = spellData.damageTriggerFrame;

        List <List <uint> > entities  = new List <List <uint> >();
        TargetRangeType     rangeType = (TargetRangeType)targetRangeType;

        switch (rangeType)
        {
        case TargetRangeType.CircleRange:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                entities = MogoUtils.GetEntitiesInRange(theOwner.Transform, radius);
            }
            break;

        case TargetRangeType.SectorRange:
            if (targetRangeParam.Count >= 2)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = targetRangeParam[1];
                entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.SingeTarget:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = 150;
                entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.WorldRange:
            if (targetRangeParam.Count >= 4)
            {
                float x1      = targetRangeParam[0] * 0.01f;
                float y1      = targetRangeParam[1] * 0.01f;
                float x2      = targetRangeParam[2] * 0.01f;
                float y2      = targetRangeParam[3] * 0.01f;
                float minX    = Math.Min(x1, x2);
                float maxX    = Math.Max(x1, x2);
                float minY    = Math.Min(y1, y2);
                float maxY    = Math.Max(y1, y2);
                float radiusX = minX + (maxX - minX) * 0.5f;
                float radiusY = minY + (maxY - minY) * 0.5f;
                float radius  = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f;
                entities = MogoUtils.GetEntitiesInRange(new Vector3(radiusX, 0, radiusY), radius);
            }
            break;

        case TargetRangeType.LineRange:
        default:
            if (targetRangeParam.Count >= 2)
            {
                float length = targetRangeParam[0] * 0.01f;
                float width  = targetRangeParam[1] * 0.01f;
                entities = MogoUtils.GetEntitiesFrontLine(theOwner.Transform, length, theOwner.Transform.forward, width);
            }
            break;
        }
        if (entities.Count < 3)
        {
            return(false);
        }
        if (entities[0].Count > 0 && entities[0].Contains(targetId))
        {
            return(true);
        }
        if (entities[1].Count > 0 && entities[1].Contains(targetId))
        {
            return(true);
        }
        if (entities[2].Count > 0 && entities[2].Contains(targetId))
        {
            return(true);
        }
        return(false);
    }
Esempio n. 10
0
        //---------------------------------------------------------------------------
        // Helper for GetText() test cases
        //---------------------------------------------------------------------------
        internal void GetTextHelper(SampleText sampleText, TargetRangeType callingRangeType, MaxLength maxLengthType, GetResult getResult, Type expectedException)
        {
            int maxLength = 0;
            string actualText = "";
            string expectedText = "";
            TextPatternRange callingRange;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine length of text to get = <<maxLength>>
            TS_CalcMaxLength(maxLengthType, out maxLength, expectedText);

            // Call GetText(<<maxLength>>) <<expectedException>>
            TS_GetText(callingRange, ref actualText, maxLength, expectedException, CheckType.Verification);

            // Validate text is <<getResult>>
            TS_VerifyTextLength(getResult, actualText, expectedText, maxLength, expectedException, CheckType.Verification);
        }
Esempio n. 11
0
        //---------------------------------------------------------------------------
        // Helper for Move() test cases
        //---------------------------------------------------------------------------
        internal void MoveHelper2(SampleText sampleText, TargetRangeType callingRangeType, int count, int result)
        {
            int[] numberOfTextUnits = new int[((int)TextUnit.Document) + 1];
            TextUnit[] supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1];
            TextPatternRange callingRange;

            //  Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);

            // Pre-Condition Determine Count for each TextUnit in document
            TS_CountTextUnits(callingRange, supportedTextUnits, ref numberOfTextUnits);

            // Call Move(<<count>>) (N+1) times where N=# characters in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Character, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# formats in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Format, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# words in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Word, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# lines in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Line, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# paragraphs in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Paragraph, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# pages in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Page, numberOfTextUnits, callingRange, count, result, CheckType.Verification);

            // Call Move(<<count>>) (N+1) times where N=# document in doc, verify result = <<result>>
            TS_MoveNTimes(TextUnit.Document, numberOfTextUnits, callingRange, count, result, CheckType.Verification);
        }
Esempio n. 12
0
        //---------------------------------------------------------------------------
        // Helper for CompareEndpoints() test cases
        //---------------------------------------------------------------------------
        internal void CompareEndpointsHelper(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType argumentRangeType, ValueComparison startStart, ValueComparison startEnd, ValueComparison endStart, ValueComparison endEnd, Type expectedException)
        {
            TextPatternRange callingRange = null;
            TextPatternRange argumentRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, true, CheckType.Verification);

            // Pre-Condition Create argument range = <<argumentRangeType>>
            TS_CreateRange(out argumentRange, argumentRangeType, callingRange, true, CheckType.Verification);

            // Verify CompareEndPoints(start,start) <<startStart>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.Start, argumentRange, 
                                              TextPatternRangeEndpoint.Start, startStart, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(start,  end) <<startEnd>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.Start, argumentRange,
                                              TextPatternRangeEndpoint.End,   startEnd, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(  end,start) <<endStart>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.End,   argumentRange,
                                              TextPatternRangeEndpoint.Start, endStart, expectedException, CheckType.Verification);

            // Verify CompareEndPoints(  end,  end) <<endEnd>> zero
            TS_CompareEndpoints(callingRange, TextPatternRangeEndpoint.End,   argumentRange, 
                                              TextPatternRangeEndpoint.End,   endEnd, expectedException, CheckType.Verification);
        }
Esempio n. 13
0
        //---------------------------------------------------------------------------
        // Helper for GetAttributeValue() test cases
        //---------------------------------------------------------------------------
        internal void GetAttributeValueHelper(SampleText sampleText, TargetRangeType callingRangeType, AttributeType attribType, GetResult getResult, Type expectedException)
        {
            IDictionary attributes = null;
            TextPatternRange callingRange;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Identify & use <<attribType>>
            TS_GetAttributeValues(callingRange, out attributes, attribType, CheckType.Verification);

            // For each attribute identified, GetAttributeValue() returns <<getResult>>
            TS_GetAttributeValue(callingRange, attributes, attribType, getResult, expectedException, CheckType.Verification);
        }
Esempio n. 14
0
        //---------------------------------------------------------------------------
        // Helper for RangeFromPoint() test cases
        //---------------------------------------------------------------------------
        internal void RangeFromPointHelper2(SampleText sampleText, bool isMultiLineExpected, TargetRangeType rangeType, BoundingRectangleLocation pointLocation, RangeCompare rangeCompare)
        {
            Point screenLocation;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange = null;
            TextPatternRange rangeFromPt = null;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLineExpected, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range equal to <<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Scroll range into view
            // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
            // We need to make sure we scroll off the view so we can scroll back on it.
            // Otherwise the second scrollIntoView call may be a no-op...
            Range_ScrollIntoView(callingRange, false, null, CheckType.Verification);
            TS_ScrollIntoView(callingRange, true, null, CheckType.Verification);

            // Pre-Condition Call GetBoundingRectangles() on that range
            TS_GetBoundingRectangles(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Pre-Condition Create a point <<pointLocation>> of bounding rect
            TS_CreatePoint(ref callingRange, boundRects, out screenLocation, pointLocation, CheckType.Verification);

            // Call RangeFromPoint on point without errors
            TS_RangeFromPoint(ref rangeFromPt, screenLocation, null, CheckType.Verification);

            // Verify that range returned is <<rangeCompare>>
            TS_CompareRanges(callingRange, rangeFromPt, rangeCompare, null, CheckType.Verification);
        }
Esempio n. 15
0
        //---------------------------------------------------------------------------
        // Helper for GetSelection() test cases
        //---------------------------------------------------------------------------
        internal void GetSelectionHelper(SampleText sampleText, SupportedTextSelection supportedTextSelection, TargetRangeType rangeType, bool expectMatch, uint arrayCount, Type expectedException)
        {
            bool               isEqual       = false;
            string             actualText    = "";
            TextPatternRange   callingRange  = null;
            TextPatternRange[] selectedRange = null;

            // Pre-Condition Verify SupportedTextSelection=<<supportedTextSelection>>
            TS_VerifySupportedTextSelection(supportedTextSelection, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>>
            TS_SetText(sampleText, out actualText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range=<<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.Verification);

            // Call Select()
            TS_Select(callingRange, null, CheckType.Verification);

            // Call GetSelection() on calling range
            TS_GetSelection(ref selectedRange, arrayCount, expectedException, CheckType.Verification);

            // Compare selected range and calling range, comparison should = <<expectMatch>>
            TS_Compare(callingRange, selectedRange[0], ref isEqual, expectMatch, null, CheckType.Verification);
        }
Esempio n. 16
0
        //---------------------------------------------------------------------------
        // Helper for ScrollIntoView() test cases
        //---------------------------------------------------------------------------
        internal void ScrollIntoViewHelper(SampleText sampleText, TargetRangeType callingRangeType, bool alignToTop)
        {
            string actualText = "";
            string expectedText = "";
            TextPatternRange callingRange;
            TextPatternRange[] visibleRanges = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Get text from calling range
            TS_GetText(callingRange, ref expectedText, -1, null, CheckType.Verification);

            // Pre-Condition SetFocus to control containing TextPattern
            TS_SetFocus(CheckType.Verification);

            // Call ScrollIntoView(<<alignToTop>>)
            TS_ScrollIntoView(callingRange, alignToTop, null, CheckType.Verification);

            // Call GetVisibleRange() on TextPattern
            TS_GetVisibleRanges(ref visibleRanges, null, CheckType.Verification);

            // Call GetText() on FIRST visible range (post V1, this should validate against each/all ranges)
            TS_GetText(visibleRanges[0], ref actualText, -1, null, CheckType.Verification);

            // Verify visible range is within expected range
            TS_TextWithin("ScrollIntoView()", actualText, expectedText, CheckType.Verification);
        }
Esempio n. 17
0
        //---------------------------------------------------------------------------
        // TS_CreateRange, has no support for returning offsets
        //---------------------------------------------------------------------------
        internal void TS_CreateRange(out TextPatternRange range, TargetRangeType rangeType, TextPatternRange rangeToClone, bool trimRange, CheckType checkType)
        {
            int startOffset = 0;
            int endOffset = 0;

            CreateRange(out range, rangeType, out startOffset, out endOffset, rangeToClone, checkType);

            if ((trimRange == true) && (range != null))
                TextLibrary.TrimRangeCRLF(m_le, range);

            m_TestStep++;
        }
Esempio n. 18
0
        //---------------------------------------------------------------------------
        // Helper for MoveEndpointByRange() test cases
        //---------------------------------------------------------------------------
        internal void ExpandToEnclosingUnitHelper(SampleText sampleText, TargetRangeType callingRangeType)
        {
            string           text               = "";
            TextPatternRange callingRange       = null;
            TextUnit[]       supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1]; ;

            // PreCondition: Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out text, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Character) and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Character, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Format)    and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Format, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Word)      and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Word, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Line)      and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Line, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Praagraph) and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Paragraph, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Page)      and verify results
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Page, text.Length, CheckType.Verification);

            // Clone range and call ExpandToEnclosingUnits(Document)  and verify results   
            TS_ExpandToEnclosingUnits(callingRange, supportedTextUnits, TextUnit.Document, text.Length, CheckType.Verification);
        }
Esempio n. 19
0
        internal void MoveEndpointByRangeHelper1(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType targetRangeType, MoveEPResults result1, MoveEPResults result2, MoveEPResults result3, MoveEPResults result4, Type expectedException)
        {
            TextPatternRange callingRange = null;
            TextPatternRange targetRange = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, true, CheckType.Verification);

            // Pre-Condition Createtarget range = <<targetRangeType>>
            TS_CreateRange(out targetRange, targetRangeType, callingRange, true, CheckType.Verification);

            // Call MoveEndpointByRange(Start,target range,Start) with result = <<result1>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.Start,
                                    targetRange, TextPatternRangeEndpoint.Start,
                                    result1, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(Start,target range,End  ) with result = <<result2>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.Start,
                                   targetRange, TextPatternRangeEndpoint.End,
                                   result2, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(End,  target range,Start) with result = <<result3>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.End,
                                   targetRange, TextPatternRangeEndpoint.Start,
                                   result3, expectedException, CheckType.Verification);

            // Call MoveEndpointByRange(End,  target range,End  ) with result = <<result4>>
            TS_MoveEndpointByRange(callingRange, TextPatternRangeEndpoint.End,
                                   targetRange, TextPatternRangeEndpoint.End,
                                   result4, expectedException, CheckType.Verification);
        }
Esempio n. 20
0
        //---------------------------------------------------------------------------
        // Helper for MoveEndpointByUnit() test cases
        //---------------------------------------------------------------------------
        internal void MoveEndpointByUnitHelper3(SampleText sampleText, TargetRangeType callingRangeType, bool isMultiLineExpected, TextUnit textUnit, TextPatternRangeEndpoint endPoint)
        {
            TextPatternRange callingRange;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLineExpected, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            ThrowMe(CheckType.IncorrectElementConfiguration, "Not impelemented Yet");

            // Pre-Condition Calculate # of random text units to move between 1..8

            // Verify MoveEndpointByUnit(End,  Character,<rand#>) returns <rand#>

            // Verify that the text enclosed is as expected

        }
Esempio n. 21
0
        public bool PackTryToMoveToTargetBySkillTypeAndLockOnTarget(int skillType, int random, TargetRangeType rangeType)
        {
            int skillID;

            return(this.GetSkillIDBySkillType(skillType, out skillID) && this.PackTryToMoveToTargetBySkillIDAndLockOnTarget(skillID, random, rangeType));
        }
Esempio n. 22
0
        internal void CreateEmptyRandomRange(out TextPatternRange range, RangeLocation rangeLoc, TargetRangeType targetRangeType, CheckType checkType)
        {
            int actualCount = 0;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            // Requires non-empty range
            if (IsEmptyRange(documentRange, checkType))
                ThrowMe(checkType, ParseType(targetRangeType) + " requires non-empty range");

            // Get range and text in the range            
            range = null;
            range = Pattern_DocumentRange(checkType);

            // calculate position of random range
            int length = Range_GetText(range).Length;
            int offset = 1 + Helpers.RandomValue(1, length / 4);

            // Create empty range by collapsing endpoint to start
            CreateEmptyRange(out range, RangeLocation.Start, checkType);

            // Now, create the degenerate range            
            switch (rangeLoc)
            {
                case RangeLocation.Start:
                    // Move start (and end) endPoint to location in document
                    // This works because Start EndPoint can never roll past end endPoint (it just rolls with start)
                    Range_MoveEndpointByUnit(range, TextPatternRangeEndpoint.Start, TextUnit.Character,
                            offset, ref actualCount, null, checkType);
                    break;
                case RangeLocation.End:
                    offset = 0 - offset; // was length - offset. This seems to be correct
                    // Move start (and end) endPoint to location in document
                    // This works because Start EndPoint can never roll past end endPoint (it just rolls with start)
                    Range_MoveEndpointByUnit(range, TextPatternRangeEndpoint.Start, TextUnit.Character,
                            offset, ref actualCount, null, checkType);
                    break;
                default:
                    throw new ArgumentException("TS_CreateEmptyRandomRange() has no support for " + ParseType(rangeLoc));
            }

            // Final check
            if (IsEmptyRange(range, checkType))
                Comment("Created degenerate (empty) range near " + rangeLoc + " of the document");
            else
            {
                ThrowMe(checkType, "TS_CreateEmptyRange() failed to create empty range, text = '" +
                         TrimText(Range_GetText(range), 512) + "'");
            }
        }
Esempio n. 23
0
 /// ---------------------------------------------------------------------------
 /// <summary>Parses values for enum</summary>
 /// ---------------------------------------------------------------------------
 static public string ParseType(TargetRangeType value)
 {
     return ParseType(value.GetType().ToString(), value.ToString());
 }
Esempio n. 24
0
        //---------------------------------------------------------------------------
        // Create range of specific type (random ranges)
        //---------------------------------------------------------------------------
        internal void CreateRamdomRange(TextPatternRange sourceRange, out TextPatternRange targetRange, TargetRangeType targetRangeType, CheckType checkType)
        {
            int startOffset = 0; 
            int endOffset   = 0;
            int length      = _actualText.Length;

            targetRange = null;
            
            // Determine offsets of existing range
            TextPatternRange documentRange = Pattern_DocumentRange(checkType);
            
            Range_CompareEndpoints( sourceRange, TextPatternRangeEndpoint.Start, documentRange, TextPatternRangeEndpoint.Start, ref startOffset, null, checkType );
            Range_CompareEndpoints( sourceRange, TextPatternRangeEndpoint.End,   documentRange, TextPatternRangeEndpoint.End,   ref endOffset,   null, checkType );

            Comment("Calling range is from " + startOffset + " to " + (length + endOffset) + " (characters)" );

            // Adjust offsets
            switch (targetRangeType)
            {
                case TargetRangeType.RandomEndsStart:               //range that ENDs at START of calling range
                    endOffset = startOffset - length;
                    startOffset = 0;
                    break;
                case TargetRangeType.RandomStartStart:              //range that STARTs at START of calling range
                    endOffset   = 0;                                //start endPoint remains unchanged
                    break;
                case TargetRangeType.RandomEndsEnd:                 //range that ENDs at END of calling range
                    startOffset = 0;                                //end endPoint remains unchanges
                    break;
                case TargetRangeType.RandomStartsEnd:               //range that STARTs at END of calling range
                    startOffset = endOffset + length;
                    endOffset   = 0;
                    break;
                default:
                    throw new ArgumentException("CreateRandomRange() has no support for " + ParseType(targetRangeType));
            }

            // Set offsets of target range
            Range_Clone( documentRange, ref targetRange, null, checkType );
            Range_MoveEndpointByUnit( targetRange, TextPatternRangeEndpoint.Start, TextUnit.Character, startOffset, ref startOffset, null, checkType );
            Range_MoveEndpointByUnit( targetRange, TextPatternRangeEndpoint.End,   TextUnit.Character, endOffset,   ref endOffset,   null, checkType );

            Comment("Target range is from " + startOffset + " to " + (length + endOffset) + " (characters)");
        }
Esempio n. 25
0
        //---------------------------------------------------------------------------
        // Helper for Select() test cases
        //---------------------------------------------------------------------------
        internal void SelectHelper(SampleText sampleText, TargetRangeType callingRangeType, Type expectedException)
        {
            string actualText             = "";   
            string expectedText           = "";   // comparison of these strings.
            TextPatternRange callingRange = null;

            // Pre-Condition SetFocus to control containing TextPattern
            TS_SetFocus(CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Select the range
            TS_Select(callingRange, expectedException, CheckType.Verification);

            // Get the text from the selection
            TS_GetTextSelection(ref actualText, CheckType.Verification);

            // Verify the selection is as expected
            TS_IsMatchingText("Select()", actualText, expectedText, true, CheckType.Verification);
        }
Esempio n. 26
0
        internal void CreateMiscRange(TargetRangeType targetRangeType, out TextPatternRange targetRange, CheckType checkType)
        {
            int startOffset = 0;
            int endOffset = 0;
            int actualStartOffset = 0;
            int actualEndOffset = 0;
            string text = "";
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            Range_GetText(documentRange, ref text, -1, null, checkType);

            // Sanity check            
            TrimTrailingCRLF(m_le, ref text);
            if (text.Length == 0)
                ThrowMe(checkType, "Require non-empty document to create range " + Parse(targetRangeType));

            // calculate where range begins/ends
            switch (targetRangeType)
            {
                case TargetRangeType.TwoCharsAdjacent:              //two adjacent characters
                    // Bug 1134054: TextPatternRange.ScrollIntoView fails to scroll horizontally on edit control
                    // So... we'll pick something that will always be in view
                    startOffset = 1;
                    endOffset = 3;
                    break;
                case TargetRangeType.TwoCharsSplitAcrossLine:       //two chracters split across a line break
                    // Bug 1059601: TextPatternRange.GetText(-1) retrieves a string that eliminates \n's in RichEdit 2.0
                    // So... we search for \r instead of \n
                    startOffset = text.IndexOf("\r") - 1;
                    endOffset = startOffset + 3;
                    break;
                default:
                    throw new ArgumentException("CreateMiscRange() has no support for " + ParseType(targetRangeType));
            }

            // sanity check
            if ((startOffset < 0) || (endOffset > text.Length))
                ThrowMe(checkType, "CreateMiscRange is unable to calculate correct start/end (" + startOffset + "," + endOffset + ") for range");

            // Create range
            CreateEmptyRange(out targetRange, RangeLocation.Start, checkType);
            Range_MoveEndpointByUnit(targetRange, TextPatternRangeEndpoint.End, TextUnit.Character, endOffset, ref actualEndOffset, null, checkType);
            Range_MoveEndpointByUnit(targetRange, TextPatternRangeEndpoint.Start, TextUnit.Character, startOffset, ref actualStartOffset, null, checkType);

            // sanity check
            if ((startOffset != actualStartOffset) || (endOffset != actualEndOffset))
            {
                ThrowMe(checkType, "CreateMisMatchRange could not move end points as expected. Expected offsets = " +
                        startOffset + ", " + endOffset + ", actual offsets = " + actualStartOffset + ", " + actualEndOffset);
            }
            else
                Comment("Created range of type " + Parse(targetRangeType));
        }
Esempio n. 27
0
        //---------------------------------------------------------------------------
        // Helper for GetBoundingRectangles() test cases
        //---------------------------------------------------------------------------
        internal void GetBoundingRectanglesHelper(SampleText sampleText, TargetRangeType callingRangeType, bool isMultiLine, ScrollLocation scrollLocation, GetBoundRectResult boundRectResults)
        {
            Rect autoElement;
            Rect[] boundRects = new Rect[0];
            TextPatternRange callingRange;

            // Pre-Condition Control must supports multi-line = <<expectedResult>>
            TS_IsMultiLine(isMultiLine, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Scroll viewport to <<ScrollLocation>>
            TS_ScrollViewPort(scrollLocation, false, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Get Automation Element Bounding Rectangle
            TS_GetAutomationElementBoundingRectangle(out autoElement);

            // Call GetBoundingRectangles()
            TS_GetBoundingRectanglesLite(callingRange, ref boundRects, false, null, CheckType.Verification);

            // Valdiate Bounding Rectangles <<getResult>>
            TS_VerifyWithinRects(autoElement, boundRects, boundRectResults, CheckType.Verification);

        }
Esempio n. 28
0
 internal void CreateRange(out TextPatternRange targetRange, TargetRangeType targetRangeType, TextPatternRange sourceRange, CheckType checkType)
 {
     int startOffset = 0;
     int endOffset   = 0;
     
     CreateRange( out targetRange, targetRangeType, out startOffset, out endOffset, sourceRange, checkType ); 
 }
Esempio n. 29
0
        //---------------------------------------------------------------------------
        // Helper for Move() test cases
        //---------------------------------------------------------------------------
        internal void MoveHelper(SampleText sampleText, TargetRangeType callingRangeType, Count count, Count expectedCount)
        {
            TextUnit[]       supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1];
            int[]            numberOfTextUnits  = new int[((int)TextUnit.Document) + 1];
            TextPatternRange callingRange       = null;
            TextPatternRange documentRange      = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition: Acquire range for entire document
            TS_DocumentRange( ref documentRange, CheckType.IncorrectElementConfiguration );

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);

            // Pre-Condition: Determine Count for each TextUnit in document
            TS_CountTextUnits( documentRange, supportedTextUnits, ref numberOfTextUnits );
            
            // Call Move(<<count>>) for each TextUnit, validiting result is <<result>>
            TS_Move(callingRange, supportedTextUnits, numberOfTextUnits, count, expectedCount, CheckType.Verification);
        }
Esempio n. 30
0
        internal void CreateRange(out TextPatternRange targetRange, TargetRangeType targetRangeType, out int startOffset, out int endOffset, TextPatternRange sourceRange, CheckType checkType)
        {
            TextPattern differentTextPattern = null;

            // Initialize ref params
            targetRange = null;
            startOffset = 0;
            endOffset = 0;

            Comment("ENTERING CreateRange(" + Parse(targetRangeType) + "," + startOffset + "," + endOffset + "," + (sourceRange == null ? null : "<sourceRange>") + ",...)");

            switch (targetRangeType)
            {
                case TargetRangeType.DocumentRange:         // entire document
                    targetRange = Pattern_DocumentRange(checkType);
                    Comment("Created range of type " + Parse(targetRangeType));
                    break;
                case TargetRangeType.Clone:
                    Range_Clone(sourceRange, ref targetRange, null, checkType);
                    Comment("Created range of type " + Parse(targetRangeType));
                    break;
                case TargetRangeType.SameAsCaller:                  //same as calling range
                    if (sourceRange == null)
                        ThrowMe(checkType, "CreateRange(" + ParseType(targetRangeType) + ") cannot succeed, calling range was not passed into method");
                    targetRange = sourceRange;
                    Comment("Created range of type " + Parse(targetRangeType));
                    break;
                case TargetRangeType.Null: //null value
                    targetRange = null;
                    Comment("Created range of type " + Parse(targetRangeType));
                    break;
                case TargetRangeType.EmptyStart:            // EMPTY range at START of document
                    CreateEmptyRange(out targetRange, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.EmptyMiddle:           // EMPTY range in MIDDLE of document
                    CreateEmptyRange(out targetRange, RangeLocation.Middle, checkType);
                    break;
                case TargetRangeType.EmptyEnd:              // EMPTY range at END of document
                    CreateEmptyRange(out targetRange, RangeLocation.End, checkType);
                    break;
                case TargetRangeType.RandomStart:           //RANDOM range at START of document
                    CreateSubRange(out targetRange, RangeLocation.Start, out startOffset, out endOffset, checkType);
                    break;
                case TargetRangeType.RandomMiddle:          //RANDOM range in MIDDLE of document
                    CreateSubRange(out targetRange, RangeLocation.Middle, out startOffset, out endOffset, checkType);
                    break;
                case TargetRangeType.RandomEnd:             //RANDOM range at END of document
                    CreateSubRange(out targetRange, RangeLocation.End,
                                      out startOffset, out endOffset, checkType);
                    break;
                case TargetRangeType.RandomEmptyStart:      //EMPTY range at random location near START of document
                    CreateEmptyRandomRange(out targetRange, RangeLocation.Start, targetRangeType, checkType);
                    break;
                case TargetRangeType.RandomEmptyEnd:        //EMPTY range at random location near END of document
                    CreateEmptyRandomRange(out targetRange, RangeLocation.End, targetRangeType, checkType);
                    break;
                case TargetRangeType.FirstCharacter:        //first character in document
                    CreateTextUnitRange(out targetRange, TextUnit.Character, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.MiddleCharacter:       //MIDDLE chracter in document
                    CreateTextUnitRange(out targetRange, TextUnit.Character, 1, targetRangeType, RangeLocation.Middle, checkType);
                    break;
                case TargetRangeType.LastCharacter:         //last character in document
                    CreateTextUnitRange(out targetRange, TextUnit.Character, -1, targetRangeType, RangeLocation.End, checkType);
                    break;
                case TargetRangeType.FirstFormat:           //First format range in document
                    CreateTextUnitRange(out targetRange, TextUnit.Format, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.FirstWord:             //First word range in document
                    CreateTextUnitRange(out targetRange, TextUnit.Word, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.FirstLine:             //First line range in document
                    CreateTextUnitRange(out targetRange, TextUnit.Line, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.FirstParagraph:        //First paragraph range in document
                    CreateTextUnitRange(out targetRange, TextUnit.Paragraph, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.FirstPage:             //First page range in document
                    CreateTextUnitRange(out targetRange, TextUnit.Page, 1, targetRangeType, RangeLocation.Start, checkType);
                    break;
                case TargetRangeType.DifferentTextPattern:          //range from a different TextPattern
                    differentTextPattern = GetDifferentTextPattern(m_le, checkType);
                    targetRange = differentTextPattern.DocumentRange;
                    break;
                case TargetRangeType.TwoCharsAdjacent:              //two adjacent characters
                case TargetRangeType.TwoCharsSplitAcrossLine:       //two chracters split across a line break
                    CreateMiscRange(targetRangeType, out targetRange, checkType);
                    break;
                case TargetRangeType.VisibleRange:                  // Equal to visible range of control
                    CreateVisibleRange(ref targetRange, checkType );
                    break;
                case TargetRangeType.RandomEndsStart:               //range that ENDs at START of calling range
                case TargetRangeType.RandomStartStart:              //range that STARTs at START of calling range
                case TargetRangeType.RandomEndsEnd:                 //range that ENDs at END of calling range
                case TargetRangeType.RandomStartsEnd:               //range that STARTs at END of calling range
                    CreateRamdomRange(sourceRange, out targetRange, targetRangeType, checkType);
                    break;
                case TargetRangeType.MiddleSpaces:                  //In middle of spaces between 1st and 2nd word
                case TargetRangeType.MiddlePunctuation:             //In middle of punctuation between 1st and 2nd word
                case TargetRangeType.HiddenLast:                    //Last instance of hidden text within document
                case TargetRangeType.HiddenFirst:                   //1st instance of hidden text within document
                default:
                    throw new ArgumentException("CreateRange() has no support for " + ParseType(targetRangeType));
            }

            Comment("     EXITING CreateRange(" + ParseType(targetRangeType) + "," + startOffset + "," + endOffset + "," + (sourceRange == null ? null : "<sourceRange>") + ",...)");
        }
Esempio n. 31
0
        //---------------------------------------------------------------------------
        // Helper for MoveEndpointByUnit() test cases
        //---------------------------------------------------------------------------
        internal void MoveEndpointByUnitHelper2(SampleText sampleText, TargetRangeType callingRangeType, Count requestedCount, Count startExpectedCount, Count endExpectedCount )
        {
            TextPatternRange documentRange      = Pattern_DocumentRange(CheckType.Verification);
            int              richEditOffset     = TextLibrary.CountTrailingCRLF(m_le, documentRange);
            int[]            numberOfTextUnits  = new int[((int)TextUnit.Document) + 1];
            TextUnit[]       supportedTextUnits = new TextUnit[((int)TextUnit.Document) + 1]; 
            TextPatternRange callingRange       = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRangeType>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Determine supported TextUnits for this control
            TS_IdentifySupportedTextUnits(ref supportedTextUnits);
            
            // Pre-Condition Calculate # of text units to move by
            TS_CountTextUnits(callingRange, supportedTextUnits, ref numberOfTextUnits);

            // Verify MoveEndpointEndPoints(start,TextUnit.*, 1) returns <<startOne>> for all TextUnits
            TS_MoveEndpointByUnitAndValidate2(callingRange, TextPatternRangeEndpoint.Start, requestedCount, startExpectedCount, numberOfTextUnits, richEditOffset, CheckType.Verification);

            // Verify MoveEndpointEndPoints(end,  TextUnit.*, 1) returns <<endOne>> for all TextUnits
            TS_MoveEndpointByUnitAndValidate2(callingRange, TextPatternRangeEndpoint.End, requestedCount, endExpectedCount, numberOfTextUnits, richEditOffset, CheckType.Verification);

        }
Esempio n. 32
0
        public bool SetTargetBySkillType(int skillType, TargetRangeType rangeType, bool isUseRushDistance, float reuseRate = -1f)
        {
            int skillID;

            return(this.GetSkillIDBySkillType(skillType, out skillID) && this.SetTargetBySkillID(skillID, rangeType, isUseRushDistance, reuseRate));
        }
Esempio n. 33
0
        //---------------------------------------AI Condition相关begin------------------------------------------------

        public override bool ProcInSkillRange(int skillBagIndex)
        {
            if (m_monsterData.skillIds.Count < skillBagIndex || skillBagIndex <= 0)
            {
                return(false);
            }
            skillBagIndex--;
            if (blackBoard.enemyId == 0)
            {
                return(false);
            }

            int skillId = m_monsterData.skillIds[skillBagIndex];

            if (!SkillData.dataMap.ContainsKey(skillId))
            {
                return(false);
            }


            EntityParent enemy = GetTargetEntity();

            if (enemy == null)
            {
                return(false);
            }

            bool rnt = false;


            if (!SkillData.dataMap.ContainsKey(skillId))
            {
                return(false);
            }

            TargetRangeType targetRangeType = 0;

            SkillData tmpSkillData = SkillData.dataMap[skillId];

            //逐个skillaction来判断是否等于TargetRangeType.WorldRange
            foreach (var tmpSkillActionId in tmpSkillData.skillAction)
            {
                if (SkillAction.dataMap[tmpSkillActionId].targetRangeType == (int)TargetRangeType.WorldRange)
                {
                    targetRangeType = TargetRangeType.WorldRange;
                }
            }

            if (targetRangeType == TargetRangeType.WorldRange)
            {
                rnt = skillManager.IsInSkillRange(skillId, blackBoard.enemyId);
            }
            else
            {
                int skillRange = GetSkillRange(skillId);


                int   distance     = skillRange;
                float entityRadius = enemy.MonsterData.scaleRadius;
                if (entityRadius <= 0.1f)
                {
                    entityRadius = (float)enemy.GetIntAttr("scaleRadius");
                }

                int curdistance = (int)(Vector3.Distance(Transform.position, enemy.Transform.position) * 100 - entityRadius);


                if (distance >= curdistance)
                {
                    rnt = true;
                    //Mogo.Util.LoggerHelper.Debug("IsInSkillRange:true");
                }
                else
                {
                    rnt = false;
                    //Mogo.Util.LoggerHelper.Debug("IsInSkillRange:false");
                }
            }
            return(rnt);
        }
Esempio n. 34
0
        public bool SetTargetFromLockOnTargetBySkillType(int skillType, TargetRangeType rangeType, bool isUseRushDistance)
        {
            int skillID;

            return(this.GetSkillIDBySkillType(skillType, out skillID) && this.SetTargetFromLockOnTargetBySkillID(skillID, rangeType, isUseRushDistance));
        }
Esempio n. 35
0
        public bool PackTryToMoveToTargetBySkillIndex(int skillIndex, int random, TargetRangeType rangeType)
        {
            int skillID;

            return(this.GetSkillIDBySkillIndex(skillIndex, out skillID) && this.PackTryToMoveToTargetBySkillID(skillID, random, rangeType));
        }
Esempio n. 36
0
    public List <Transform> GetHitContainers(int hitActionID)
    {
        var spellData = SkillAction.dataMap[hitActionID];

        // 目标类型 0 敌人, 1 自己  2 队友  3  友方
        int targetType = spellData.targetType;
        // 攻击范围类型。  0  扇形范围 1  圆形范围, 2, 单体。 3  直线范围 4 前方范围
        int targetRangeType = spellData.targetRangeType;
        // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表
        List <float> targetRangeParam = spellData.targetRangeParam;
        // 最大攻击人数
        //int maxTargetCount = spellData.maxTargetCount;
        // 触发伤害特效帧数
        //int damageTriggerFrame = spellData.damageTriggerFrame;

        List <Transform> result = new List <Transform>();

        if (targetType == (int)TargetType.Myself)
        {
            return(result);
        }

        if (theOwner.Transform == null)
        {
            return(result);
        }

        TargetRangeType rangeType = (TargetRangeType)targetRangeType;

        switch (rangeType)
        {
        case TargetRangeType.CircleRange:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                result = MogoUtils.GetTransformsInSector(theOwner.Transform, Container.containerRange, radius);
            }
            break;

        case TargetRangeType.SectorRange:
            if (targetRangeParam.Count >= 2)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = targetRangeParam[1];
                result = MogoUtils.GetTransformsInSector(theOwner.Transform, Container.containerRange, radius, angle);
            }
            break;

        case TargetRangeType.SingeTarget:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = 150;
                result = MogoUtils.GetTransformsInSector(theOwner.Transform, Container.containerRange, radius, angle);

                //entities = Utils.GetEntities(theOwner.Transform, radius, angle);
                MogoUtils.SortByDistance(theOwner.Transform, result);
                if (result.Count > 1)
                {
                    for (int i = 1; i < result.Count; i++)
                    {
                        result.RemoveAt(i);
                    }
                }
            }
            break;

        case TargetRangeType.WorldRange:
            if (targetRangeParam.Count >= 4)
            {
                float x1      = targetRangeParam[0] * 0.01f;
                float y1      = targetRangeParam[1] * 0.01f;
                float x2      = targetRangeParam[2] * 0.01f;
                float y2      = targetRangeParam[3] * 0.01f;
                float minX    = Math.Min(x1, x2);
                float maxX    = Math.Max(x1, x2);
                float minY    = Math.Min(y1, y2);
                float maxY    = Math.Max(y1, y2);
                float radiusX = minX + (maxX - minX) * 0.5f;
                float radiusY = minY + (maxY - minY) * 0.5f;
                float radius  = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f;
                result = MogoUtils.GetTransformsInRange(new Vector3(radiusX, 0, radiusY), Container.containerRange, radius);
            }
            break;

        case TargetRangeType.LineRange:
        default:
            if (targetRangeParam.Count >= 2)
            {
                float length = targetRangeParam[0] * 0.01f;
                float width  = targetRangeParam[1] * 0.01f;
                result = MogoUtils.GetTransformsFrontLineNew(theOwner.Transform, Container.containerRange, length, theOwner.Transform.forward, width);
            }
            break;
        }
        return(result);
    }
Esempio n. 37
0
 public bool PackTryToMoveToTargetBySkillIDAndLockOnTarget(int skillID, int random, TargetRangeType rangeType)
 {
     return(this.CheckRandom(random) && this.SetTargetFromLockOnTargetBySkillID(skillID, rangeType, false) && this.MoveToTargetBySkillID(skillID));
 }
Esempio n. 38
0
        //---------------------------------------------------------------------------
        // Helper for Compare() test cases
        //---------------------------------------------------------------------------
        internal void CompareHelper(SampleText sampleText, TargetRangeType callingRangeType, TargetRangeType argumentRangeType, bool expectMatch, Type expectedException)
        {
            bool isEqual = false;
            TextPatternRange callingRange;
            TextPatternRange argumentRange;
            string expectedText = "";
            IDictionary attribsExpected = null;
            AutomationElement enclosingExpected = null;
            AutomationElement[] childrenExpected = null;

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, out expectedText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create calling range = <<callingRange>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Argument range is <<argumentRange>>
            TS_CreateRange(out argumentRange, argumentRangeType, callingRange, false, CheckType.Verification);

            // Compare the ranges (<<expectedException>> for any expected errors)
            TS_Compare(callingRange, argumentRange, ref isEqual, expectMatch, expectedException, CheckType.Verification);

            // Calling Range: Get Attribute dictionary (assuming we're not done first!)
            if (expectedException != null)
            {
                Comment("Cannot continue with comparison tests when exception was raised as expected");
                return;
            }

            TS_GetAttributeValues(callingRange, out attribsExpected, AttributeType.SupportedAttributes, CheckType.Verification);

            // Calling Range: Get Get Enclosing element
            TS_GetEnclosingElement(callingRange, ref enclosingExpected, null, CheckType.Verification);

            // Calling Range: Get children
            TS_Children(callingRange, ref childrenExpected, false, CheckType.Verification);

            // Verify <<expectMatch>> Start/End Points
            TS_IsMatchingEndPoints(callingRange, argumentRange, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  text
            TS_IsMatchingText("Compare", argumentRange, expectedText, expectMatch, true, CheckType.Verification);

            // Verify <<expectMatch>>  Attribute dictionary
            TS_IsMatchingDictionary(argumentRange, attribsExpected, AttributeType.SupportedAttributes, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  Get Enclosing element
            TS_IsMatchingEnclosingElement(argumentRange, enclosingExpected, expectMatch, CheckType.Verification);

            // Verify <<expectMatch>>  children
            TS_IsMatchingChildren(argumentRange, childrenExpected, expectMatch, CheckType.Verification);
        }
Esempio n. 39
0
        //---------------------------------------------------------------------------
        // Helper for TextSelectionChangedEvent() test cases
        //---------------------------------------------------------------------------
        internal void TextSelectionChangedEventHelper(SampleText sampleText, TargetRangeType rangeType)
        {
            TextPatternRange       callingRange          = null;
            SupportedTextSelection supportedTextSelection = SupportedTextSelection.None; 

            // Pre-Condition Verify SupportedTextSelection != SupportedTextSelection.None
            Pattern_SupportedTextSelection(ref supportedTextSelection);
            TS_VerifySupportedTextSelection(supportedTextSelection, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range equal to <<rangeType>>
            TS_CreateRange(out callingRange, rangeType, null, false, CheckType.Verification);

            // Pre-Condition Set listener for TextPattern.SelectionChangedEvent
            TSC_AddEventListener(m_le, TextPattern.TextSelectionChangedEvent, TreeScope.Element, CheckType.Verification);

            // Select the element 
            TS_Select(callingRange, null, CheckType.Verification);

            // Wait for event
            TSC_WaitForEvents(1);

            // Verify ElementAddedToSelection event did/didnot happen
            TSC_VerifyEventListener(m_le, TextPattern.TextSelectionChangedEvent, EventFired.True, CheckType.Verification);
        }
Esempio n. 40
0
 static public string Parse(TargetRangeType value)
 {
     switch (value)
     {
         case TargetRangeType.DocumentRange: return "entire document";
         case TargetRangeType.EmptyStart: return "EMPTY range at START of document";
         case TargetRangeType.EmptyMiddle: return "EMPTY range in MIDDLE of document";
         case TargetRangeType.EmptyEnd: return "EMPTY range at END of document";
         case TargetRangeType.RandomEmptyStart: return "EMPTY range at random location near START of document";
         case TargetRangeType.RandomEmptyEnd: return "EMPTY range at random location near END of document";
         case TargetRangeType.RandomStart: return "RANDOM range at START of document";
         case TargetRangeType.RandomMiddle: return "RANDOM range in MIDDLE of document";
         case TargetRangeType.RandomEnd: return "RANDOM range at END of document";
         case TargetRangeType.TwoCharsAdjacent: return "two adjacent characters";
         case TargetRangeType.TwoCharsSplitAcrossLine: return "two characters split across a line break";
         case TargetRangeType.RandomEndsStart: return "range that ENDs at START of calling range";
         case TargetRangeType.RandomStartStart: return "range that STARTs at START of calling range";
         case TargetRangeType.RandomEndsEnd: return "range that ENDs at END of calling range";
         case TargetRangeType.RandomStartsEnd: return "range that STARTs at END of calling range";
         case TargetRangeType.Null: return "null value";
         case TargetRangeType.DifferentTextPattern: return "range from a different TextPattern";
         case TargetRangeType.SameAsCaller: return "same as calling range";
         case TargetRangeType.FirstCharacter: return "first character in document";
         case TargetRangeType.MiddleCharacter: return "MIDDLE character in document";
         case TargetRangeType.LastCharacter: return "last character in document";
         case TargetRangeType.HiddenFirst: return "1st instance of hidden text within document";
         case TargetRangeType.HiddenLast: return "Last instance of hidden text within document";
         case TargetRangeType.Clone: return "clone of calling range";
         case TargetRangeType.FirstFormat: return "First format range in document";
         case TargetRangeType.FirstWord: return "First word range in document";
         case TargetRangeType.FirstLine: return "First line range in document";
         case TargetRangeType.FirstParagraph: return "First paragraph range in document";
         case TargetRangeType.FirstPage: return "First page range in document";
         case TargetRangeType.MiddleSpaces: return "In middle of spaces between 1st and 2nd word";
         case TargetRangeType.MiddlePunctuation: return "In middle of punctuation between 1st and 2nd word";
         case TargetRangeType.VisibleRange: return "Equal to visible range of control";
         default:
             throw new ArgumentException("Parse() has no support for " + ParseType(value));
     }
 }
Esempio n. 41
0
        //---------------------------------------------------------------------------
        // Create range of specific text unit size
        //---------------------------------------------------------------------------
        internal void CreateTextUnitRange(out TextPatternRange range, TextUnit unit, int expectedCount, TargetRangeType targetRangeType, RangeLocation rangeLocation, CheckType checkType)
        {
            int actualCount = 0;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            if (IsEmptyRange(documentRange, checkType))
                ThrowMe(checkType, ParseType(targetRangeType) + " requires non-empty range");

            // Create empty range    
            CreateEmptyRange(out range, rangeLocation, checkType);

            // Expand range to match 
            Range_MoveEndpointByUnit(range, TextPatternRangeEndpoint.End, unit, expectedCount, ref actualCount, null, checkType);

            // If we did a move endPoint, did expected count = actual count?
            if (expectedCount != actualCount)
            {
                ThrowMe(checkType, "MoveEndpointByUnit(" + ParseType(unit) + "," + expectedCount + ") returned " +
                        actualCount + ", unable to create range of type " + Parse(targetRangeType));
            }
            else
            {
                Comment("Created range size " + expectedCount + " " + Parse(unit) + " units");
            }
        }
Esempio n. 42
0
        //---------------------------------------------------------------------------
        // Helper for Clone() test cases
        //---------------------------------------------------------------------------
        internal void CloneHelper(SampleText sampleText, TargetRangeType callingRangeType, bool requiresChildren)
        {
            TextPatternRange callingRange;
            TextPatternRange cloneRange = null;
            AutomationElement[] children = null;
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.IncorrectElementConfiguration);

            // Pre-Condition Verify text is expected value <<sampleText>> 
            TS_SetText(sampleText, CheckType.IncorrectElementConfiguration);

            // Pre-Condition Create range = <<callingRange>>
            TS_CreateRange(out callingRange, callingRangeType, null, false, CheckType.Verification);

            // Pre-Condition Children Property Helpers is <<requiresChildren>> array
            TS_Children(documentRange, ref children, requiresChildren, CheckType.IncorrectElementConfiguration);

            // Clone the range
            TS_Clone(callingRange, ref cloneRange, CheckType.Verification);

            // Verify identical ranges by calling Compare()
            TS_IsMatchingRange(callingRange, cloneRange, CheckType.Verification);

            // If children, Verify each child element is identical
            TS_IsMatchingRangeChildren(callingRange, cloneRange, CheckType.Verification);
        }
Esempio n. 43
0
    private List <uint> GetHitEntities(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position)
    {
        var spellData = SkillAction.dataMap[hitActionID];

        // 目标类型 0 敌人, 1 自己  2 队友  3  友方
        int targetType = spellData.targetType;
        // 攻击范围类型。  0  扇形范围 1  圆形范围, 2, 单体。 3  直线范围 4 前方范围
        int targetRangeType = spellData.targetRangeType;
        // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表
        List <float> targetRangeParam = spellData.targetRangeParam;
        float        offsetX          = spellData.hitXoffset;
        float        offsetY          = spellData.hitYoffset;
        float        angleOffset      = 180;
        // 最大攻击人数
        //int maxTargetCount = spellData.maxTargetCount;
        // 触发伤害特效帧数
        //int damageTriggerFrame = spellData.damageTriggerFrame;

        List <uint> entities = new List <uint>();

        if (targetType == (int)TargetSelectType.Myself)
        {
            entities.Add(owner.ID);
            return(entities);
        }
        if (owner.transform == null)
        {
            return(entities);
        }
        Matrix4x4  entityltwm     = owner.transform.localToWorldMatrix;
        Quaternion entityrotation = owner.transform.rotation;
        Vector3    entityforward  = owner.transform.forward;
        Vector3    entityposition = owner.transform.position;

        if (spellData.castPosType == 0)
        {
            entityltwm     = ltwm;
            entityrotation = rotation;
            entityforward  = forward;
            entityposition = position;
        }
        TargetRangeType rangeType = (TargetRangeType)targetRangeType;

        switch (rangeType)
        {
        case TargetRangeType.CircleRange:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;

                entities = GameCommonUtils.GetEntitiesInRange(entityltwm, entityrotation, entityforward, entityposition, radius, offsetX, offsetY, angleOffset);
            }
            break;

        case TargetRangeType.SectorRange:
            if (targetRangeParam.Count >= 2)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = targetRangeParam[1];
                entities = GameCommonUtils.GetEntitiesInSector(entityltwm, entityrotation, entityforward, entityposition, radius, angle, offsetX, offsetY, angleOffset);
                //entities = Utils.GetEntities(theOwner.Transform, radius, angle);
            }
            break;

        case TargetRangeType.SingeTarget:
            if (targetRangeParam.Count >= 1)
            {
                float radius = targetRangeParam[0] * 0.01f;
                float angle  = 150;
                entities = GameCommonUtils.GetEntitiesInSector(entityltwm, entityrotation, entityforward, entityposition, radius, angle, offsetX, offsetY, angleOffset);
                GameCommonUtils.SortByDistance(owner.transform, entities);
                if (entities.Count > 1)
                {
                    for (int i = 1; i < entities.Count; i++)
                    {
                        entities.RemoveAt(i);
                    }
                }
            }
            break;

        case TargetRangeType.WorldRange:
            if (targetRangeParam.Count >= 4)
            {
                float x1      = targetRangeParam[0] * 0.01f;
                float y1      = targetRangeParam[1] * 0.01f;
                float x2      = targetRangeParam[2] * 0.01f;
                float y2      = targetRangeParam[3] * 0.01f;
                float minX    = Math.Min(x1, x2);
                float maxX    = Math.Max(x1, x2);
                float minY    = Math.Min(y1, y2);
                float maxY    = Math.Max(y1, y2);
                float radiusX = minX + (maxX - minX) * 0.5f;
                float radiusY = minY + (maxY - minY) * 0.5f;
                float radius  = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f;
                entities = GameCommonUtils.GetEntitiesInRange(new Vector3(radiusX, 0, radiusY), radius);
            }
            break;

        case TargetRangeType.LineRange:
        default:
            if (targetRangeParam.Count >= 2)
            {
                float length = targetRangeParam[0] * 0.01f;
                float width  = targetRangeParam[1] * 0.01f;
                entities = GameCommonUtils.GetEntitiesFrontLineNew(entityltwm, entityrotation, entityforward, entityposition, length, entityforward, width, offsetX, offsetY, angleOffset);
            }
            break;
        }
        return(entities);
    }
Esempio n. 44
0
        /// <summary>
        /// 根据技能id,获取到受击者的列表
        /// 返回值 是一个三元组。分别是 dummy list, monster list, player list
        /// </summary>
        /// <param name="hitActionID"></param>
        /// <param name="ltwm"></param>
        /// <param name="rotation"></param>
        /// <param name="forward"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        private List <List <uint> > GetHitEntities(int hitActionID, Matrix4x4 ltwm, Quaternion rotation, Vector3 forward, Vector3 position)
        {
            var spellData = SkillAction.dataMap[hitActionID];
            //技能实施的目标类型,0敌人,1自己,2队友,3友方
            int targetType = spellData.targetType;
            //技能范围类型。0 扇形 1 圆形 2单体 3直线 4前方
            int targetRangeType = spellData.targetRangeType;
            //攻击范围参数。 针对不同类型,有不同的意义。 浮点数列表
            List <float>        targetRangeParam = spellData.targetRangeParam;
            float               offsetX          = spellData.hitXoffset;
            float               offsetY          = spellData.hitYoffset;
            float               angleOffset      = 180;
            List <List <uint> > entities         = new List <List <uint> >();

            if (targetType == (int)TargetType.Myself)
            {
                List <uint> listDummy     = new List <uint>();
                List <uint> listMonster   = new List <uint>();
                List <uint> listPlayer    = new List <uint>();
                List <uint> listMercenary = new List <uint>();
                listPlayer.Add(theOwner.ID);
                entities.Add(listDummy);
                entities.Add(listMonster);
                entities.Add(listPlayer);
                entities.Add(listMercenary);
                return(entities);
            }
            if (theOwner.Transform == null)
            {
                return(entities);
            }
            Matrix4x4  entityltwm     = theOwner.Transform.localToWorldMatrix;
            Quaternion entityrotation = theOwner.Transform.rotation;
            Vector3    entityforward  = theOwner.Transform.forward;
            Vector3    entityposition = theOwner.Transform.position;

            //如果技能释放的位置不是自身,当castPosType为0的时候,不是自身
            if (spellData.castPosType == 0)
            {
                entityltwm     = ltwm;
                entityrotation = rotation;
                entityforward  = forward;
                entityposition = position;
            }
            TargetRangeType rangeType = (TargetRangeType)targetRangeType;

            switch (rangeType)
            {
            //圆形
            case TargetRangeType.CircleRange:
                if (targetRangeParam.Count >= 1)
                {
                    float radius = targetRangeParam[0] * 0.01f;    //参数1为范围半径
                    if (spellData.castPosType == 2 && theOwner is EntityDummy)
                    {
                        EntityParent e = theOwner.GetTargetEntity();
                        if (e != null)
                        {
                            entities = UnityTools.GetEntityInRange(e.Transform.position, radius, offsetX, offsetY, angleOffset);
                        }
                    }
                    else
                    {
                        entities = UnityTools.GetEntityInRange(entityltwm, entityrotation, entityforward, entityposition, radius, offsetX, offsetY, angleOffset);
                    }
                }
                break;

            //直线
            case TargetRangeType.LineRange:
                if (targetRangeParam.Count >= 2)
                {
                    float length = targetRangeParam[0] * 0.01f;
                    float width  = targetRangeParam[1] * 0.01f;
                    entities = UnityTools.GetEnitiesForntLineNew(entityltwm, entityrotation, entityforward, entityposition, length, entityforward, width, offsetX, offsetY, angleOffset);
                }
                break;
            }
            return(entities);
        }