示例#1
0
        public void TypeInfo(int page)
        {
            CurrentPage = page;
            sets        = ArenaControl.GetSets(a.Type);
            int index = sets.Count / 5;
            int pages = (sets.Count % 5 == 0 ? index : (index + 1));
            int i;

            AddPage(0);
            AddBackground(0, 44, 260, 240, 9250);
            AddBackground(0, 0, 260, 47, 9250);
            AddLabel(100, 14, 0, @"Arena Sets");

            if (sets.Count < ((page + 1) * 5))
            {
                index = sets.Count - page * 5;
            }
            else
            {
                index = 5;
            }

            for (i = 1; i < index + 1; i++)
            {
                AddLabel(60, 60 + i * 30, 0, sets[i - 1]);
                AddRadio(25, 60 + i * 30, 208, 209, sets[i - 1].Equals(a.Set) ? true : false, i);
            }

            AddLabel(60, 60, 0, String.Format("New Set: {0}", a.Name));
            AddRadio(25, 60, 208, 209, false, 0);

            AddButton(218, 248, 4005, 4007, 1, GumpButtonType.Reply, 0);
        }
示例#2
0
        public void TypeInfo(int page)
        {
            CurrentPage = page;
            sets        = ArenaControl.GetSets(t.TeamSize);
            int index = sets.Count / 5;
            int pages = (sets.Count % 5 == 0 ? index : (index + 1));
            int i;

            AddPage(0);
            AddBackground(0, 44, 260, 110 + index * 30, 9250);
            AddBackground(0, 0, 260, 47, 9250);
            AddLabel(100, 14, 0, @"Arena Sets");

            if (sets.Count < ((page + 1) * 5))
            {
                index = sets.Count - page * 5;
            }
            else
            {
                index = 5;
            }

            for (i = 1; i < index + 1; i++)
            {
                AddLabel(60, 30 + i * 30, 0, sets[i - 1]);
                AddButton(218, 30 + i * 30, t.ArenaSets.Contains(sets[i - 1]) ? 4017 : 4020,
                          t.ArenaSets.Contains(sets[i - 1]) ? 4019 : 4022, i, GumpButtonType.Reply, 0);
            }

            AddButton(218, 58 + index * 30, 4023, 4025, 0, GumpButtonType.Reply, 0); // OK Button
        }
示例#3
0
 public SingleTarget(ArenaControl arena, List <Point3D> list, int location)
     : base(10, true, TargetFlags.None)
 {
     a   = arena;
     loc = location;
     l   = list;
 }
示例#4
0
 public ArenaSetGump(Mobile from, ArenaControl arena, int page)
     : this()
 {
     caller = from;
     a      = arena;
     TypeInfo(page);
 }
示例#5
0
 public ArenaInfoGump(Mobile from, ArenaControl arena)
     : this()
 {
     caller = from;
     a      = arena;
     ArenaInfo();
 }
示例#6
0
 public ArenaPlacementGump(Mobile from, ArenaControl arena, List <Point3D> list)
     : this()
 {
     caller = from;
     a      = arena;
     points = list;
     PlacementInfo();
 }
示例#7
0
        /// <summary>
        /// The main tournament timer.
        /// Setup the brackets and start the timer
        /// </summary>
        public TournamentTimer(Tournament tournament)
        {
            Random rand = new Random();

            Manager.FilterInactiveTeams(tournament);
            m_CurrentRound      = 0;
            m_CurrentMatch      = 0;
            m_DelayStart        = TimeSpan.FromSeconds(30.0);
            m_Contestants       = new List <Teams>();
            m_Matches           = new List <Match>();
            m_Arenas            = new List <ArenaControl>();
            m_Tournament        = tournament;
            m_Bracket           = new BuildBracket();
            m_TournamentStarted = false;
            m_Contestants.AddRange(tournament.Teams);
            ShuffleTeams();

            switch (m_Tournament.Type)
            {
            case TournamentType.RoundRobin:
            {
                break;
            }

            case TournamentType.SingleElimination:
            {
                m_Bracket.SingleElimination(m_Contestants);
                break;
            }

            case TournamentType.DoubleElimination:
            {
                break;
            }

            case TournamentType.Hybrid:
            {
                break;
            }
            }

            string arenaset = (m_Tournament.ArenaSets != null && m_Tournament.ArenaSets.Count > 0)? m_Tournament.ArenaSets[rand.Next(m_Tournament.ArenaSets.Count)] : "";

            m_Arenas = ArenaControl.GetArenaSet(m_Tournament.TeamSize, arenaset);
            if (!(m_Arenas.Count > 0))
            {
                m_Arenas = ArenaControl.RandomArenaSet(m_Tournament.TeamSize);
            }
        }
示例#8
0
 public MatchTimer(TournamentTimer tournament, ArenaControl arena, Match bout)
     : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
 {
     Priority   = TimerPriority.OneSecond;
     t          = tournament;
     b          = bout;
     a          = arena;
     a.Occupied = true;
     countdown  = 6;
     started    = false;
     cfinished  = false;
     staging    = TimeSpan.FromSeconds(30.0);
     announcer  = getAnn();
     BeginStage();
 }
示例#9
0
        /// <summary>
        /// Determines if there is an unoccupied arena and sets it to be
        /// the next arena to be used
        /// </summary>
        /// <returns></returns>
        public bool HaveUnoccupiedArena()
        {
            m_NextArena = null;

            foreach (ArenaControl arena in m_Arenas)
            {
                if (!arena.Occupied)
                {
                    m_NextArena = arena;
                    break;
                }
            }

            return(m_NextArena != null);
        }
示例#10
0
        public SpectatorAreaGump(ArenaControl r)
            : base(25, 250)
        {
            m_Control = r;

            Closable  = true;
            Dragable  = true;
            Resizable = false;

            AddPage(0);
            AddBackground(23, 32, 412, 256, 9270);
            AddAlphaRegion(19, 29, 418, 263);

            AddLabel(186, 45, 1152, "REMOVE AREA");


            //+25 between 'em.

            int itemsThisPage  = 0;
            int nextPageNumber = 1;


            if (r.SpectatorArea != null)
            {
                for (int i = 0; i < r.SpectatorArea.Length; i++)
                {
                    Rectangle3D rect = ((Rectangle3D)r.SpectatorArea[i]);

                    if (itemsThisPage >= 8 || itemsThisPage == 0)
                    {
                        itemsThisPage = 0;

                        if (nextPageNumber != 1)
                        {
                            AddButton(393, 45, 4007, 4009, 0, GumpButtonType.Page, nextPageNumber);
                            //Forward button -> #0
                        }

                        AddPage(nextPageNumber++);

                        if (nextPageNumber != 2)
                        {
                            AddButton(35, 45, 4014, 4016, 1, GumpButtonType.Page, nextPageNumber - 2);
                            //Back Button -> #1
                        }
                    }

                    AddButton(70, 75 + 25 * itemsThisPage, 4017, 4019, 100 + i, GumpButtonType.Reply, 0);
                    //Button is 100 + i

                    //AddLabel(116, 77 + 25*i, 0, "(1234, 5678)");
                    AddLabel(116, 77 + 25 * itemsThisPage, 1152, String.Format("({0}, {1}, {2})", rect.Start.X, rect.Start.Y, rect.Start.Z));


                    AddLabel(232, 78 + 25 * itemsThisPage, 1152, "<-->");

                    //AddLabel(294, 77 + 25*i, 0, "(9876, 5432)");
                    AddLabel(294, 77 + 25 * itemsThisPage, 1152, String.Format("({0}, {1}, {2})", rect.End.X, rect.End.Y, rect.End.Z));

                    itemsThisPage++;
                }
            }
        }
示例#11
0
        public static void InitializeContent()
        {
            #region tutorial step 2
            #region arena
            var map = new Point(2000, 2000);

            var arena = new ArenaControl();

            arena.Layers.Canvas.style.backgroundColor =
                Color.FromGray(0xc0);
            arena.SetLocation(
                Rectangle.Of(0, 0, Native.window.Width, Native.window.Height));

            arena.SetCanvasSize(map);

            arena.Control.AttachToDocument();


            arena.DrawTextToInfo(Title, new Point(8, 8), Color.Blue);

            Native.window.onresize +=
                delegate
            {
                arena.SetLocation(
                    Rectangle.Of(0, 0, Native.window.Width, Native.window.Height));

                arena.SetCanvasPosition(
                    arena.CurrentCanvasPosition
                    );
            };
            #endregion
            #endregion


            var pending = default(Dude2);

            #region arsenal
            var arsenal = new Dictionary <string, DudeAnimationInfo>
            {
                { "Soldier",
                  new DudeAnimationInfo
                  {
                      Frames_Stand = Frames.WolfSoldier,
                      Frames_Walk  = Frames.WolfSoldier_Walk
                  } },
                { "Imp",
                  new DudeAnimationInfo
                  {
                      Frames_Stand = Frames.DoomImp,
                      Frames_Walk  = Frames.DoomImp_Walk
                  } }
            };
            #endregion


            #region tutorial step 3

            Func <DudeAnimationInfo, Point, Dude2> CreateActor =
                (_frames, _coords) =>
            {
                var actor = new Dude2();

                actor.Frames = _frames.Frames_Stand;
                actor.AnimationInfo.Frames_Stand = _frames.Frames_Stand;
                actor.AnimationInfo.Frames_Walk  = _frames.Frames_Walk;
                actor.Zoom.DynamicZoomFunc       = a => 1;
                actor.SetSize(48, 72);
                actor.TeleportTo(_coords.X, _coords.Y);
                actor.Zoom.StaticZoom = DefaultActiorZoom;
                actor.Direction       = Math.PI * 0.5;
                actor.Control.AttachTo(arena.Layers.Canvas);
                //actor.HasShadow = _frames.Frames_Stand.Length > 1;
                if (_frames.Frames_Stand.Length == 1)
                {
                    actor.Shadow.style.Opacity = 0.4;
                }
                actor.AnimationInfo.WalkAnimationInterval = 1000 / 30;
                return(actor);
            };

            var actors = new List <Dude2>
            {
            };

            var selection = from i in actors
                            where i.IsSelected
                            select i;

            arena.ApplySelection +=
                (rect, ev) =>
            {
                if (pending != null)
                {
                    return;
                }

                foreach (var v in actors)
                {
                    v.IsSelected = rect.Contains(v.CurrentLocation.ToInt32());
                }
            };

            var Argh        = new Argh();
            var Affirmative = new Affirmative();
            var ghoullaugh  = new ghoullaugh();
            var sheep       = new sheep();
            var pig         = new pig();
            var click       = new click().AttachToDocument();

            arena.SelectionClick +=
                (p, ev) =>
            {
                if (pending != null)
                {
                    return;
                }

                foreach (var v in selection)
                {
                    if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.ManWithHorns.Frames_Stand[0].Source)
                    {
                        ghoullaugh.play();
                        ghoullaugh = new ghoullaugh();
                    }
                    else if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.ThePig.Frames_Stand[0].Source)
                    {
                        pig.play();
                        pig = new pig();
                    }
                    else if (v.AnimationInfo.Frames_Stand[0].Source == MyFrames.TheSheep.Frames_Stand[0].Source)
                    {
                        sheep.play();
                        sheep = new sheep();
                    }
                    else if (v.AnimationInfo.Frames_Stand[0].Source == Frames.WolfSoldier[0].Source)
                    {
                        Affirmative.play();
                        Affirmative = new Affirmative();
                    }
                    else
                    {
                        Argh.play();
                        Argh = new Argh();
                    }



                    v.WalkTo(p.ToDouble());

                    // move in group formation
                    p.X += 16;
                    p.Y += 16;
                }
            };


            #endregion

            #region tutorial step 4



            #region CreateDialogAt
            var CreateDialogAt =
                new
            {
                //Dialog = default(IHTMLDiv),
                Content = default(IHTMLDiv),
                Width   = default(string)
            }
            .ToFunc(
                (Point pos, string width) =>
            {
                var f = new Form();

                f.Show();

                f.SizeTo(200, 200);


                // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151115/audio
                //f.PopupInsteadOfClosing();

                f.MoveTo(pos.X, pos.Y);
                //f.SizeTo(


                //var dialog = new IHTMLDiv();

                //dialog.style.SetLocation(pos.X, pos.Y);

                //dialog.style.backgroundColor = Color.Gray;
                //dialog.style.padding = "1px";

                //var caption = new IHTMLDiv().AttachTo(dialog);

                //caption.style.backgroundColor = Color.Blue;
                //caption.style.width = width;
                //caption.style.height = "0.5em";
                //caption.style.cursor = IStyle.CursorEnum.move;

                //var drag = new DragHelper(caption);

                //drag.Position = pos;
                //drag.Enabled = true;
                //drag.DragMove +=
                //    delegate
                //    {
                //        dialog.style.SetLocation(drag.Position.X, drag.Position.Y);
                //    };

                var _content = new IHTMLDiv().AttachTo(f.GetHTMLTargetContainer());

                _content.style.textAlign       = IStyle.TextAlignEnum.center;
                _content.style.backgroundColor = Color.White;
                _content.style.padding         = "1px";

                //dialog.AttachToDocument();

                return(new
                {     //Dialog = dialog,
                    Content = _content,
                    Width = width
                });
            }
                );
            #endregion

            #region dialog
            var toolbar = CreateDialogAt(new Point(2, 2), "8em");

            var combo = new IHTMLSelect();
            var build = new IHTMLButton();

            build.style.SetSize(72, 72);
            build.style.padding = "0px";

            var avatar = new IHTMLImage().AttachTo(build);
            var remove = new IHTMLButton("Remove");


            combo.AttachTo(toolbar.Content);
            new IHTMLBreak().AttachTo(toolbar.Content);
            build.AttachTo(toolbar.Content);
            new IHTMLBreak().AttachTo(toolbar.Content);
            remove.AttachTo(toolbar.Content);
            new IHTMLBreak().AttachTo(toolbar.Content);
            #endregion


            #region GetSelectedArsenal
            Func <DudeAnimationInfo> GetSelectedArsenal =
                () =>
            {
                if (arsenal.ContainsKey(combo[combo.selectedIndex].value))
                {
                    return(arsenal[combo[combo.selectedIndex].value]);
                }

                return(null);
            };
            #endregion

            Action Refresh =
                delegate
            {
                var i = GetSelectedArsenal();

                if (i != null)
                {
                    avatar.src = i.Images.Random().src;
                }
            };

            combo.Add(arsenal.Keys.ToArray());
            Refresh();

            combo.onchange +=
                delegate
            {
                Refresh();



                click.play();
                click = new click().AttachToDocument();
            };

            #region pending actor

            arena.MouseMove +=
                p =>
            {
                if (pending == null)
                {
                    return;
                }

                pending.TeleportTo(p.X, p.Y);
            };

            arena.Layers.User.oncontextmenu +=
                e =>
            {
                e.preventDefault();

                if (pending != null)
                {
                    pending.Control.Orphanize();
                    pending = null;
                    arena.ShowSelectionRectangle = true;

                    return;
                }

                actors.ForEach(
                    k => k.IsSelected = false
                    );
            };

            arena.SelectionClick +=
                (p, ev) =>
            {
                if (pending == null)
                {
                    return;
                }

                pending.TeleportTo(p.X, p.Y);

                actors.Add(pending);

                pending.IsHot = false;


                var x = GetSelectedArsenal();
                pending = CreateActor(x,
                                      new Point(
                                          Native.window.Width / 2,
                                          Native.window.Height / 2
                                          )
                                      );

                pending.IsHot = true;


                click.play();
                click = new click().AttachToDocument();
            };

            build.onclick +=
                delegate
            {
                if (pending != null)
                {
                    pending.Control.Orphanize();
                    pending = null;

                    return;
                }

                var x = GetSelectedArsenal();

                pending = CreateActor(x,
                                      new Point(
                                          Native.window.Width / 2,
                                          Native.window.Height / 2
                                          )
                                      );

                pending.IsHot = true;
                arena.ShowSelectionRectangle = false;

                click.play();
                click = new click().AttachToDocument();
            };
            #endregion

            remove.onclick +=
                delegate
            {
                foreach (var v in selection.ToArray())
                {
                    v.Control.Orphanize();
                    actors.Remove(v);
                }


                click.play();
                click = new click().AttachToDocument();
            };

            #endregion

            if (FilterToImpAndSoldier)
            {
            }
            else
            {
                #region step 6

                {
                    var n = "NPC";

                    arsenal.Add(n, MyFrames.NPC3);
                    combo.Add(n);
                }

                #endregion


                {
                    var n = "ManWithHorns";

                    arsenal.Add(n, MyFrames.ManWithHorns);
                    combo.Add(n);
                }
                {
                    var n = "TheSheep";

                    arsenal.Add(n, MyFrames.TheSheep);
                    combo.Add(n);
                }
                {
                    var n = "ThePig";

                    arsenal.Add(n, MyFrames.ThePig);
                    combo.Add(n);
                }

                {
                    var n = "TheCactus";

                    arsenal.Add(n, MyFrames.TheCactus);
                    combo.Add(n);
                }
            }


            if (BeforeAddingDebris != null)
            {
                BeforeAddingDebris(arena.Layers.Canvas);
            }

            3.Times(
                delegate()
            {
                new DebrisImages().Images.ForEach(
                    img => img.AttachTo(arena.Layers.Canvas).style.SetLocation(map.X.Random(), map.Y.Random())
                    );
            }
                );

            16.Times(
                delegate()
            {
                actors.Add(
                    CreateActor(arsenal.Random().Value, new Point(map.X.Random(), map.Y.Random()))
                    );
            }
                );
        }
示例#12
0
 public SingleTarget(ArenaControl arena, int location)
     : base(10, true, TargetFlags.None)
 {
     a   = arena;
     loc = location;
 }
示例#13
0
 public SpectatorRegion(ArenaControl control)
     : base(control.Set + control.Name, Map.Felucca, Region.DefaultPriority, control.SpectatorArea)
 {
     m_Controller = control;
 }
示例#14
0
        /// <summary>
        /// Creates a new control
        /// </summary>
        /// <param name="DataElement">The hidden data element</param>
        public GameOfLife()
        {
            var MyContainer = new IHTMLDiv().AttachToDocument();

            MyContainer.style.position = IStyle.PositionEnum.absolute;
            MyContainer.style.left     = "0px";
            MyContainer.style.top      = "0px";
            MyContainer.style.right    = "0px";
            MyContainer.style.bottom   = "0px";

            var vv = new ArenaControl();



            var cx = 32;
            var cy = 32;

            var w = 32;
            var h = 32;

            vv.SetCanvasSize(new Point(cx * w, cy * h));


            vv.SetLocation(new Rectangle {
                Left = 0, Top = 0, Width = Native.window.Width, Height = Native.window.Height
            });

            Native.window.onresize +=
                delegate
            {
                Console.WriteLine("onresize");
                vv.SetLocation(new Rectangle {
                    Left = 0, Top = 0, Width = Native.window.Width, Height = Native.window.Height
                });
            };

            vv.Layers.Canvas.style.backgroundColor = Color.White;

            vv.Control.AttachTo(MyContainer);


            var buffer = new Array2D <LayeredControl.CanvasRectangle>(cx, cy);


            vv.Layers.Canvas.Hide();

            Action <string, Point, Color> DrawTextWithShadow =
                (text, pos, c) =>
            {
                vv.DrawTextToInfo(text, pos + new Point(2, 2), Color.Black);
                vv.DrawTextToInfo(text, pos, Color.White);
                vv.DrawTextToInfo(text, pos + new Point(1, 1), c);
            };

            //DrawTextWithShadow("Game Of Life - Use middle mouse button to drag map around", new Point(8, 8), Color.Red);

            int index = 0;

            var State = new __Type1
            {
                ColorDeath = Color.White,
                //ColorSurvival = Color.Gray,
                ColorBirth = Color.Black
            };

            Func <Color> RandomState = () => new System.Random().NextDouble() > 0.5 ? State.ColorDeath : State.ColorBirth;


            #region reset

            Action Reset =
                () =>
                buffer.ForEach(
                    (int x, int y) =>
            {
                var c = new LayeredControl.CanvasRectangle
                {
                    BackgroundColor = RandomState(),
                    Location        = new Rectangle {
                        Left = x * w + 1, Top = y * h + 1, Width = w - 2, Height = h - 2
                    }
                };

                vv.DrawRectangleToCanvas(c);

                buffer[x, y] = c;
            }
                    );

            Reset();

            #endregion

            vv.Layers.Canvas.Show();

            //var f = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset);

            //var chk_enabled = new IHTMLInput(HTMLInputTypeEnum.checkbox);
            //var btn_reset = new IHTMLButton("Randomize");

            //btn_reset.onclick += (i) => Reset();

            //f.appendChild(btn_reset, chk_enabled, new IHTMLLabel("Activate", chk_enabled));

            //f.AttachToDocument();
            //f.style.SetLocation(500, 60);

            var NextEvolution = default(Action);

            Action <int> SleepAndEvolve =
                (timeout) => new Timer((t) => NextEvolution(), timeout, 0);

            #region NextEvolution
            NextEvolution =
                () =>
            {
                var nextframe = default(Action);
                var t         = IDate.Now.getTime();

                //if (chk_enabled.@checked)
                buffer.ForEach(
                    (int x, int y) =>
                {
                    Func <int, int, LayeredControl.CanvasRectangle> g =
                        (ox, oy) => buffer[x + ox, y + oy];

                    var u = g(0, 0);

                    var c = new[] {
                        g(-1, -1),
                        g(-1, 0),
                        g(-1, 1),
                        g(0, 1),
                        g(0, -1),
                        g(1, -1),
                        g(1, 0),
                        g(1, 1)
                    }.Count(i => i != null && i.BackgroundColor == State.ColorBirth);


                    var ncolor = default(Color);

                    var IsDeath = u.BackgroundColor == State.ColorDeath;
                    var IsBirth = u.BackgroundColor == State.ColorBirth;

                    var Is2    = c == 2;
                    var Is3    = c == 3;
                    var Is2or3 = Is2 || Is3;

                    if (IsDeath && Is3)
                    {
                        ncolor = State.ColorBirth;
                    }
                    else if (IsBirth && Is2or3)
                    {
                        ncolor = State.ColorBirth;
                    }
                    else
                    {
                        ncolor = State.ColorDeath;
                    }


                    nextframe += () =>
                    {
                        u.BackgroundColor = ncolor;
                        u.Update();
                    };
                }
                    );

                if (nextframe != null)
                {
                    nextframe();
                    nextframe = null;
                }

                int timeout = (int)(IDate.Now.getTime() - t) - 0;

                System.Console.WriteLine("time: " + timeout);

                SleepAndEvolve(timeout.Max(100));
            };
            #endregion

            SleepAndEvolve(1);
        }
示例#15
0
 public ArenaRegion(ArenaControl control)
     : base(control.Name, Map.Felucca, Region.DefaultPriority + 10, control.ArenaArea)
 {
     m_Controller = control;
 }