Example #1
0
        /// <summary>
        /// Print menu to navigate between traveling, buying, selling, etc
        /// </summary>
        public async Task StartAsync(IDialogContext context)
        {
            EventInfo randomEvent;

            context.UserData.TryGetValue(StateKeys.RandomEvent, out randomEvent);

            var user = this.GetUser(context);

            // setup hero card
            var buttons = this.CreateButtonMenu(new string[] { "Inventory", "Buy", "Sell", "Prices", "Travel", "Loan Shark" });

            var location = this.GetLocation(context);
            IMessageActivity activity = this.SetupActivity(context, buttons,
                                                           $"You have {user.Wallet:C0}. You're in {location.Name}. What do you want to do?");

            await context.PostAsync(activity);

            // check for random event text
            if (randomEvent != null)
            {
                if (randomEvent.IsGunEvent)
                {
                    context.Call(new BuyGunDialog(), ResumeMainMenu);
                }
                else if (randomEvent.IsCombatEvent)
                {
                    var combat = new CombatContext();
                    context.UserData.SetValue(StateKeys.CombatContext, combat);
                    context.Call(new CombatDialog(), ResumeMainMenu);
                }
                else
                {
                    await context.PostAsync(randomEvent.EventText);

                    context.Wait(MessageReceivedAsync);
                }

                context.UserData.RemoveValue(StateKeys.RandomEvent);
            }
            else
            {
                // get day of game
                if (user.DayOfGame == Defaults.GameEndDay - 1)
                {
                    await context.PostAsync(Defaults.GameEndWarningText);
                }

                context.Wait(MessageReceivedAsync);
            }
        }
Example #2
0
        internal static IEnumerable <Vector3> GeneratePossibleTargetPointsInHalfCircleFacingAwayFromTarget(
            this Vector3 center, CombatContext context, Vector3 target, float radius, int numberOfPoints = 32)
        {
            if (BelphegorSettings.Instance.Debug.IsDebugDrawingActive)
            {
                PointGenerationDebugDrawer.Instance.ClearDebugOutput();
            }

            PointGeneratorCache pointGenerator = new PointGeneratorCache(context);

            float deltaY = target.Y - center.Y;
            float deltaX = target.X - center.X;
            float alpha  = Convert.ToSingle(Math.Atan2(deltaY, deltaX) + Math.PI / 2);

            return(pointGenerator.GetNavigateablePointsInHalfCircleInRandomOrder(center, radius, numberOfPoints, alpha));
        }
Example #3
0
        internal static Vector3 GeneratePointAtPosition(this Vector3 center, CombatContext context, float radius,
                                                        int pointNumber = 0, bool useLocalNavigation = true, int numberOfPoints = 32)
        {
            if (BelphegorSettings.Instance.Debug.IsDebugDrawingActive)
            {
                PointGenerationDebugDrawer.Instance.ClearDebugOutput();
            }

            var            pointGenerator = new PointGeneratorCache(context);
            List <Vector3> points         = pointGenerator.GetNavigateablePoints(center, radius, numberOfPoints).ToList();
            int            count          = points.Count;

            if (pointNumber < count)
            {
                return(points.ElementAt(pointNumber));
            }
            return(count > 0 ? points[0] : center);
        }
Example #4
0
 internal PointGeneratorCache(CombatContext context)
 {
     _context = context;
 }
Example #5
0
        internal static IEnumerable <Vector3> GeneratePossibleTargetPoints(this Vector3 center, CombatContext context, float radius,
                                                                           bool useLocalNavigation = true,
                                                                           int numberOfPoints      = 32)
        {
            if (BelphegorSettings.Instance.Debug.IsDebugDrawingActive)
            {
                PointGenerationDebugDrawer.Instance.ClearDebugOutput();
            }

            PointGeneratorCache pointGenerator = new PointGeneratorCache(context);

            IEnumerable <Vector3> returnEnum = useLocalNavigation ? pointGenerator.GetNavigateablePointsInRandomOrder(center, radius, numberOfPoints) : pointGenerator.GetRaycastReachablePointsInRanomOrder(center, radius, numberOfPoints);

            for (var i = radius + 5; i <= radius + 20; i += 5)
            {
                returnEnum = returnEnum.Union(useLocalNavigation ? pointGenerator.GetNavigateablePointsInRandomOrder(center, i, numberOfPoints) : pointGenerator.GetRaycastReachablePointsInRanomOrder(center, i, numberOfPoints));
            }

            return(returnEnum);
        }
Example #6
0
        public virtual void DoHarmful( Mobile target, bool indirect )
        {
            if ( target == null )
                return;

            bool isCriminal = IsHarmfulCriminal( target );

            OnHarmfulAction( target, isCriminal );
            target.AggressiveAction( this, isCriminal );

            Region.OnDidHarmful( this, target );
            target.Region.OnGotHarmful( this, target );

            if ( !indirect )
                Combatant = target;

            #region Combat
            if ( m_CombatContext == null )
                m_CombatContext = new CombatContext( this );

            m_CombatContext.RefreshExpireCombatant();
            #endregion

            HarmfulActionEventArgs args = HarmfulActionEventArgs.Create( this, target, isCriminal );

            EventSink.Instance.InvokeHarmfulAction( args );

            args.Free();
        }
Example #7
0
        public virtual void AggressiveAction( Mobile aggressor, bool criminal )
        {
            if ( aggressor == this )
                return;

            AggressiveActionEventArgs args = AggressiveActionEventArgs.Create( this, aggressor, criminal );

            EventSink.Instance.InvokeAggressiveAction( args );

            args.Free();

            #region Combat
            if ( Combatant == aggressor )
            {
                if ( m_CombatContext == null )
                    m_CombatContext = new CombatContext( this );

                m_CombatContext.RefreshExpireCombatant();
            }
            #endregion

            bool addAggressor = true;

            List<AggressorInfo> list = m_Aggressors;

            for ( int i = 0; i < list.Count; ++i )
            {
                AggressorInfo info = list[i];

                if ( info.Attacker == aggressor )
                {
                    info.Refresh();
                    info.CriminalAggression = criminal;
                    info.CanReportMurder = criminal;

                    addAggressor = false;
                }
            }

            list = aggressor.m_Aggressors;

            for ( int i = 0; i < list.Count; ++i )
            {
                AggressorInfo info = list[i];

                if ( info.Attacker == this )
                {
                    info.Refresh();

                    addAggressor = false;
                }
            }

            bool addAggressed = true;

            list = m_Aggressed;

            for ( int i = 0; i < list.Count; ++i )
            {
                AggressorInfo info = list[i];

                if ( info.Defender == aggressor )
                {
                    info.Refresh();

                    addAggressed = false;
                }
            }

            list = aggressor.m_Aggressed;

            for ( int i = 0; i < list.Count; ++i )
            {
                AggressorInfo info = list[i];

                if ( info.Defender == this )
                {
                    info.Refresh();
                    info.CriminalAggression = criminal;
                    info.CanReportMurder = criminal;

                    addAggressed = false;
                }
            }

            bool setCombatant = false;

            if ( addAggressor )
            {
                m_Aggressors.Add( AggressorInfo.Create( aggressor, this, criminal ) );

                if ( this.CanSee( aggressor ) && m_Client != null )
                    m_Client.Send( new MobileIncoming( this, aggressor ) );

                if ( Combatant == null )
                    setCombatant = true;

                UpdateAggrExpire();
            }

            if ( addAggressed )
            {
                aggressor.m_Aggressed.Add( AggressorInfo.Create( aggressor, this, criminal ) );

                if ( this.CanSee( aggressor ) && m_Client != null )
                    m_Client.Send( new MobileIncoming( this, aggressor ) );

                if ( Combatant == null )
                    setCombatant = true;

                UpdateAggrExpire();
            }

            if ( setCombatant )
                Combatant = aggressor;

            Region.OnAggressed( aggressor, this, criminal );
        }
 public PlayerModelsController(CombatContext context)
 {
     _context = context;
 }
Example #9
0
 public Combatant GetNextCombatant(CombatContext combatContext)
 {
     _monsterIsNext = !_monsterIsNext;
     return _monsterIsNext ? (Combatant) combatContext.Monster : combatContext.Player;
 }