Example #1
0
        private void OnAccept(GumpButton button)
        {
            if (AcceptHandler != null)
            {
                AcceptHandler(button);
            }

            if (String.IsNullOrWhiteSpace(InvasionName))
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                {
                    Title         = "Choose an Invasion Name",
                    Html          = "Your invasion must have a name!",
                    AcceptHandler = b => Refresh(true)
                });
                return;
            }

            if (Region.Regions.Find(x => x.Name == InvasionRegion) == null)
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                {
                    Title         = "Region Does Not Exist",
                    Html          = "The region you input does not exist.",
                    AcceptHandler = b => Refresh(true)
                });
                return;
            }

            if (Levels.Count == 0)
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                {
                    Title         = "Invalid Levels",
                    Html          = "You must specify at least one valid level.",
                    AcceptHandler = b => Refresh(true)
                });
                return;
            }

            EventInvasions.GenerateInvasion(InvasionName, InvasionRegion, Levels, Gates);

            Close();
        }
Example #2
0
        public void AddScore(Mobile damager, int amount)
        {
            Mobile creditMob = null;

            var oneHandedWeapon = damager.FindItemOnLayer(Layer.OneHanded) as BaseWeapon;
            var twoHandedWeapon = damager.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
            var equipRanged     = twoHandedWeapon as BaseRanged;

            if (damager is BaseCreature)
            {
                var bc = (BaseCreature)damager;

                if (bc.ControlMaster is PlayerMobile)
                {
                    creditMob = bc.ControlMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.TamerMod));
                }
                else if (bc.SummonMaster is PlayerMobile)
                {
                    creditMob = bc.SummonMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.SummonMod));
                }
                else if (bc.BardMaster is PlayerMobile)
                {
                    creditMob = bc.BardMaster;
                    amount    = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.BardMod));
                }
            }
            else if (damager is PlayerMobile)
            {
                creditMob = damager;
                if (equipRanged != null)
                {
                    if (twoHandedWeapon.Slayer != SlayerName.None)
                    {
                        amount = (int)(Math.Ceiling(amount * 0.5));
                    }

                    amount = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.ArcherMod));
                }
                else if (oneHandedWeapon != null || twoHandedWeapon != null)
                {
                    if (oneHandedWeapon != null && oneHandedWeapon.Slayer != SlayerName.None ||
                        twoHandedWeapon != null && twoHandedWeapon.Slayer != SlayerName.None)
                    {
                        amount = (int)(Math.Ceiling(amount * 0.5));
                    }

                    amount = (int)(Math.Ceiling(amount * EventInvasions.CSOptions.MeleeMod));
                }
            }

            if (creditMob != null)
            {
                PlayerInvasionProfile profile = EventInvasions.EnsureProfile(creditMob as PlayerMobile);
                profile.AddScore(amount, this);
                if (ParticipantsScores.ContainsKey(creditMob as PlayerMobile))
                {
                    ParticipantsScores[creditMob as PlayerMobile] += amount;
                }
                else
                {
                    ParticipantsScores.Add(creditMob as PlayerMobile, amount);
                }
            }
        }
Example #3
0
        protected override void CompileEntryLayout(
            SuperGumpLayout layout, int length, int index, int pIndex, int yOffset, Invasion entry)
        {
            yOffset = 116 + pIndex * 67;

            layout.Add(
                "entry" + index,
                () =>
            {
                AddBackground(54, yOffset, 664, 72, 9260);

                AddLabel(71, yOffset + 10, 0, @"Invasion Name");
                AddLabel(71, yOffset + 38, 0, entry.InvasionName);

                AddLabel(208, yOffset + 10, 0, @"Invasion Region");
                AddLabel(208, yOffset + 38, 0, entry.RegionName);

                AddLabel(335, yOffset + 10, 0, @"Date");
                AddLabel(335, yOffset + 38, 0, entry.DateStarted.ToShortDateString());

                AddLabel(439, yOffset + 10, 0, @"Status");
                AddLabel(439, yOffset + 38, entry.Status.AsHue(), entry.Status.ToString());

                AddLabel(505, yOffset + 10, 0, @"View Details");
                AddButton(518, yOffset + 38, 2074, 2076, b =>
                {
                    new InvasionDetailsUI(User, Hide(true), entry).
                    Send <InvasionDetailsUI>();
                });

                if (User.AccessLevel < EventInvasions.Access && entry.Status != InvasionStatus.Waiting)
                {
                    AddLabel(605, yOffset + 10, 0, @"View Scoreboard");
                    AddButton(630, yOffset + 38, 2074, 2076, b => Send(new InvasionScoresOverviewGump(User, entry, Refresh(true))));
                }

                if (User.AccessLevel >= EventInvasions.Access)
                {
                    if (entry.Status == InvasionStatus.Running)
                    {
                        AddLabel(600, yOffset + 10, 0, @"Cancel");
                        AddButton(590, yOffset + 38, 2071, 2073, b =>
                        {
                            if (entry.Status == InvasionStatus.Running)
                            {
                                entry.FinishInvasion();
                            }
                            Refresh(true);
                        });
                    }

                    if (entry.Status == InvasionStatus.Waiting)
                    {
                        AddLabel(600, yOffset + 10, 0, @"Start");
                        AddButton(593, yOffset + 38, 2074, 2076, b =>
                        {
                            if (entry.Status == InvasionStatus.Waiting)
                            {
                                entry.StartInvasion();
                            }
                            Refresh(true);
                        });
                    }

                    if (entry.Status == InvasionStatus.Finished)
                    {
                        AddLabel(600, yOffset + 10, 0, @"Restart");
                        AddButton(597, yOffset + 38, 2074, 2076, b =>
                        {
                            if (entry.Status == InvasionStatus.Finished)
                            {
                                entry.RestartInvasion();
                            }
                            Refresh(true);
                        });
                    }

                    AddLabel(666, yOffset + 10, 0, @"Copy");
                    AddButton(657, yOffset + 38, 2074, 2076, b =>
                    {
                        EventInvasions.GenerateInvasion(entry);
                        Refresh(true);
                    });
                }
            });
        }