public HRocket(Texture2D texture, Texture2D trailTexture, Vector2 position)
 {
     this.texture = texture;
     this.Position = position;
     this.trailTexture = trailTexture;
     this.alive = true;
     trail = new Trail(trailTexture, new Vector2(Position.X, Position.Y + texture.Height));
 }
Ejemplo n.º 2
0
 // reset state
 public override void Reset()
 {
     base.Reset(); // reset the vehicle
     Speed = 1.5f;         // speed along Forward direction.
     MaxForce = 0.3f;      // steering force is clipped to this magnitude
     MaxSpeed = 5;         // velocity is clipped to this magnitude
     trail = new Trail();
     trail.Clear();    // prevent long streaks due to teleportation
 }
Ejemplo n.º 3
0
        // reset state
        public override void Reset()
        {
            base.Reset(); // reset the vehicle
            Speed = 0.0f;         // speed along Forward direction.
            MaxForce = 9.0f;      // steering force is clipped to this magnitude
            MaxSpeed = 9.0f;         // velocity is clipped to this magnitude

            SetPosition(0, 0, 0);
            if (trail == null) trail = new Trail(100, 6000);
            trail.Clear();    // prevent long streaks due to teleportation
        }
Ejemplo n.º 4
0
        // reset state
        public override void Reset()
        {
            base.Reset();			// reset the vehicle

            Speed = 0;            // speed along Forward direction.
            MaxForce = 5.0f;       // steering force is clipped to this magnitude
            MaxSpeed = 3.0f;       // velocity is clipped to this magnitude
            trail = new Trail();
            trail.Clear();    // prevent long streaks due to teleportation
            GaudyPursuitAnnotation = true; // select use of 9-color annotation
        }
Ejemplo n.º 5
0
    void Awake()
    {
        DontDestroyOnLoad(transform.gameObject);

        if (photonView.isMine)
        {
            rotationDevice = GameObject.FindGameObjectWithTag("RotationDevice");
            finalSpeeder = FindObjectOfType<RotateForward>();
        }
        else
        {
            trail = GetComponentInChildren<Trail>();
        }
    }
Ejemplo n.º 6
0
        public bool CreateTrail(Trail trail)
        {
            // Test

            /*
             * try
             * {
             *  appDbContext.Trails.Add(trail);
             *  return appDbContext.SaveChanges() > 0 ? true : false;
             * }
             * catch (Exception ex)
             * {
             *  // log exception
             *  return false;
             * }
             */

            appDbContext.Trails.Add(trail);
            return(appDbContext.SaveChanges() > 0 ? true : false);
        }
Ejemplo n.º 7
0
 public IActionResult AddTrail(Trail t, string NS, string EW)
 {
     if (NS == "S" && t.Latitude > 0)
     {
         t.Latitude = t.Latitude * -1;
     }
     if (EW == "W" && t.Longitude > 0)
     {
         t.Longitude = t.Longitude * -1;
     }
     if (ModelState.IsValid)
     {
         trailFactory.Add(t);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("NewTrail"));
     }
 }
Ejemplo n.º 8
0
        public void AddTrail_SubsequentTrail_TrailAdded()
        {
            // Arrange
            var location1 = new Location();
            var location2 = new Location();

            var firstTrail = new Trail(location1, location2);

            location1.AddTrail(firstTrail);

            var subsequentTrail = new Trail(location2, location1);

            // Act
            location1.AddTrail(subsequentTrail);

            // Arrange
            location1.Trails.Count.ShouldBe(2);
            location1.Trails.Contains(firstTrail).ShouldBeTrue();
            location1.Trails.Contains(subsequentTrail).ShouldBeTrue();
        }
Ejemplo n.º 9
0
        public MainForm()
        {
            InitializeComponent();

            var trail = Trail.Load(@"AntTrails\Default.xml");

            settings = new Settings(trail)
            {
                MinCohorts     = Properties.Settings.Default.MinCohorts,
                MaxCohorts     = Properties.Settings.Default.MaxCohorts,
                MaxSteps       = Properties.Settings.Default.MaxSteps,
                Population     = Properties.Settings.Default.Population,
                MaxTreeDepth   = Properties.Settings.Default.MaxTreeDepth,
                MutationRate   = Properties.Settings.Default.MutationRate,
                PercentToKeep  = Properties.Settings.Default.PercentToKeep,
                MetGoalsTarget = Properties.Settings.Default.MetGoalsTarget
            };

            antGrid.Load(trail);
        }
Ejemplo n.º 10
0
        protected override void Seed(TrailProjectIV.Models.DataContext context)
        {
            var trails = new Trail[]
            {
                new Trail {
                    TrailNumber = 1, TrailName = "Givens, Spicer & Lowry Trail", TrailStatusUpdated = DateTime.Now, StatusId = 1
                },
                new Trail {
                    TrailNumber = 2, TrailName = "Lighthouse Trail", TrailStatusUpdated = DateTime.Now, StatusId = 1
                },
                new Trail {
                    TrailNumber = 3, TrailName = "Capitol Peak Trail", TrailStatusUpdated = DateTime.Now, StatusId = 1
                },
                new Trail {
                    TrailNumber = 4, TrailName = "Little Fox Canyon Trail", TrailStatusUpdated = DateTime.Now, StatusId = 1
                }
            };

            context.Trails.AddOrUpdate(t => t.TrailNumber, trails);
        }
Ejemplo n.º 11
0
        private bool addTrailToTable(Trail t)
        {
            var row = table.NewRow();

            //int nodeNumber;
            //int.TryParse(n.Name.Split('.')[1], out nodeNumber);
            row["id"]   = t.StartingSlot;
            row["Type"] = "Trail";
            row["Name"] = t.Name;
            try
            {
                table.Rows.Add(row);
            }
            catch (ConstraintException e)
            {
                mainWindow.errorMessage("This trail alredy exist.");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 12
0
        private void _map_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
        {
            string[] dialogInfo = e.Marker.Title.ToString().Split(',');
            Trail    trail      = null;

            if (dialogInfo.Length > 2)
            {
                for (int i = 0; i < TrailList.Count; ++i)
                {
                    if (e.Marker.Title == TrailList[i].Item1.Title)
                    {
                        trail = TrailList[i].Item2;
                    }
                }

                Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
                TrailInfoDialog dialogFragment = new TrailInfoDialog(trail, m_username, m_userID);
                dialogFragment.Show(transaction, "TrailInfo_Dialog");
            }
        }
        public void TestMovingAverageSeconds()
        {
            DateTime StartTime = DateTime.Now;
            Trail    trail     = new Trail();
            Point    Position1 = new Point(10, 0);
            Point    Position2 = new Point(20, 10);

            trail.AddPosition(Position1);
            while (DateTime.Now.Subtract(StartTime).Seconds < 5)
            {
            }
            trail.AddPosition(Position2);

            //Average position of last second
            Assert.AreEqual(20, trail.MovingAverageTime(1).X);
            Assert.AreEqual(10, trail.MovingAverageTime(1).Y);
            //Average position of last 7 seconds
            Assert.AreEqual(15, trail.MovingAverageTime(7).X);
            Assert.AreEqual(5, trail.MovingAverageTime(7).Y);
        }
Ejemplo n.º 14
0
        private void ManageTrails()
        {
            trail = trail ?? new Trail(Main.instance.GraphicsDevice, 10, new TriangularTip(40 * 4), factor => 10 + factor * 4 + (projectile.timeLeft <= 30 ? Helper.SwoopEase(1 - projectile.timeLeft / 30f) * 30 : 0), factor =>
            {
                if (factor.X > 0.95f)
                {
                    return(Color.Transparent);
                }

                float mul = 1;
                if (projectile.timeLeft < 30)
                {
                    mul = Helper.SwoopEase(projectile.timeLeft / 30f);
                }


                return(new Color(100, 220, 255) * factor.X * (0.5f + (float)Math.Sin(Main.GameUpdateCount * 0.15f) * 0.25f) * mul);
            });

            trail.Positions    = cache.ToArray();
            trail.NextPosition = projectile.Center + Vector2.UnitX.RotatedBy(Main.GameUpdateCount * 0.1f + (11 / 10f) * 3) * 60;

            trail2 = trail2 ?? new Trail(Main.instance.GraphicsDevice, 10, new TriangularTip(40 * 4), factor => 10 + factor * 4 + (projectile.timeLeft <= 30 ? Helper.SwoopEase(1 - projectile.timeLeft / 30f) * 30 : 0), factor =>
            {
                if (factor.X > 0.95f)
                {
                    return(Color.Transparent);
                }

                float mul = 1;
                if (projectile.timeLeft < 30)
                {
                    mul = Helper.SwoopEase(projectile.timeLeft / 30f);
                }

                return(new Color(100, 220, 255) * factor.X * (0.5f + (float)Math.Cos(Main.GameUpdateCount * 0.15f + 3.14f) * 0.25f) * mul);
            });

            trail2.Positions    = cache2.ToArray();
            trail2.NextPosition = projectile.Center + Vector2.UnitY.RotatedBy(Main.GameUpdateCount * 0.1f + (11 / 10f) * 3) * 60;
        }
Ejemplo n.º 15
0
        }         // InternalFlow

        private void ComparePrimaryAndSecondary(AutomationCalculator.AutoDecision.AutoRejection.LGAgent oSecondary)
        {
            if (Trail.HasApprovalChance == oSecondary.Trail.HasApprovalChance)
            {
                Trail.Negative <SameApprovalChance>(false)
                .Init(Trail.HasApprovalChance, oSecondary.Trail.HasApprovalChance);
                oSecondary.Trail.Negative <SameApprovalChance>(false)
                .Init(Trail.HasApprovalChance, oSecondary.Trail.HasApprovalChance);
            }
            else
            {
                Trail.Affirmative <SameApprovalChance>(false)
                .Init(Trail.HasApprovalChance, oSecondary.Trail.HasApprovalChance);
                oSecondary.Trail.Affirmative <SameApprovalChance>(false)
                .Init(Trail.HasApprovalChance, oSecondary.Trail.HasApprovalChance);
            }             // if

            if (Output.FlowType == oSecondary.Output.FlowType)
            {
                Trail.Dunno <SameFlowChosen>().Init(Output.FlowType, oSecondary.Output.FlowType);
                oSecondary.Trail.Dunno <SameFlowChosen>().Init(Output.FlowType, oSecondary.Output.FlowType);
            }
            else
            {
                Trail.Negative <SameFlowChosen>(true).Init(Output.FlowType, oSecondary.Output.FlowType);
                oSecondary.Trail.Negative <SameFlowChosen>(true).Init(Output.FlowType, oSecondary.Output.FlowType);
            }             // if

            if (Output.GradeRangeID == oSecondary.Output.GradeRangeID)
            {
                Trail.Dunno <SameConfigurationChosen>().Init(Output.GradeRangeID, oSecondary.Output.GradeRangeID);
                oSecondary.Trail.Dunno <SameConfigurationChosen>()
                .Init(Output.GradeRangeID, oSecondary.Output.GradeRangeID);
            }
            else
            {
                Trail.Negative <SameConfigurationChosen>(true).Init(Output.GradeRangeID, oSecondary.Output.GradeRangeID);
                oSecondary.Trail.Negative <SameConfigurationChosen>(true)
                .Init(Output.GradeRangeID, oSecondary.Output.GradeRangeID);
            }     // if
        }         // ComparePrimaryAndSecondary
Ejemplo n.º 16
0
        protected virtual void RunPrimary()
        {
            using (Trail.AddCheckpoint(ProcessCheckpoints.OldWayFlow)) {
                this.oldWayAgent.Init().RunPrimaryOnly();
                this.oldWayAgent.Trail.UniqueID = this.args.TrailUniqueID;
                this.oldWayAgent.Trail.SetTag(this.args.Tag).Save(DB, null, TrailPrimaryStatus.OldPrimary);
            }             // old flow step

            using (Trail.AddCheckpoint(ProcessCheckpoints.GatherData)) {
                var inputData = new LGRejectionInputData();
                inputData.Init(
                    this.oldWayAgent.Trail.MyInputData.DataAsOf,
                    this.oldWayAgent.Trail.MyInputData,
                    this.oldWayAgent.Trail.MyInputData
                    );

                GatherData(inputData);

                Trail.MyInputData.Init(inputData.DataAsOf, inputData, inputData);
            }             // gather data step

            using (Trail.AddCheckpoint(ProcessCheckpoints.MakeDecision)) {
                if (Trail.MyInputData.AutoDecisionInternalLogic)
                {
                    Trail.Dunno <InternalFlow>().Init();
                }
                else
                {
                    Trail.Dunno <LogicalGlueFlow>().Init();
                }

                if (LogicalGlueFlowFollowed)
                {
                    LogicalGlueFlow();
                }
                else
                {
                    InternalFlow();
                }
            }     // make decision step
        }         // RunPrimary
Ejemplo n.º 17
0
        // reset all instance state
        public override void Reset()
        {
            // reset the vehicle
            base.Reset();

            // max speed and max steering force (maneuverability)
            MaxSpeed = 2.0f;
            MaxForce = 8.0f;

            // initially stopped
            Speed = 0;

            // size of bounding sphere, for obstacle avoidance, etc.
            Radius = 0.5f;             // width = 0.7, add 0.3 margin, take half

            // set the path for this Pedestrian to follow
            path = Globals.GetTestPath();

            // set initial position
            // (random point on path + random horizontal offset)
            float   d            = path.TotalPathLength * Utilities.Random();
            float   r            = path.radius;
            Vector3 randomOffset = Vector3Helpers.RandomVectorOnUnitRadiusXZDisk() * r;

            Position = (path.MapPathDistanceToPoint(d) + randomOffset);

            // randomize 2D heading
            RandomizeHeadingOnXZPlane();

            // pick a random direction for path following (upstream or downstream)
            pathDirection = (Utilities.Random() > 0.5) ? -1 : +1;

            // trail parameters: 3 seconds with 60 points along the trail
            trail = new Trail(3, 60);

            // notify proximity database that our position has changed
            if (proximityToken != null)
            {
                proximityToken.UpdateForNewPosition(Position);
            }
        }
Ejemplo n.º 18
0
        async Task <ScenarioResult> Publish(MessageEventArgs messageArgs, CallbackQueryEventArgs callbackArgs)
        {
            SetFromUser(messageArgs, callbackArgs);

            EnsureReview();

            var dbReview = await Repository.AddReview(_fromUser, _toContact, new DBReview(_grade, _review));

            try
            {
                await SentNotificationToContact(dbReview);
            }
            catch
            {
            }

            var text = $"Великолепно! Отзыв отправлен.";
            await Trail.SendTextMessageAsync(text);

            return(await NewScenarioInit(new InitScenario()));
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Called when simulation is about to destroy itself, but right before it actually does it.
        /// </summary>
        protected override void OnPreDestroy()
        {
            // Notify modules of impending doom allowing them to save data.
            Scoring.Destroy();
            Tombstone.Destroy();
            Time.Destroy();
            EventDirector.Destroy();
            Trail.Destroy();

            // Null the destroyed instances.
            Scoring       = null;
            Tombstone     = null;
            Time          = null;
            EventDirector = null;
            Trail         = null;
            TotalTurns    = 0;
            Vehicle       = null;

            // Destroys game simulation instance.
            Instance = null;
        }
Ejemplo n.º 20
0
        // reset state
        public override void Reset()
        {
            base.Reset(); // reset the vehicle
            Speed = 0.0f;         // speed along Forward direction.
            MaxForce = 3000.7f;      // steering force is clipped to this magnitude
            MaxSpeed = 10;         // velocity is clipped to this magnitude

            // Place me on my part of the field, looking at oponnents goal
            SetPosition(b_ImTeamA ? Utilities.Random() * 20 : -Utilities.Random() * 20, 0, (Utilities.Random() - 0.5f) * 20);
            if (m_MyID < 9)
            {
                if (b_ImTeamA)
                    Position = (Globals.PlayerPosition[m_MyID]);
                else
                    Position = (new Vector3(-Globals.PlayerPosition[m_MyID].X, Globals.PlayerPosition[m_MyID].Y, Globals.PlayerPosition[m_MyID].Z));
            }
            m_home = Position;

            if (trail == null) trail = new Trail(10, 60);
            trail.Clear();    // prevent long streaks due to teleportation
        }
Ejemplo n.º 21
0
    private void bruteForce()
    {
        int n = TrailPlan.getNumberOfPoints();

        Point[] temp = new Point[n];
        for (int i = 0; i < n; i++)
        {
            temp [i] = (Point)TrailPlan.getPoint(i);
        }
        foreach (Point[] permutation in Permutation.getPermutations <Point>(temp))
        {
            ArrayList temporary = new ArrayList();
            for (int j = 0; j < permutation.Length; j++)
            {
                temporary.Add(permutation[j]);
            }
            Trail tempTrail = new Trail(temporary);
            bruteForcePopulation.saveTrail(permutationCounter, tempTrail);
            permutationCounter++;
        }
    }
Ejemplo n.º 22
0
        public async Task Handle_CallsFindByIdAsyncWithValidGuid_ReturnsTrailForGivenId()
        {
            //Arrange
            var id = Guid.Parse("08489d16-d7b1-4a90-8bef-0b4c94b50fe0");

            trailServiceMock.Setup(x => x.FindByIdAsync(id)).ReturnsAsync(TrailsMockData.TrailByIdMock);

            var validGuidRequest = new Details.Query()
            {
                Id = id
            };
            var cancellationToken = new CancellationToken();

            //Act
            Trail trail = await detailsHandler.Handle(validGuidRequest, cancellationToken);

            //Assert
            trailServiceMock.Verify(x => x.FindByIdAsync(id), Times.Once);
            Assert.IsType <Trail>(trail);
            Assert.Equal("Trail By Id", trail.Name);
        }
Ejemplo n.º 23
0
        //CREATE TRAIL
        public bool CreateTrail(TrailCreate model)
        {
            var entity =
                new Trail()
            {
                ParkId          = model.ParkId,
                Name            = model.Name,
                Length          = model.Length,
                IsTrailALoop    = model.IsTrailALoop,
                TrailDifficulty = model.TrailDifficulty,
                Description     = model.Description
            };



            using (var ctx = new ApplicationDbContext())
            {
                ctx.Trails.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public void Validate(int?minDifficulty, int?maxDifficulty, int?difficulty, bool isValidExpected)
        {
            // Arrange
            var trail = new Trail()
            {
                MinDifficulty = minDifficulty,
                MaxDifficulty = maxDifficulty
            };

            var objectUnderTest = new Tour_Trail
            {
                Trail      = trail,
                Difficulty = difficulty
            };

            // Act
            var result = objectUnderTest.IsValid();

            // Assert
            result.Should().Be(isValidExpected);
        }
Ejemplo n.º 25
0
        public IActionResult Store(Trail model)
        {
            if (ModelState.IsValid)
            {
                //List<Dictionary<string, object>> User = _dbConnector.Query($"INSERT INTO users (first_name, last_name, email, password, age) VALUES ('{model.FirstName}', '{model.LastName}', '{model.Email}', '{model.Password}', 0)");
                trailFactory.Add(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage));
                Console.WriteLine(messages);
                HttpContext.Session.SetObjectAsJson("TheList", ModelState.Values);
                return(RedirectToAction("NewTrail"));
            }

            //List<Dictionary<string, object>> Allq = _dbConnector.Query("SELECT * FROM quotes ORDER BY created_at Desc");
        }
Ejemplo n.º 26
0
        public override void MakeAndVerifyDecision()
        {
            Trail.SetTag(this.args.Tag).UniqueID = this.args.TrailUniqueID;

            AutomationCalculator.AutoDecision.AutoRejection.LGAgent oSecondary = null;

            try {
                RunPrimary();

                oSecondary = RunSecondary();

                ComparePrimaryAndSecondary(oSecondary);

                WasMismatch = !Trail.EqualsTo(oSecondary.Trail, CompareTrailsQuietly);
            } catch (Exception e) {
                Log.Error(e, "Exception during auto rejection.");
                Trail.Negative <ExceptionThrown>(true).Init(e);
            }             // try

            Trail.Save(DB, oSecondary == null ? null : oSecondary.Trail);
        }         // MakeAndVerifyDecision
Ejemplo n.º 27
0
    /// <summary>
    /// Draggin a Way , all below HTypes
    /// DoingNow == H.Trail  || DoingNow == H.BridgeTrail || DoingNow == H.BridgeRoad)
    /// </summary>
    void DrawWay()
    {
        Trail way = Control.CurrentSpawnBuild as Trail;

        if (Input.GetMouseButtonUp(0) && !_isDraggingWay)
        {
            _isDraggingWay = true;
        }
        if (_isDraggingWay)
        {
            if (way.CurrentLoop == H.None)
            {
                way.Drag();
            }
        }
        if (_isDraggingWay && Input.GetMouseButtonUp(0) && way.IsWayOk)
        {
            MouseUp();
            IsDraggingWay = false;
        }
    }
Ejemplo n.º 28
0
        private int SaveTrail(int userId, TrailDto model)
        {
            Trail trail = new Trail {
                Name   = model.Name,
                UserId = userId,
            };

            trail.TrailLocations = model.Locations
                                   .Select(i => new TrailLocation {
                Latitude  = i.Latitude,
                Longitude = i.Longitude,
                Order     = i.Order,
            })
                                   .ToList();

            context.Trails.Add(trail);

            context.SaveChanges();

            return(trail.TrailId);
        }
Ejemplo n.º 29
0
    private void SpawnTrail()
    {
        if (shooting)
        {
            bool spawn = true;

            float distance             = 0;
            float distance_from_player = 0;

            if (trails.Count > 0)
            {
                Trail curr_trail = trails[trails.Count - 1];

                distance             = Mathf.Abs(Vector2.Distance(weapon_head.transform.position, curr_trail.trile_go.transform.position));
                distance_from_player = Mathf.Abs(Vector2.Distance(gameObject.transform.position, weapon_head.transform.position));

                if (distance > 0.3f)
                {
                    spawn = true;
                }
                else
                {
                    spawn = false;
                }
            }

            if (spawn)
            {
                Trail trail = new Trail();
                trail.trile_go             = new GameObject();
                trail.distance_from_player = distance_from_player;

                SpriteRenderer sr = trail.trile_go.AddComponent <SpriteRenderer>();

                sr.sprite = trail_sprite;

                trails.Add(trail);
            }
        }
    }
Ejemplo n.º 30
0
        /// <summary>
        /// Satisfies the starts.
        /// </summary>
        /// <param name="v1">The v1.</param>
        /// <param name="v2">The v2.</param>
        /// <param name="trail">The trail.</param>
        /// <returns></returns>
        private static bool SatisfyStarts(Variable v1, Variable v2, Trail trail)
        {
            var d1 = (AllenDomain)v1.Domain;

            if (d1.Empty)
            {
                return(false);
            }
            var d3 = (AllenDomain)d1.Clone();
            var d2 = (AllenDomain)v2.Domain;

            if (d2.Empty)
            {
                return(false);
            }
            for (int st1 = d1.Min(); st1 <= d1.Max(); st1 += d1.Step)
            {
                bool found = false;
                for (int st2 = d2.Min(); st2 <= d2.Max(); st2 += d2.Step)
                {
                    int lt1 = st1 + d1.Duration;
                    int lt2 = st2 + d2.Duration;
                    if ((st1 == st2) && (lt1 < lt2))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    d3.Remove(st1);
                    if (d3.Size() == 0)
                    {
                        return(false);
                    }
                }
            }
            //v1.UpdateDomain(d3, trail);
            return(true);
        }
Ejemplo n.º 31
0
 public Bitmap GetTrail(int width, int height)
 {
     if (width > 0 && height > 0)
     {
         Bitmap   bmp    = new Bitmap(width, height);
         Graphics g      = Graphics.FromImage(bmp);
         PointF   center = new PointF(width / 2f, height / 2f);
         var      curr   = Trail.GetEnumerator();
         if (curr.MoveNext())
         {
             var prev = curr;
             while (curr.MoveNext())
             {
                 g.DrawLine(new Pen(colorTrail, 1), curr.Current.X + center.X, curr.Current.Y + center.Y,
                            prev.Current.X + center.X, prev.Current.Y + center.Y);
                 prev = curr;
             }
         }
         return(bmp);
     }
     return(null);
 }
    public override async Task <ActionResult <int> > HandleAsync(AddTrailRequest request, CancellationToken cancellationToken = default)
    {
        var trail = new Trail
        {
            Name          = request.Trail.Name,
            Description   = request.Trail.Description,
            Location      = request.Trail.Location,
            TimeInMinutes = request.Trail.TimeInMinutes,
            Length        = request.Trail.Length,
            Waypoints     = request.Trail.Waypoints.Select(wp => new Waypoint
            {
                Latitude  = wp.Latitude,
                Longitude = wp.Longitude
            }).ToList()
        };

        await _database.Trails.AddAsync(trail, cancellationToken);

        await _database.SaveChangesAsync(cancellationToken);

        return(Ok(trail.Id));
    }
Ejemplo n.º 33
0
        private void ManageTrail()
        {
            trail = trail ?? new Trail(Main.instance.GraphicsDevice, 50, new RoundedTip(12), factor => (10 + factor * 25) * trailWidth, factor =>
            {
                return(new Color(120, 20 + (int)(100 * factor.X), 255) * factor.X * trailWidth);
            });

            trail.Positions = cache.ToArray();

            trail2 = trail2 ?? new Trail(Main.instance.GraphicsDevice, 50, new RoundedTip(6), factor => (80 + 0 + factor * 0) * trailWidth, factor =>
            {
                return(new Color(100, 20 + (int)(60 * factor.X), 255) * factor.X * 0.15f * trailWidth);
            });

            trail2.Positions = cache.ToArray();

            if (projectile.velocity.Length() > 1)
            {
                trail.NextPosition  = projectile.Bottom + new Vector2(0, 20) + projectile.velocity;
                trail2.NextPosition = projectile.Bottom + new Vector2(0, 20) + projectile.velocity;
            }
        }
Ejemplo n.º 34
0
        private void ManageTrail()
        {
            trail = trail ?? new Trail(Main.instance.GraphicsDevice, 33, new TriangularTip(1), factor => 38 * (1 - Progress), factor =>
            {
                return(Color.Lerp(new Color(180, 180, 255), new Color(85, 85, 200), Progress));
            });

            trail2 = trail2 ?? new Trail(Main.instance.GraphicsDevice, 33, new TriangularTip(1), factor => 20 * (1 - Progress), factor =>
            {
                return(Color.White);
            });
            float   nextplace = 33f / 32f;
            Vector2 offset    = new Vector2((float)Math.Sin(nextplace), (float)Math.Cos(nextplace));

            offset *= Radius;

            trail.Positions    = cache.ToArray();
            trail.NextPosition = projectile.Center + offset;

            trail2.Positions    = cache.ToArray();
            trail2.NextPosition = projectile.Center + offset;
        }
Ejemplo n.º 35
0
        private void ManageTrail()
        {
            trail = trail ?? new Trail(Main.instance.GraphicsDevice, 90, new TriangularTip(20 * 4), factor => factor * 20, factor =>
            {
                if (factor.X > 0.95f)
                {
                    return(Color.White * 0);
                }

                float alpha = 1;

                if (projectile.timeLeft < 20)
                {
                    alpha = projectile.timeLeft / 20f;
                }

                return(new Color(255, 175 + (int)((float)Math.Sin(factor.X * 3.14f * 5) * 25), 100) * (float)Math.Sin(factor.X * 3.14f) * alpha);
            });

            trail.Positions    = cache.ToArray();
            trail.NextPosition = projectile.Center + projectile.velocity;
        }
Ejemplo n.º 36
0
 public IActionResult Create(TrailViewModel model)
 {
     if (ModelState.IsValid)
     {
         Trail newTrail = new Trail
         {
             Name        = model.Name,
             Description = model.Description,
             Length      = model.Length,
             Elevation   = model.Elevation,
             Longitude   = model.Longitude,
             Latitude    = model.Latitude,
         };
         _trailfactory.AddNewTrail(newTrail);
     }
     else
     {
         // ViewBag.errors = ModelState.Values;
         return(View("New"));
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 37
0
 void Start()
 {
     bite = GetComponent<BiteScript>();
     trail = transform.parent.gameObject.GetComponent<Trail>();
     levelingSystem = GameObject.FindObjectOfType<LevelingSystem>();
 }
Ejemplo n.º 38
0
 void Awake()
 {
     if( instance == null ){
         instance = this;
     }
 }
	void Awake(){
		m_Trail = GetComponentInChildren<Trail> ();
		m_SmoothTrail = GetComponentInChildren<SmoothTrail> ();
		m_SmokeTrail = GetComponentInChildren<SmokeTrail> ();
	}
Ejemplo n.º 40
0
    void Start()
    {
        if(isRemote == false) {
            bite = GetComponent<BiteScript>();
            trail = transform.parent.gameObject.GetComponent<Trail>();
            levelingSystem = GameObject.FindObjectOfType<LevelingSystem>();
        }

        BenchmarkController benchmarker = BenchmarkController.instance;
        if(benchmarker != null) {
            benchmarker.SettleSnakeHead(this);
        }
    }
Ejemplo n.º 41
0
        // reset state
        public override void Reset()
        {
            base.Reset();  // reset the vehicle

            Speed = 3;             // speed along Forward direction.
            MaxForce = 3.0f;        // steering force is clipped to this magnitude
            MaxSpeed = 3.0f;        // velocity is clipped to this magnitude

            Avoiding = false;         // not actively avoiding

            RandomizeStartingPositionAndHeading();  // new starting position

            trail = new Trail();
            trail.Clear();     // prevent long streaks due to teleportation
        }
Ejemplo n.º 42
0
        // reset all instance state
        public override void Reset()
        {
            // reset the vehicle
            base.Reset();

            // max speed and max steering force (maneuverability)
            MaxSpeed = 2.0f;
            MaxForce = 8.0f;

            // initially stopped
            Speed = 0;

            // size of bounding sphere, for obstacle avoidance, etc.
            Radius = 0.5f; // width = 0.7, add 0.3 margin, take half

            // set the path for this Pedestrian to follow
            path = Globals.GetTestPath();

            // set initial position
            // (random point on path + random horizontal offset)
            float d = path.TotalPathLength * Utilities.Random();
            float r = path.radius;
            Vector3 randomOffset = Vector3Helpers.RandomVectorOnUnitRadiusXZDisk() * r;
            Position = (path.MapPathDistanceToPoint(d) + randomOffset);

            // randomize 2D heading
            RandomizeHeadingOnXZPlane();

            // pick a random direction for path following (upstream or downstream)
            pathDirection = (Utilities.Random() > 0.5) ? -1 : +1;

            // trail parameters: 3 seconds with 60 points along the trail
            trail = new Trail(3, 60);

            // notify proximity database that our position has changed
            if (proximityToken != null) proximityToken.UpdateForNewPosition(Position);
        }
Ejemplo n.º 43
0
	// Use this for initialization
	void Start () {
        trail = new Trail(this);
        player.trail = trail;
        foods = new List<Transform>();
        GoToNextDay();
    }
Ejemplo n.º 44
0
 protected internal override bool Satisfy(Trail trail)
 {
     var net = (CourseNetwork) Network;
     var prof = new int[net.Professors.Count];
     foreach (Variable var in v)
     {
         if (!var.IsValueType)
         {
             Domain d = var.Domain;
             if (d.Size() != 1)
                 continue;
             prof[(int) d.Element()]++;
             if (prof[(int) d.Element()] > ((Professor) net.Professors[(int) d.Element()]).Courses)
             {
                 return false;
             }
             if (prof[(int) d.Element()] == ((Professor) net.Professors[(int) d.Element()]).Courses)
             {
                 foreach (Variable va in v)
                 {
                     if ((va != var) && (va.Domain.Size() != 1))
                     {
                         var newD = (IntDomain) va.Domain;
                         newD = (IntDomain) newD.Delete(d.Element());
                         if (trail != null)
                         {
                             va.UpdateDomain(newD, trail);
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 45
0
        public void drawTrail(ref  SpriteBatch batch, ref Trail trail)
        {
            Color _color = Color.White;

            for (int i = Trail.SIZE - 1; i >= 0; i--)
            {
                _color.A = (byte)((trail.Positions.Count - i) * (255 / trail.Positions.Count));
                trail.updateRectangle(i);
                batch.Draw(textures["Pandas"], trail.Rectangle, trail.Sources[i], _color);
            }
        }
Ejemplo n.º 46
0
        /// <summary>
        /// Satisfies the specified trail.
        /// </summary>
        /// <param name="trail">The trail.</param>
        /// <returns></returns>
        protected internal override bool Satisfy(Trail trail)
        {
            switch (_relation)
            {
                case AllenEvents.PRECEDES:
                    return SatisfyPrecedes(Vars[0], Vars[1]);

                case AllenEvents.PRECEDEDBY:
                    return SatisfyPrecededby(Vars[0], Vars[1]);

                case AllenEvents.EQUALS:
                    return SatisfyEquals(Vars[0], Vars[1]);

                case AllenEvents.MEETS:
                    return SatisfyMeets(Vars[0], Vars[1]);

                case AllenEvents.METBY:
                    return SatisfyMetby(Vars[0], Vars[1]);

                case AllenEvents.DURING:
                    return SatisfyDuring(Vars[0], Vars[1]);

                case AllenEvents.CONTAINS:
                    return SatisfyContains(Vars[0], Vars[1]);

                case AllenEvents.STARTS:
                    return SatisfyStarts(Vars[0], Vars[1]);

                case AllenEvents.STARTEDBY:
                    return SatisfyStartedby(Vars[0], Vars[1]);

                case AllenEvents.FINISHES:
                    return SatisfyFinishes(Vars[0], Vars[1]);

                case AllenEvents.FINISHEDBY:
                    return SatisfyFinishedby(Vars[0], Vars[1]);

                case AllenEvents.OVERLAPS:
                    return SatisfyOverlaps(Vars[0], Vars[1]);

                case AllenEvents.OVERLAPPEDBY:
                    return SatisfyOverlappedby(Vars[0], Vars[1]);
            }
            return false;
        }
Ejemplo n.º 47
0
 public void AddTrail(Trail trail)
 {
 }
Ejemplo n.º 48
0
    void HandleClientMessages(object peer)
    {
        NetIncomingMessage msg;
        while ((msg = client.ReadMessage()) != null)
        {
            switch (msg.MessageType)
            {
                case NetIncomingMessageType.Data:
                    switch((ShapeCustomNetMessageType)msg.ReadByte())
                    {
                        //Contains the current locations of the players on the server
                        case ShapeCustomNetMessageType.LocationUpdate:
                            int numOfPlayers = msg.ReadInt32();

                            for (int i = 0; i < numOfPlayers; i++)
                            {
                                int index = msg.ReadInt32();
                                float powr = msg.ReadFloat();
                                float time = msg.ReadFloat();
                                Vector2 pos = msg.ReadVector2();

                                if (index == player.indexOnServer)
                                {
                                    player.power = powr;
                                    player.positions.Add(new PositionInTime(time, pos, false));
                                }
                                else if (playersOnSameServer[index] != null)
                                {
                                    playersOnSameServer[index].power = powr;
                                    playersOnSameServer[index].positions.Add(new PositionInTime(time, pos, false));
                                }

                                int numTrail = msg.ReadInt32();

                                for(int j = 0; j < numTrail; j++)
                                {
                                    Vector2 position = msg.ReadVector2();
                                    float size = msg.ReadFloat();

                                    if(index == player.indexOnServer)
                                    {
                                        if(j < player.trail.Count)
                                        {
                                            if (player.trail[j] != null)
                                            {
                                                player.trail[j].position = position;
                                                player.trail[j].size = size;
                                                player.trail[j].lastUpdatedValues = System.Environment.TickCount - lastReceivedLocationUpdate;
                                            }

                                            if (numTrail < player.trail.Count)
                                                player.trail.RemoveRange(numTrail - 1,player.trail.Count - numTrail);
                                        }
                                        else
                                        {
                                            Trail t = new Trail(position, size, Color.Beige, spriteBatch.GraphicsDevice, null);
                                            t.lastUpdatedValues = System.Environment.TickCount - lastReceivedLocationUpdate;
                                            player.trail.Add(t);
                                        }
                                    }
                                    else if (playersOnSameServer[index] != null)
                                    {
                                        if(j < playersOnSameServer[index].trail.Count)
                                        {
                                            if (playersOnSameServer[index].trail[j] != null)
                                            {
                                                playersOnSameServer[index].trail[j].position = position;
                                                playersOnSameServer[index].trail[j].size = size;
                                                playersOnSameServer[index].trail[j].lastUpdatedValues = System.Environment.TickCount - lastReceivedLocationUpdate;
                                            }

                                            if (numTrail < playersOnSameServer[index].trail.Count)
                                                playersOnSameServer[index].trail.RemoveRange(numTrail - 1, playersOnSameServer[index].trail.Count - numTrail);
                                        }
                                        else
                                        {
                                            Trail t = new Trail(position, size, Color.Beige, spriteBatch.GraphicsDevice, null);
                                            t.lastUpdatedValues = System.Environment.TickCount - lastReceivedLocationUpdate;
                                            playersOnSameServer[index].trail.Add(t);
                                        }
                                    }
                                }
                            }

                            int numRemnants = msg.ReadInt32();

                            for (int i = 0; i < numRemnants; i++ )
                            {
                                Vector2 pos = msg.ReadVector2();
                                float size = msg.ReadFloat();

                                if(i < remnants.Count)
                                {
                                    remnants[i].position = pos;
                                    remnants[i].size = size;
                                    remnants[i].lastUpdatedValues = System.Environment.TickCount - lastReceivedLocationUpdate;
                                }
                                else
                                {
                                    CollisionRemnant newRemnant = new CollisionRemnant(pos, size, Color.GhostWhite, spriteBatch.GraphicsDevice, null);
                                    remnants.Add(newRemnant);
                                }

                                if (numRemnants < remnants.Count)
                                    remnants.RemoveRange(numRemnants - 1, remnants.Count - numRemnants);
                            }

                            lastReceivedLocationUpdate = System.Environment.TickCount;
                            break;
                        //A new player has joined the server which has to be added to this client
                        case ShapeCustomNetMessageType.NewPlayerJoined:
                            int indexOnServer = msg.ReadInt32();
                            ShapeTeam team = (ShapeTeam)msg.ReadByte();
                            int power = msg.ReadInt32();

                            Player newPlayer = new Player(spriteBatch.GraphicsDevice);

                            newPlayer.indexOnServer = indexOnServer;
                            newPlayer.SetTeam(team);
                            newPlayer.power = power;

                            newPlayer.LoadContent(cManager);

                            playersOnSameServer[indexOnServer] = newPlayer;

                            //MessageBox.Show("New player jioned");
                            break;
                        case ShapeCustomNetMessageType.SetupSuccessful:
                            //Have our index on server handed to us
                            player.indexOnServer = msg.ReadInt32();
                            player.SetTeam((ShapeTeam)msg.ReadByte());

                            int numOfPlayers1 = msg.ReadInt32();

                            for (int i = 0; i < numOfPlayers1; i++ )
                            {
                                Player p = new Player(spriteBatch.GraphicsDevice);
                                int index = msg.ReadInt32();
                                p.indexOnServer = index;
                                p.SetTeam((ShapeTeam)msg.ReadByte());

                                int powaar = msg.ReadInt32();
                                //p.power = powaar;

                                p.LoadContent(cManager);

                                playersOnSameServer[index] = p;
                            }
                            break;
                        case ShapeCustomNetMessageType.SetupFailed:
                            MessageBox.Show(msg.ReadString());
                            break;
                    }
                    break;
                case NetIncomingMessageType.DiscoveryResponse:
                    //MessageBox.Show(msg.ReadString() + " | " + msg.ReadIPEndPoint() + " | " + msg.SenderEndPoint);

                    if (client.GetConnection(msg.SenderEndPoint) == null)
                        ConnectToServer(msg.SenderEndPoint.Address.ToString(),55678);
                    break;
                case NetIncomingMessageType.StatusChanged:
                    switch ((NetConnectionStatus)msg.ReadByte())
                    {
                        //When connected to the server
                        case NetConnectionStatus.Connected:
                            //1. Handle hailmessage containing server info
                            int maxPlayersOnServer = msg.SenderConnection.RemoteHailMessage.ReadInt32();
                            playersOnSameServer = new Player[maxPlayersOnServer];

                            //2. Send client info
                            NetOutgoingMessage outMsg = client.CreateMessage();
                            outMsg.Write((byte)ShapeCustomNetMessageType.SetupRequest);
                            //outMsg.Write((byte)ShapeTeam.BLUE);
                            outMsg.Write("UserName");
                            client.SendMessage(outMsg, NetDeliveryMethod.ReliableOrdered);
                            break;
                        //When disconnected from the server
                        case NetConnectionStatus.Disconnected:
                            //Contains a string of the reason for the disconnection
                            string reason = msg.ReadString();
                            if (string.IsNullOrEmpty(reason))
                                MessageBox.Show("Disconnected! Reason unknown.");
                            else
                                MessageBox.Show("Disconnected, Reason: " + reason);

                            HandleDisconnection();
                            break;
                    }
                    break;
                default:
                    //Console.WriteLine("Unhandled type: " + msg.MessageType);
                    break;
            }
            client.Recycle(msg);
        }
    }
Ejemplo n.º 49
0
 public void RemoveTrail(Trail trail)
 {
 }
Ejemplo n.º 50
0
        // reset state
        public override void Reset()
        {
            // reset the underlying vehicle class
            base.Reset();

            // initially stopped
            Speed = 0;

            // Assume top speed is 20 meters per second (44.7 miles per hour).
            // This value will eventually be supplied by a higher level module.
            MaxSpeed = 20;

            // steering force is clipped to this magnitude
            MaxForce = MaxSpeed * 0.4f;

            // vehicle is 2 meters wide and 3 meters long
            halfWidth = 1.0f;
            halfLength = 1.5f;

            // init dynamically controlled radius
            AdjustVehicleRadiusForSpeed();

            // not previously avoiding
            annotateAvoid = Vector3.Zero;

            // 10 seconds with 200 points along the trail
            if (trail == null) trail = new Trail(10, 200);

            // prevent long streaks due to teleportation
            trail.Clear();

            // first pass at detecting "stuck" state
            stuck = false;

            // QQQ need to clean up this hack
            qqqLastNearestObstacle = Vector3.Zero;

            // master look ahead (prediction) time
            baseLookAheadTime = 3;

            if (demoSelect == 2)
            {
                lapsStarted++;
                float s = worldSize;
                float d = (float)pathFollowDirection;
                Position = (new Vector3(s * d * 0.6f, 0, s * -0.4f));
                RegenerateOrthonormalBasisUF(Vector3.Right * d);
            }

            // reset bookeeping to detect stuck cycles
            ResetStuckCycleDetection();

            // assume no previous steering
            currentSteering = Vector3.Zero;

            // assume normal running state
            dtZero = false;

            // QQQ temporary global QQQoaJustScraping
            QQQoaJustScraping = false;

            // state saved for speedometer
            annoteMaxRelSpeed = annoteMaxRelSpeedCurve = annoteMaxRelSpeedPath = 0;
            annoteMaxRelSpeed = annoteMaxRelSpeedCurve = annoteMaxRelSpeedPath = 1;
        }
Ejemplo n.º 51
0
        // reset state
        public override void Reset()
        {
            // reset vehicle state
            base.Reset();

            // speed along Forward direction.
            Speed = startSpeed;

            // initial position along X axis
            SetPosition(startX, 0, 0);

            // steering force clip magnitude
            MaxForce = 0.3f;

            // velocity  clip magnitude
            MaxSpeed = 1.5f;

            // for next instance: step starting location
            startX += 2;

            // for next instance: step speed
            startSpeed += 0.15f;

            // 15 seconds and 150 points along the trail
            trail = new Trail(15, 150);
        }