示例#1
0
        public void DeactivateEvent()
        {
            LastRunTime = DateTime.Now;

            foreach (var mapRespawn in MapRespawns)
            {
                Map.Respawns.Remove(mapRespawn);
            }

            MapRespawns.Clear();

            Stage = 0;
            AwardPlayers();

            MapEventClientSide eventNotification = new MapEventClientSide()
            {
                EventName = Info.EventName,
                EventType = Info.EventType,
                Index     = Info.Index,
                IsActive  = false,
                Size      = Info.EventSize,
                Location  = CurrentLocation
            };

            foreach (var player in Map.Players)
            {
                player.Enqueue(new S.DeactivateEvent()
                {
                    Event = eventNotification
                });
            }

            #region RemoveBoundaries
            foreach (var spellObj in Zone)
            {
                Map.RemoveObject(spellObj);
                spellObj.Despawn();
            }
            Zone.Clear();
            #endregion
        }
示例#2
0
        public void ActivateEvent()
        {
            Point randomLocation = Locations[Envir.Random.Next(Locations.Count)];

            CurrentLocation = randomLocation;
            SMain.EnqueueDebugging(string.Format("{0} Activating Event:{1}", Map.Info.FileName, Info.EventName));
            switch (Info.EventType)
            {
            case EventType.Invasion:
                Stage = 1;
                SpawnInvasionMonsters(1);
                break;

            default:
                SpawnMonsters();
                break;
            }

            MapEventClientSide eventNotification = new MapEventClientSide()
            {
                EventName = Info.EventName,
                EventType = Info.EventType,
                Index     = Info.Index,
                IsActive  = true,
                Size      = Info.EventSize,
                Location  = CurrentLocation
            };

            foreach (var player in Map.Players)
            {
                player.Enqueue(new S.ActivateEvent()
                {
                    Event = eventNotification
                });
            }

            #region Boundaries
            for (int y = CurrentLocation.Y - Info.EventSize; y <= CurrentLocation.Y + Info.EventSize; y++)
            {
                if (y < 0)
                {
                    continue;
                }
                if (y >= Map.Height)
                {
                    break;
                }
                for (int x = CurrentLocation.X - Info.EventSize; x <= CurrentLocation.X + Info.EventSize; x += Math.Abs(y - CurrentLocation.Y) == Info.EventSize ? 1 : Info.EventSize * 2)
                {
                    if (x < 0)
                    {
                        continue;
                    }
                    if (x >= Map.Width)
                    {
                        break;
                    }
                    if (!Map.Cells[x, y].Valid)
                    {
                        continue;
                    }

                    SpellObject spell = new SpellObject
                    {
                        ExpireTime      = long.MaxValue,
                        Spell           = this.Info.IsSafezone ? Spell.TrapHexagon : Spell.FireWall,
                        TickSpeed       = int.MaxValue,
                        CurrentLocation = new Point(x, y),
                        CurrentMap      = Map,
                        Decoration      = true
                    };

                    Map.Cells[x, y].Add(spell);
                    Zone.Add(spell);
                    spell.Spawned();
                }
            }
            #endregion
        }
示例#3
0
        private void OnBeforeDraw()
        {
            MapControl map = GameScene.Scene.MapControl;

            if (map == null || !Visible)
            {
                return;
            }

            //int index = map.BigMap <= 0 ? map.MiniMap : map.BigMap;
            int index = map.BigMap;

            if (index <= 0)
            {
                if (Visible)
                {
                    Visible = false;
                }
                return;
            }

            TrySort();

            Rectangle viewRect = new Rectangle(0, 0, 600, 400);

            Size = Libraries.MiniMap.GetSize(index);

            if (Size.Width < 600)
            {
                viewRect.Width = Size.Width;
            }

            if (Size.Height < 400)
            {
                viewRect.Height = Size.Height;
            }

            viewRect.X = (Settings.ScreenWidth - viewRect.Width) / 2;
            viewRect.Y = (Settings.ScreenHeight - 120 - viewRect.Height) / 2;

            Location = viewRect.Location;
            Size     = viewRect.Size;

            float scaleX = Size.Width / (float)map.Width;
            float scaleY = Size.Height / (float)map.Height;

            viewRect.Location = new Point(
                (int)(scaleX * MapObject.User.CurrentLocation.X) - viewRect.Width / 2,
                (int)(scaleY * MapObject.User.CurrentLocation.Y) - viewRect.Height / 2);

            if (viewRect.Right >= Size.Width)
            {
                viewRect.X = Size.Width - viewRect.Width;
            }
            if (viewRect.Bottom >= Size.Height)
            {
                viewRect.Y = Size.Height - viewRect.Height;
            }

            if (viewRect.X < 0)
            {
                viewRect.X = 0;
            }
            if (viewRect.Y < 0)
            {
                viewRect.Y = 0;
            }

            Libraries.MiniMap.Draw(index, Location, Size, Color.FromArgb(255, 255, 255));

            int startPointX = (int)(viewRect.X / scaleX);
            int startPointY = (int)(viewRect.Y / scaleY);

            //画地图上的点,应该是只画玩家和怪物,NPC
            for (int i = MapControl.Objects.Count - 1; i >= 0; i--)
            {
                MapObject ob = MapControl.Objects[i];


                if (ob.Race == ObjectType.Item || ob.Dead || ob.Race == ObjectType.Spell)
                {
                    continue;                                                                       // || (ob.ObjectID != MapObject.User.ObjectID)
                }
                float x = ((ob.CurrentLocation.X - startPointX) * scaleX) + Location.X;
                float y = ((ob.CurrentLocation.Y - startPointY) * scaleY) + Location.Y;

                Color colour;

                if ((GroupDialog.GroupList.Contains(ob.Name) && MapObject.User != ob) || ob.Name.EndsWith(string.Format("({0})", MapObject.User.Name)))
                {
                    colour = Color.FromArgb(0, 0, 255);
                }
                else
                if (ob is PlayerObject)
                {
                    colour = Color.FromArgb(255, 255, 255);
                }
                else if (ob is NPCObject || ob.AI == 6)
                {
                    colour = Color.FromArgb(0, 255, 50);
                }
                else
                {
                    colour = Color.FromArgb(255, 0, 0);
                }

                DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);
            }
            //for (int i = 0; i < ListTown.Count; i++)
            //{

            //    if (ListTown[i].BigMap != map.BigMap) continue;
            //    float xx = ((ListTown[i].Location.X - startPointX) * scaleX);
            //    float yy = ((ListTown[i].Location.Y - startPointY) * scaleY);


            //    ListLabelTown.Add(new MirLabel
            //    {
            //        AutoSize = true,
            //        Parent = this,
            //        Font = new Font(Settings.FontName, 9f, FontStyle.Regular),
            //        DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
            //        Text = ListTown[i].Name,
            //        ForeColour = ListTown[i].Color,
            //        Location = new Point((int)(xx), (int)(yy)),
            //        NotControl = true,
            //        Visible = true,
            //        Modal = true
            //    });
            //}
            //这里画自动寻路的路径
            for (int i = 0; i < map.RouteList.Count; i++)
            {
                Color colour = Color.White;
                float x      = ((map.RouteList[i].X - startPointX) * scaleX) + Location.X;
                float y      = ((map.RouteList[i].Y - startPointY) * scaleY) + Location.Y;
                DXManager.Sprite.Draw2D(DXManager.RadarTexture, Point.Empty, 0, new PointF((int)(x - 0.5F), (int)(y - 0.5F)), colour);
            }
            DisposeEvents();
            for (int i = MapControl.MapEvents.Count - 1; i >= 0; i--)
            {
                MapEventClientSide mapEvent = MapControl.MapEvents[i];

                float x = ((mapEvent.Location.X - startPointX) * scaleX) + Location.X;
                float y = ((mapEvent.Location.Y - startPointY) * scaleY) + Location.Y;

                int imgIndex = 0;
                switch (mapEvent.EventType)
                {
                case EventType.MonsterSlay:
                    imgIndex = 2259;
                    break;

                case EventType.Invasion:
                    imgIndex = 1811;
                    break;

                case EventType.DailyBoss:
                    imgIndex = 2091;
                    break;

                case EventType.WeeklyBoss:
                    imgIndex = 2092;
                    break;
                }

                PublicEvents.Add(new MirImageControl()
                {
                    Parent     = this.Parent,
                    Library    = Libraries.Items,
                    Index      = imgIndex,
                    Location   = new Point((int)(x - 10), (int)(y - 10)),
                    NotControl = false,
                    Visible    = true,
                    Hint       = mapEvent.EventName,
                    Blending   = false,
                    Size       = new Size(2, 2)
                });
            }
        }