/// <summary>
 /// Завершает миссию
 /// </summary>
 public void Finish()
 {
     Active = false;
     API.deleteEntity(_blip);
     API.deleteColShape(_bootyPoint.ColShape);
     API.deleteEntity(_bootyPoint.Marker);
     _bootyPoint = null;
 }
示例#2
0
 public Rank()
 {
     Number            = -1;
     TeamId            = -1;
     MatchesWonAndLost = new PointResult(0, 0);
     MatchPoints       = new PointResult(0, 0);
     SetPoints         = new PointResult(0, 0);
     BallPoints        = new PointResult(0, 0);
 }
        /// <summary>
        /// Запускает миссию
        /// </summary>
        public void Start()
        {
            Active    = true;
            StartTime = DateTime.Now;
            var position = MissionDataGetter.GetMissionPosition(Place);

            _bootyPoint = _pointCreator.CreateMarker(Marker.VerticalCylinder, position, Colors.DarkBlue, 1.5f);
            _bootyPoint.Marker.scale = new Vector3(3, 3, 1);
            _bootyPoint.ColShape.onEntityEnterColShape += (shape, entity) => PlayerHelper.ProcessAction(entity, OnPlayerEnterBootyShape);
            _blip = _pointCreator.CreateBlip(position, 78, 19, name: "Миссия банды");
        }
示例#4
0
        public void PointResultModelToViewModelTest()
        {
            var model = new PointResult
            {
                Name  = "a",
                Value = 1
            };

            var result = _Sut.Map <PointResultViewModel>(model);

            Assert.AreEqual(model.Name, result.Name);
            Assert.AreEqual(model.Value, result.Value);
        }
        //연동회원 잔여포인트 확인
        public double getBalance(string BearerToken, string ServiceID, bool UseStaticIP, bool UseGAIP)
        {
            if (string.IsNullOrEmpty(ServiceID))
            {
                throw new LinkhubException(-99999999, "ServiceID is Not entered");
            }
            if (string.IsNullOrEmpty(BearerToken))
            {
                throw new LinkhubException(-99999999, "BearerToken is Not entered");
            }

            string         URI     = getTargetURL(UseStaticIP, UseGAIP) + "/" + ServiceID + "/Point";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);

            if (this._ProxyYN == true)
            {
                WebProxy proxyRequest = new WebProxy();

                Uri proxyURI = new Uri(this._ProxyAddress);
                proxyRequest.Address     = proxyURI;
                proxyRequest.Credentials = new NetworkCredential(this._ProxyUserName, this._ProxyPassword);
                request.Proxy            = proxyRequest;
            }

            request.Headers.Add("Authorization", "Bearer" + " " + BearerToken);
            request.Method = "GET";

            try
            {
                HttpWebResponse            response   = (HttpWebResponse)request.GetResponse();
                Stream                     stReadData = response.GetResponseStream();
                DataContractJsonSerializer ser2       = new DataContractJsonSerializer(typeof(PointResult));
                PointResult                result     = (PointResult)ser2.ReadObject(stReadData);

                return(result.remainPoint);
            }
            catch (WebException we)
            {
                if (we.Response != null)
                {
                    Stream stReadData = we.Response.GetResponseStream();
                    DataContractJsonSerializer ser2 = new DataContractJsonSerializer(typeof(Error));
                    Error t = (Error)ser2.ReadObject(stReadData);

                    throw new LinkhubException(t.code, t.message);
                }

                throw new LinkhubException(-99999999, we.Message);
            }
        }
示例#6
0
        public Double getPartnerBalance(String BearerToken, String ServiceID, bool UseStaticIP, bool UseGAIP)
        {
            if (String.IsNullOrEmpty(ServiceID))
            {
                throw new LinkhubException(-99999999, "NO ServiceID");
            }
            if (String.IsNullOrEmpty(BearerToken))
            {
                throw new LinkhubException(-99999999, "NO BearerToken");
            }

            String URL = getTargetURL(UseStaticIP, UseGAIP);

            String URI = URL + "/" + ServiceID + "/PartnerPoint";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);

            request.Headers.Add("Authorization", "Bearer" + " " + BearerToken);

            request.Method = "GET";

            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                Stream stReadData = response.GetResponseStream();

                DataContractJsonSerializer ser2 = new DataContractJsonSerializer(typeof(PointResult));

                PointResult result = (PointResult)ser2.ReadObject(stReadData);

                return(result.remainPoint);
            }
            catch (WebException we)
            {
                if (we.Response != null)
                {
                    Stream stReadData = we.Response.GetResponseStream();

                    DataContractJsonSerializer ser2 = new DataContractJsonSerializer(typeof(Error));

                    Error t = (Error)ser2.ReadObject(stReadData);

                    throw new LinkhubException(t.code, t.message);
                }

                throw new LinkhubException(-99999999, we.Message);
            }
        }
        /// <summary>
        /// Assigns &quot;set points&quot; to each of the <see cref="SetEntity"/>s in the list.
        /// For &quot;Best-of&quot; matches, <see cref="SetEntity.IsTieBreak"/> is flagged, too.
        /// </summary>
        /// <param name="setList">An <see cref="IList{SetEntity}"/>.</param>
        /// <param name="setRule">The <see cref="SetRuleEntity"/> with the set rules to apply.</param>
        /// <param name="matchRule">The <see cref="MatchRuleEntity"/> with the set rules to apply.</param>
        /// <returns>Returns the <see cref="IList{SetEntity}"/> after &quot;set points&quot; were set.</returns>
        public static IList <SetEntity> CalculateSetPoints(this IList <SetEntity> setList, SetRuleEntity setRule, MatchRuleEntity matchRule)
        {
            var wonSets = new PointResult(0, 0);

            foreach (var set in setList)
            {
                set.CalculateSetPoints(setRule);
                set.IsTieBreak = false || matchRule.BestOf && wonSets.Home == wonSets.Guest &&
                                 wonSets.Home + wonSets.Guest == matchRule.MaxNumOfSets() - 1;
                wonSets.Home  += set.HomeBallPoints > set.GuestBallPoints ? 1 : 0;
                wonSets.Guest += set.HomeBallPoints < set.GuestBallPoints ? 0 : 1;
            }

            return(setList);
        }
示例#8
0
        /// <summary>
        /// Запускает войну за район
        /// </summary>
        public void StartWar()
        {
            ClientEventHandler.Add(ClientEvent.CAPTURE_DISTRICT, CaptureStreet);
            _district = _districtsProvider.GetNext();
            _clanManager.RemoveDistrict(_district.Id);
            var position = PositionConverter.ToVector3(_district.Position);

            _blip         = _pointCreator.CreateBlip(position, 439, 4, scale: 2f, name: "Война за район");
            _capturePoint = _pointCreator.CreateMarker(Marker.VerticalCylinder, position, Colors.White, 3.7f, "Точка захвата района");
            _capturePoint.ColShape.onEntityEnterColShape += PlayerComeToCapturePoint;
            _capturePoint.ColShape.onEntityExitColShape  += PlayerAwayFromCapturePoint;
            API.setMarkerScale(_capturePoint.Marker, new Vector3(4, 4, 4));
            API.setEntityPosition(_capturePoint.Label, _capturePoint.Label.position.Add(new Vector3(0, 0, 2)));
            API.sendChatMessageToAll($"~b~[Банды] Началось сражение за район \"{_district.Name}\"!");
        }
示例#9
0
        public Double getPartnerBalance(String BearerToken, String ServiceID)
        {
            if (String.IsNullOrEmpty(ServiceID))
            {
                throw new LinkhubException(-99999999, "NO ServiceID");
            }
            if (String.IsNullOrEmpty(BearerToken))
            {
                throw new LinkhubException(-99999999, "NO BearerToken");
            }

            String URI = ServiceURL + "/" + ServiceID + "/PartnerPoint";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);

            request.Headers.Add("Authorization", "Bearer" + " " + BearerToken);

            request.Method = "GET";

            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                Stream stReadData = response.GetResponseStream();

                PointResult result = fromJson <PointResult>(stReadData);

                return(double.Parse(result.remainPoint));
            }
            catch (WebException we)
            {
                if (we.Response != null)
                {
                    Stream    stReadData = we.Response.GetResponseStream();
                    JsonValue readData   = parseJson(stReadData);
                    throw new LinkhubException(readData["code"], readData["message"]);
                }

                throw new LinkhubException(-99999999, we.Message);
            }
        }
示例#10
0
        /// <summary>
        /// Создать НПС
        /// </summary>
        public PointResult CreatePed(PedHash hash, string name, Vector3 pedPosition, Vector3 pedRotation,
                                     Vector3 markerPosition, Color markerColor, int dimention = 0)
        {
            var markerType = Convert.ToInt32(Marker.HorizontalSplitArrowCircle);
            var result     = new PointResult {
                Npc      = CreatePed(hash, pedPosition, pedRotation, dimention),
                Label    = API.createTextLabel(name, pedPosition.Add(new Vector3(0, 0, 1.2)), 10, 0.5F),
                ColShape = API.createSphereColShape(markerPosition, 1.4F),
                Marker   = API.createMarker(
                    markerType, markerPosition, new Vector3(), new Vector3(), new Vector3(1, 1, 1),
                    markerColor.Bright, markerColor.Red, markerColor.Green, markerColor.Blue
                    )
            };

            if (dimention != 0)
            {
                result.ColShape.dimension = dimention;
                result.Label.dimension    = dimention;
                result.Marker.dimension   = dimention;
            }
            return(result);
        }
示例#11
0
        /// <summary>
        /// Создать маркер
        /// </summary>
        public PointResult CreateMarker(Marker type, Vector3 position, Color color, float range, string label = null, int dimention = 0)
        {
            var markerType = Convert.ToInt32(type);
            var result     = new PointResult {
                ColShape = API.createCylinderColShape(position, range, 3f),
                Marker   = API.createMarker(
                    markerType, position, new Vector3(), new Vector3(), new Vector3(1, 1, 0.7),
                    color.Bright, color.Red, color.Green, color.Blue, dimention
                    )
            };

            if (label != null)
            {
                result.Label           = API.createTextLabel(label, position.Add(new Vector3(0, 0, 1.2)), 10, 0.5F, dimension: dimention);
                result.Label.dimension = dimention;
            }
            if (dimention != 0)
            {
                result.ColShape.dimension = dimention;
                result.Marker.dimension   = dimention;
            }
            return(result);
        }
        private static IResult IntersectionDetailsParallel(Vector2 d0, Vector2 d1, Vector2 e, Point2 a, Point2 b, Point2 c, Point2 d) {
            Contract.Ensures(Contract.Result<IResult>() != null);

            var squareMagnitude0 = d0.GetMagnitudeSquared();
            var d0DotD1 = d0.Dot(d1);
            var s1 = d0.Dot(e) / squareMagnitude0;
            var s2 = s1 + (d0DotD1 / squareMagnitude0);
            double sMin, sMax;
            if (s1 <= s2) {
                sMin = s1;
                sMax = s2;
            }
            else {
                sMin = s2;
                sMax = s1;
            }

            if (sMax < 0.0 || sMin > 1.0)
                return DefaultNoIntersection; // no intersection
            if (sMax == 0.0)
                return new PointResult(a, 0.0, a == c ? 0.0 : 1.0); // the start point
            if (sMin == 1.0)
                return new PointResult(b, 1.0, b == c ? 0.0 : 1.0); // the end point

            PointResult resultA;
            PointResult resultB;
            double squareMagnitude1;
            if (sMin <= 0.0 && sMax >= 1.0) {
                squareMagnitude1 = d1.GetMagnitudeSquared();
                var t1 = d1.Dot(e.GetNegative()) / squareMagnitude1;
                resultA = new PointResult(a, 0.0, t1);
                resultB = new PointResult(b, 1.0, t1 + (d0DotD1 / squareMagnitude1));
            }
            else if (sMin >= 0.0 && sMax <= 1.0) {
                // reuse s1 and s2 from above
                resultA = new PointResult(c, s1, 0.0);
                resultB = new PointResult(d, s2, 1.0);
            }
            else {
                squareMagnitude1 = d1.GetMagnitudeSquared();
                var p1 = (0.0 < sMin) ? a + (d0.GetScaled(sMin)) : a;
                var p2 = a + (d0.GetScaled(sMax < 1.0 ? sMax : 1.0));
                var pd = p2 - p1;
                s1 = d0.Dot(p1 - a) / squareMagnitude0;
                s2 = s1 + (d0.Dot(pd) / squareMagnitude0);
                var t1 = d1.Dot(p1 - c) / squareMagnitude1;
                resultA = new PointResult(p1, s1, t1);
                resultB = new PointResult(p2, s2, t1 + (d1.Dot(pd) / squareMagnitude1));
            }

            return new SegmentResult(resultA, resultB);
        }
 /// <summary>
 /// Constructs a new segment intersection result.
 /// </summary>
 /// <param name="a">The first point intersection defining an end of the segment intersection.</param>
 /// <param name="b">The second point intersection defining an end of the segment intersection.</param>
 public SegmentResult(PointResult a, PointResult b) {
     A = a;
     B = b;
 }
        private static IResult IntersectionDetailsParallel(Vector2 d0, Vector2 d1, Vector2 e, Point2 a, Point2 b, Point2 c, Point2 d)
        {
            Contract.Ensures(Contract.Result <IResult>() != null);

            var    squareMagnitude0 = d0.GetMagnitudeSquared();
            var    d0DotD1          = d0.Dot(d1);
            var    s1 = d0.Dot(e) / squareMagnitude0;
            var    s2 = s1 + (d0DotD1 / squareMagnitude0);
            double sMin, sMax;

            if (s1 <= s2)
            {
                sMin = s1;
                sMax = s2;
            }
            else
            {
                sMin = s2;
                sMax = s1;
            }

            if (sMax < 0.0 || sMin > 1.0)
            {
                return(DefaultNoIntersection); // no intersection
            }
            if (sMax == 0.0)
            {
                return(new PointResult(a, 0.0, a == c ? 0.0 : 1.0)); // the start point
            }
            if (sMin == 1.0)
            {
                return(new PointResult(b, 1.0, b == c ? 0.0 : 1.0)); // the end point
            }
            PointResult resultA;
            PointResult resultB;
            double      squareMagnitude1;

            if (sMin <= 0.0 && sMax >= 1.0)
            {
                squareMagnitude1 = d1.GetMagnitudeSquared();
                var t1 = d1.Dot(e.GetNegative()) / squareMagnitude1;
                resultA = new PointResult(a, 0.0, t1);
                resultB = new PointResult(b, 1.0, t1 + (d0DotD1 / squareMagnitude1));
            }
            else if (sMin >= 0.0 && sMax <= 1.0)
            {
                // reuse s1 and s2 from above
                resultA = new PointResult(c, s1, 0.0);
                resultB = new PointResult(d, s2, 1.0);
            }
            else
            {
                squareMagnitude1 = d1.GetMagnitudeSquared();
                var p1 = (0.0 < sMin) ? a + (d0.GetScaled(sMin)) : a;
                var p2 = a + (d0.GetScaled(sMax < 1.0 ? sMax : 1.0));
                var pd = p2 - p1;
                s1 = d0.Dot(p1 - a) / squareMagnitude0;
                s2 = s1 + (d0.Dot(pd) / squareMagnitude0);
                var t1 = d1.Dot(p1 - c) / squareMagnitude1;
                resultA = new PointResult(p1, s1, t1);
                resultB = new PointResult(p2, s2, t1 + (d1.Dot(pd) / squareMagnitude1));
            }

            return(new SegmentResult(resultA, resultB));
        }
 /// <summary>
 /// Constructs a new segment intersection result.
 /// </summary>
 /// <param name="a">The first point intersection defining an end of the segment intersection.</param>
 /// <param name="b">The second point intersection defining an end of the segment intersection.</param>
 public SegmentResult(PointResult a, PointResult b)
 {
     A = a;
     B = b;
 }
        /// <summary>
        /// Gets the number of sets won by the home and guest team.
        /// </summary>
        /// <param name="setList">The <see cref="IList{SetEntity}"/> for which the calculation takes place.</param>
        /// <returns>Returns a <see cref="IOpponent{T}"/> with the number of won sets for home and guest team.</returns>
        public static IOpponent <int> GetSetsWon(this IList <SetEntity> setList)
        {
            var setsWon = new PointResult(setList.Count(set => set.HomeBallPoints > set.GuestBallPoints), setList.Count(set => set.HomeBallPoints < set.GuestBallPoints));

            return(setsWon);
        }