Example #1
0
 private static void VillagerEndMove(object sender, UnitEndMoveEventArgs args)
 {
     IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<EvolutionHub>();
     hubContext.Clients.All.unitEndMove(args.Unit.Id, args.LastLocation, args.NewLocation);
 }
Example #2
0
        /// <summary>
        /// Sets the new location and notifies the UI.
        /// </summary>
        /// <param name="location">The new location.</param>
        protected void EndMove(Location location)
        {
            Location lastLocation = Location;
            Location = location;
            Logging.LogUnit(Id, string.Format("(x:{0}, y:{1})", location.X, location.Y));

            if (OnEndMove != null)
            {
                UnitEndMoveEventArgs args = new UnitEndMoveEventArgs
                {
                    Unit = this,
                    LastLocation = lastLocation,
                    NewLocation = location
                };

                OnEndMove(this, args);
            }

            //if we arrived at the destination then raise the OnEndPath event
            if (Location == Destination)
            {
                RouteEnded(false);
            }
        }