Exemple #1
0
 private static void VillagerBeginPath(object sender, UnitBeginPathEventArgs args)
 {
     IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<EvolutionHub>();
     hubContext.Clients.All.unitBeginPath(args.Unit.Id, args.Path);
 }
Exemple #2
0
        /// <summary>
        /// Engine event. Notifies the unit that it's starting to move.
        /// </summary>
        /// <param name="targetLocation">Can be only an adiacent cell.</param>
        public virtual void BeginMove(Location targetLocation)
        {
            if (OnBeginMove != null)
            {
                UnitBeginMoveEventArgs args = new UnitBeginMoveEventArgs
                {
                    Unit = this,
                    LastLocation = Location,
                    NewLocation = targetLocation
                };
                OnBeginMove(this, args);
            }

            if (RouteTotalLegsCount == RemainingRoute.Count)
            {
                if (OnBeginPath != null)
                {
                    UnitBeginPathEventArgs args = new UnitBeginPathEventArgs
                    {
                        Unit = this,
                        Path = RemainingRoute
                    };

                    OnBeginPath(this, args);
                }
            }
            else
            {
                if (OnContinuePath != null)
                {
                    UnitContinuePathEventArgs args = new UnitContinuePathEventArgs
                    {
                        Unit = this,
                        Path = RemainingRoute
                    };

                    OnContinuePath(this, args);
                }
            }
        }