public WorldLayer(int width, int height, string name, bool visible = true)
        {
            tiles = new WorldRegion(width, height);

            Name    = name;
            Visible = visible;
        }
        public WorldLayer(int width, int height, string name, bool visible = true) 
        {
            tiles = new WorldRegion(width, height);

            Name = name;
            Visible = visible;
        }
Exemplo n.º 3
0
    private void SelectRegion(Region region)
    {
        ResetButtons();
        //get the region of the world that is being changed to
        WorldRegion worldRegion = GlobalBlackboard.Instance.regions[(int)region];


        //loop through all of the upgrades in the region and set the buttons up
        for (int i = 0; i < worldRegion.region_Upgrades.Count; i++)
        {
            //make the button visible and interactable
            buttons[i].SetActive(true);
            //set the buttons text to show the upgrades name
            buttons[i].transform.Find("Name").GetComponent <Text>().text = worldRegion.region_Upgrades[i].upgrade_Name;
            buttons[i].transform.Find("Button").GetChild(0).GetComponent <Image>().sprite = worldRegion.region_Upgrades[i].upgrade_Sprite;
            for (int j = 0; j < worldRegion.region_Upgrades[i].upgrade_Max_Level; j++)
            {
                //if the upgrade has been bought, set it's pip's sprite to the bought image
                if (j < worldRegion.region_Upgrades[i].upgrade_Level)
                {
                    buttons [i].transform.Find("Level Pips").GetChild(j).GetChild(0).GetComponent <Image>().sprite = upgrade_Bought_Image;
                }
                buttons[i].transform.Find("Level Pips").GetChild(j).gameObject.SetActive(true);
            }
            //reset the ui element's scale to avoid weird stretching
            buttons[i].transform.localScale = Vector3.one;
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// Send portal blocks of nearby portals
        /// </summary>
        /// <param name="s">S.</param>
        /// <param name="r">The red component.</param>
        public static void EnterRegion(Client player, WorldRegion r)
        {
            if (r == null || r.SubRegions == null)
                return;

            var packets = new List<PacketFromServer>();
            foreach (var sub in r.SubRegions)
            {
                if (sub.Type != WarpZone.Type)
                    continue;

                //Send block updates
                for (int x = sub.MinX; x < sub.MaxX; x++)
                {
                    for (int y = sub.MinY; y < sub.MaxY; y++)
                    {
                        for (int z = sub.MinZ; z < sub.MaxZ; z++)
                        {
                            packets.Add(new BlockChange(new CoordInt(x, y, z), BlockID.NetherPortal));
                        }
                    }
                }
            }

            if (packets.Count > 0)
            {
                Debug.WriteLine("Sending " + packets.Count + "portal packets");
                player.Queue.Queue(new Packets.PrecompiledPacket(packets));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// If a warzone send chat to everyone inside and block it to everyone else.
        /// Otherwise return false.
        /// </summary>
        static bool WarChat(Client player, string message)
        {
            WorldSession s = player.Session;

            if (s == null)
            {
                return(false);
            }
            WorldRegion r = s.CurrentRegion;

            if (r == null)
            {
                return(false);
            }
            if (r.Type != WarZone.Type)
            {
                return(false);
            }

            if (r.TellAll(Chat.Red + player.Name + " " + Chat.White, message) <= 1)
            {
                player.TellSystem(Chat.Red, "You are alone in this zone");
            }
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prevent block modification, aplies to all, residents should never get called here
        /// </summary>
        public static bool ProtectBlockBreak(VanillaSession session, WorldRegion region, PlayerDigging d)
        {
            if (IsBlockProtected(session, region) == false)
                return false;

            //Block single click from outside the adventure mode
            if (d.Status == PlayerDigging.StatusEnum.StartedDigging)
                return true;
            
            if (d.Status != PlayerDigging.StatusEnum.FinishedDigging)
                return false;

            //Old method - not needed
            BlockChange bc = new BlockChange(d.Position, BlockID.Bedrock);
            session.Player.SendToClient(bc);

            //New method - Works
            /*
            PlayerDigging pd = new PlayerDigging();
            pd.Position = d.Position;
            pd.Face = Face.Down;
            pd.Status = PlayerDigging.StatusEnum.CheckBlock;
            session.FromClient(pd);
            */

            return true;
        }
Exemplo n.º 7
0
        public EntityOverthrownCollection(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "ordinal": Ordinal = String.Intern(property.Value); break;

                case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "parent_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;

                case "target_entity_id": TargetEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;
                }
            }

            Region.AddEventCollection(this);
            UndergroundRegion.AddEventCollection(this);
            Site.AddEventCollection(this);
            TargetEntity.AddEventCollection(this);
        }
Exemplo n.º 8
0
        public static IEnumerable <WorldSubRegion> GetSubRegionsForRegions(WorldRegion region)
        {
            WorldSubRegion[] ret = null;

            switch (region)
            {
            case WorldRegion.Desert:
                ret = new[] { WorldSubRegion.DesertIntro, WorldSubRegion.DesertCrypt, WorldSubRegion.TavernOfHeroes
                              , WorldSubRegion.AncientLibrary, WorldSubRegion.Oasis, WorldSubRegion.CliffsOfAThousandPushups
                              , WorldSubRegion.TempleOfDarkness, WorldSubRegion.VillageCenter, WorldSubRegion.BeastTemple, WorldSubRegion.Coliseum };
                break;

            case WorldRegion.Fields:
                ret = new[] { WorldSubRegion.Fields };
                break;

            case WorldRegion.CrystalCaves:
                ret = new[] { WorldSubRegion.CavesIntro };
                break;

            case WorldRegion.Casino:
                ret = new[] { WorldSubRegion.CasinoIntro };
                break;

            case WorldRegion.DarkCastle:
                ret = new[] { WorldSubRegion.DarkCastleIntro };
                break;
            }

            return(ret);
        }
Exemplo n.º 9
0
        public FieldBattle(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "attacker_civ_id": Attacker = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "defender_civ_id": Defender = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "attacker_general_hfid": AttackerGeneral = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "defender_general_hfid": DefenderGeneral = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;
                }
            }

            Attacker.AddEvent(this);
            Defender.AddEvent(this);
            AttackerGeneral.AddEvent(this);
            DefenderGeneral.AddEvent(this);
            Region.AddEvent(this);
            UndergroundRegion.AddEvent(this);
        }
Exemplo n.º 10
0
        void RegionCommand(Client player, string[] cmd, int iarg)
        {
            if (cmd.Length == iarg)
            {
                //Single /reg, no arguments
                WorldRegion region = player.Session.CurrentRegion;
                if (region == null)
                {
                    throw new ErrorException("No region here");
                }


                player.TellSystem(Chat.Aqua, "Region: " + region.ColorName);
                if (player.Admin())
                {
                    player.TellSystem(Chat.Gray, region.Type + ": " + region);
                }
                player.TellSystem(Chat.DarkAqua + "Residents: ", region.GetResidents());
                player.TellSystem(Chat.DarkAqua + "Last visited by resident: ", (DateTime.UtcNow - region.Stats.LastVisitResident).TotalDays.ToString("0.0") + " days ago");
                return;
            }

            if (base.ParseCommand(player, cmd, iarg + 1) == false)
            {
                throw new ShowHelpException();
            }
        }
Exemplo n.º 11
0
        void Report(Client player, string[] cmd, int iarg)
        {
            WorldRegion region = player.Session.CurrentRegion;

            if (region == null)
            {
                throw new ErrorException("No region here");
            }


            if (cmd.Length == 3)
            {
                region.SetReport(player, cmd [2].ToLowerInvariant());
            }

            if (region.ReportVisits)
            {
                player.TellSystem(Chat.Yellow, "Reporting is on");
            }
            else
            {
                player.TellSystem(Chat.Yellow, "Reporting is off");
            }
            return;
        }
Exemplo n.º 12
0
        public HfRevived(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "ghost": _ghost = property.Value; break;

                case "hfid": HistoricalFigure = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;

                case "raised_before": RaisedBefore = true; property.Known = true;  break;
                }
            }

            HistoricalFigure.AddEvent(this);
            Site.AddEvent(this);
            Region.AddEvent(this);
            UndergroundRegion.AddEvent(this);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Deletes all tiles in the selection rectangle
        /// </summary>
        public void DeleteSelection()
        {
            WorldRegion undoRegion = GetLayerRegion(selectionRectangle, SelectedLayer),
                        redoRegion = new WorldRegion(selectionRectangle.Width, selectionRectangle.Height);

            for (int x = selectionRectangle.X; x < selectionRectangle.Right; x++)
            {
                for (int y = selectionRectangle.Y; y < selectionRectangle.Bottom; y++)
                {
                    if (!PointInWorld(x, y))
                    {
                        continue;
                    }

                    SetTile(x, y, null, SelectedLayer);
                }
            }

            History.Add(new HistoryItem(new TileChangesRegion(undoRegion, selectionRectangle.Location, SelectedLayer),
                                        new TileChangesRegion(redoRegion, selectionRectangle.Location, SelectedLayer), applyDeletionChanges));

            SelectionRectangle = Rectangle.Empty;

            worldCanvas.Invalidate();
        }
Exemplo n.º 14
0
        public HfReunion(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "group_1_hfid": HistoricalFigure1 = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "group_2_hfid": HistoricalFigure2 = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;
                }
            }

            HistoricalFigure1.AddEvent(this);
            HistoricalFigure2.AddEvent(this);
            Site.AddEvent(this);
            Region.AddEvent(this);
            UndergroundRegion.AddEvent(this);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Send portal blocks of nearby portals
        /// </summary>
        /// <param name="s">S.</param>
        /// <param name="r">The red component.</param>
        public static void EnterRegion(Client player, WorldRegion r)
        {
            if (r == null || r.SubRegions == null)
            {
                return;
            }

            var packets = new List <PacketFromServer>();

            foreach (var sub in r.SubRegions)
            {
                if (sub.Type != WarpZone.Type)
                {
                    continue;
                }

                //Send block updates
                for (int x = sub.MinX; x < sub.MaxX; x++)
                {
                    for (int y = sub.MinY; y < sub.MaxY; y++)
                    {
                        for (int z = sub.MinZ; z < sub.MaxZ; z++)
                        {
                            packets.Add(new BlockChange(new CoordInt(x, y, z), BlockID.NetherPortal));
                        }
                    }
                }
            }

            if (packets.Count > 0)
            {
                Debug.WriteLine("Sending " + packets.Count + "portal packets");
                player.Queue.Queue(new Packets.PrecompiledPacket(packets));
            }
        }
Exemplo n.º 16
0
        public Abduction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "ordinal": Ordinal = String.Intern(property.Value); break;

                case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "parent_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "attacking_enid": Attacker = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "defending_enid": Defender = world.GetEntity(Convert.ToInt32(property.Value)); break;
                }
            }

            Abductee.AddEventCollection(this);
            Region.AddEventCollection(this);
            UndergroundRegion.AddEventCollection(this);
            Site.AddEventCollection(this);
            Attacker.AddEventCollection(this);
            Defender.AddEventCollection(this);
        }
Exemplo n.º 17
0
        public AreaMap <SubRegion, WorldSubRegion> GetSubRegionalMap(WorldRegion regionEnum, List <SubRegion> subRegions)
        {
            AreaMap <SubRegion, WorldSubRegion> ret = null;

            switch (regionEnum)
            {
            case WorldRegion.Fields:
                SubRegion fieldIntroArea = subRegions.First(sr => sr.AreaId == WorldSubRegion.Fields);
                ret = new AreaMap <SubRegion, WorldSubRegion>(fieldIntroArea, new MapPath <SubRegion, WorldSubRegion>(fieldIntroArea));
                break;

            case WorldRegion.Desert:
                ret = CreateDesertSubRegionMap(subRegions);
                break;

            case WorldRegion.Casino:
                ret = CreateCasinoSubRegionMap(subRegions);
                break;

            case WorldRegion.CrystalCaves:
                ret = CreateCrystalCavesSubRegionMap(subRegions);
                break;

            case WorldRegion.DarkCastle:
                ret = CreateDarkCastleSubRegionMap(subRegions);
                break;
            }

            return(ret);
        }
Exemplo n.º 18
0
        internal static bool FilterClient(WorldRegion region, Client player, Packet packet)
        {
            if (packet.PacketID != PlayerPositionLookClient.ID)
                return false;

            CoordDouble pos = player.Session.Position;
            
            //Inner region
            if (region.SubRegions.Count == 0)
                return false;
            WorldRegion inner = region.SubRegions[0];
			
            //Find proportions between region edges
            double dOuter = pos.X - region.MinX;
            dOuter = Math.Min(dOuter, region.MaxX - pos.X);
            dOuter = Math.Min(dOuter, pos.Z - region.MinZ);
            dOuter = Math.Min(dOuter, region.MaxZ - pos.Z);
            double dInner = inner.MinX - pos.X;
            dInner = Math.Max(dInner, pos.X - inner.MaxX);
            dInner = Math.Max(dInner, inner.MinZ - pos.Z);
            dInner = Math.Max(dInner, pos.Z - inner.MaxZ);

            double frac = dOuter / (dOuter + dInner);
#if DEBUG
            //player.Tell(frac.ToString("0.00") + ": " + dOuter + " " + dInner);
#endif

            player.SendToClient(NightTime(frac));
			
            return false;
        }
Exemplo n.º 19
0
        public HfTravel(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "escape": Escaped = true; property.Known = true; break;

                case "return": Returned = true; property.Known = true; break;

                case "group_hfid": HistoricalFigure = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;
                }
            }

            HistoricalFigure.AddEvent(this);
            Site.AddEvent(this);
            Region.AddEvent(this);
            UndergroundRegion.AddEvent(this);
        }
Exemplo n.º 20
0
        private WorldArea InstantiateWorldArea(WorldTile tile, WorldAreaData data)
        {
            if (!_loadedWorldAreas.ContainsKey(data.id))
            {
                var go        = Instantiate(worldAreaPrefab, _gameWorld.transform);
                var worldArea = go.GetComponent <WorldArea>();
                worldArea.areaName = data.name;
                worldArea.climate  = data.climate;
                worldArea.tiles    = new List <WorldTile> {
                    tile
                };
                WorldRegion region = null;
                if (data.region != -1)
                {
                    region = InstantiateWorldRegion(worldArea, _regionDict[data.region]);
                }
                worldArea.worldRegion      = region;
                _loadedWorldAreas[data.id] = worldArea;
                return(worldArea);
            }

            var area = _loadedWorldAreas[data.id];

            area.tiles.Add(tile);
            return(area);
        }
Exemplo n.º 21
0
        public void UnlockRegion(int groupingId, WorldRegion regionalEnum)
        {
            MapGrouping <Region, WorldRegion> grouping = _regionGroupingsDictionary[groupingId];

            MapGroupingItem <Region, WorldRegion> regionGroupingItem = grouping.Values.Single(sr => sr.Item.AreaId == regionalEnum);

            regionGroupingItem.Unlock();
        }
Exemplo n.º 22
0
        public Duel(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "ordinal": Ordinal = String.Intern(property.Value); break;

                case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "parent_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "attacking_hfid": Attacker = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "defending_hfid": Defender = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;
                }
            }
            //foreach (WorldEvent collectionEvent in Collection) this.AddEvent(collectionEvent);
            if (ParentCollection != null && ParentCollection.GetType() == typeof(Battle))
            {
                foreach (HfDied death in Collection.OfType <HfDied>())
                {
                    Battle battle    = ParentCollection as Battle;
                    War    parentWar = battle.ParentCollection as War;
                    if (battle.NotableAttackers.Contains(death.HistoricalFigure))
                    {
                        battle.AttackerDeathCount++;
                        battle.Attackers.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++;

                        if (parentWar != null)
                        {
                            parentWar.AttackerDeathCount++;
                        }
                    }
                    else if (battle.NotableDefenders.Contains(death.HistoricalFigure))
                    {
                        battle.DefenderDeathCount++;
                        battle.Defenders.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++;
                        if (parentWar != null)
                        {
                            parentWar.DefenderDeathCount++;
                        }
                    }

                    if (parentWar != null)
                    {
                        (ParentCollection.ParentCollection as War).DeathCount++;
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void ResetGroupingChoice(WorldRegion region)
        {
            IEnumerable <int> groupingIdsToClear = Globals.GroupingKeys.GetGroupingKeysForRegion(region);

            foreach (int groupingId in groupingIdsToClear)
            {
                _groupingChoicesDictionary.Remove(groupingId);
            }
        }
Exemplo n.º 24
0
 public void OnRegionSelectionChange(object sender, SelectedWorldRegion e)
 {
     if (e.Region == null)
     {
         return;
     }
     _selectedRegion = e.Region;
     UpdateTexts(_selectedRegion);
 }
Exemplo n.º 25
0
        public static bool Trigger(Client player, WorldRegion r)
        {
#if DEBUG
            player.TellAbove("DEBUG: ", "You triggered the ban");
#else
            player.BanByServer(DateTime.Now.AddMinutes(30), r.Name);
#endif
            return true;
        }
Exemplo n.º 26
0
        public HfSimpleBattleEvent(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "subtype":
                    switch (property.Value)
                    {
                    case "attacked": SubType = HfSimpleBattleType.Attacked; break;

                    case "scuffle": SubType = HfSimpleBattleType.Scuffle; break;

                    case "confront": SubType = HfSimpleBattleType.Confronted; break;

                    case "2 lost after receiving wounds": SubType = HfSimpleBattleType.Hf2LostAfterReceivingWounds; break;

                    case "2 lost after giving wounds": SubType = HfSimpleBattleType.Hf2LostAfterGivingWounds; break;

                    case "2 lost after mutual wounds": SubType = HfSimpleBattleType.Hf2LostAfterMutualWounds; break;

                    case "happen upon": SubType = HfSimpleBattleType.HappenedUpon; break;

                    case "ambushed": SubType = HfSimpleBattleType.Ambushed; break;

                    case "corner": SubType = HfSimpleBattleType.Cornered; break;

                    case "surprised": SubType = HfSimpleBattleType.Surprised; break;

                    case "got into a brawl": SubType = HfSimpleBattleType.GotIntoABrawl; break;

                    case "subdued": SubType = HfSimpleBattleType.Subdued; break;

                    default: SubType = HfSimpleBattleType.Unknown; UnknownSubType = property.Value; property.Known = false; break;
                    }
                    break;

                case "group_1_hfid": HistoricalFigure1 = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "group_2_hfid": HistoricalFigure2 = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;
                }
            }

            HistoricalFigure1.AddEvent(this);
            HistoricalFigure2.AddEvent(this);
            Site.AddEvent(this);
            Region.AddEvent(this);
            UndergroundRegion.AddEvent(this);
        }
Exemplo n.º 27
0
        public Theft(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "ordinal": Ordinal = string.Intern(property.Value); break;

                case "coords": _coordinates = Formatting.ConvertToLocation(property.Value); break;

                case "parent_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break;

                case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "attacking_enid": Attacker = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "defending_enid": Defender = world.GetEntity(Convert.ToInt32(property.Value)); break;
                }
            }

            foreach (ItemStolen theft in Collection.OfType <ItemStolen>())
            {
                if (theft.Site == null)
                {
                    theft.Site = Site;
                }
                if (!Site.Events.Contains(theft))
                {
                    Site.AddEvent(theft);
                    Site.Events = Site.Events.OrderBy(ev => ev.Id).ToList();
                }
                if (Attacker.SiteHistory.Count == 1)
                {
                    if (theft.ReturnSite == null)
                    {
                        theft.ReturnSite = Attacker.SiteHistory.First().Site;
                    }
                    if (!theft.ReturnSite.Events.Contains(theft))
                    {
                        theft.ReturnSite.AddEvent(theft);
                        theft.ReturnSite.Events = theft.ReturnSite.Events.OrderBy(ev => ev.Id).ToList();
                    }
                }
            }
            Attacker.AddEventCollection(this);
            Defender.AddEventCollection(this);
            Region.AddEventCollection(this);
            UndergroundRegion.AddEventCollection(this);
            Site.AddEventCollection(this);
        }
Exemplo n.º 28
0
        public Region GetRegion(WorldRegion region)
        {
            IEnumerable <BattleMove> movesForRegion      = GetRegionMovesForRegion(region);
            IEnumerable <SubRegion>  subRegionsForRegion = GetSubRegionsForRegion(region);

            Region ret = new Region(region, movesForRegion, subRegionsForRegion);

            ret.RegionCompleted += DecisionManager.ResetDecisionsAfterRegionCleared;

            return(ret);
        }
Exemplo n.º 29
0
        void Delete(Client player, string[] cmd, int iarg)
        {
            if (player.Admin() == false)
            {
                throw new ErrorException("Disabled");
            }
            WorldRegion region = player.Session.CurrentRegion;

            if (region == null)
            {
                throw new ErrorException("No region here");
            }

            if (cmd.Length <= iarg)
            {
                throw new ShowHelpException(); //Need more arguments
            }
            RegionList regions = player.Session.World.Regions;

            string subdel = cmd [iarg].ToLowerInvariant();

            switch (subdel)
            {
            case "single":
                DeleteSingle(region, regions);
                player.TellSystem(Chat.Purple, region.Name + " removed");
                player.Session.CurrentRegion = null;
                break;

            case "recursive":
                DeleteRecursive(region);
                player.TellSystem(Chat.Purple, region.Name + " and subregions removed");
                region.Deleted = true;
                player.Session.CurrentRegion = null;
                break;

            case "subonly":
                DeleteSubregions(region);
                player.TellSystem(Chat.Purple, "Subregions of " + region.Name + " removed");
                break;

            default:
                throw new ShowHelpException();
            }
            RegionLoader.Save(regions);

            //Update all players regions
            foreach (var p in PlayerList.List)
            {
                RegionCrossing.SetRegion(p.Session);
            }

            ScoreboardRegionManager.UpdateAllPlayersRegion();
        }
Exemplo n.º 30
0
        public IEnumerable <int> GetGroupingKeysForRegion(WorldRegion region)
        {
            List <int> ret = new List <int>();

            switch (region)
            {
            case WorldRegion.Desert:
                ret.Add(FirstDesertGroupingId);
                ret.Add(SecondDesertGroupingId);
                ret.Add(ColiseumDesertGroupingId);
                break;
            }

            return(ret);
        }
Exemplo n.º 31
0
        public SavedGame(WorldState state, List <WorldRegion> regions, WorldRegion region, int lives, List <IEntity> entities, int[,] tiles,
                         int coins, int points, int timer, int transitionTimer)
        {
            State         = state;
            Regions       = regions;
            CurrentRegion = region;
            Lives         = lives;

            Entities = entities.ConvertAll(ent => ent.Clone());
            Tiles    = tiles.Clone() as int[, ];

            Coins           = coins;
            Points          = points;
            Timer           = timer;
            TransitionTimer = transitionTimer;
        }
Exemplo n.º 32
0
        static bool Empty(WorldRegion r)
        {
            //To be removed
            List<WorldRegion > rem = new List<WorldRegion>();
			
            //Empty subregi ons
            foreach (WorldRegion wr in r.SubRegions)
            {
                if (Empty(wr))
                    rem.Add(wr);
            }
            foreach (WorldRegion tr in rem)
                r.SubRegions.Remove(tr);
			
            return r.Residents.Count == 0 && r.SubRegions.Count == 0;
        }
Exemplo n.º 33
0
        static bool TalkingToResident(Client fr, Client to)
        {
            WorldSession s = fr.Session;

            if (s == null)
            {
                return(false);
            }
            WorldRegion r = s.CurrentRegion;

            if (r == null)
            {
                return(false);
            }
            return(r.IsResident(to));
        }
    public WorldRegion spawnRegionAt(Vector2 coors)
    {
        GameObject worldRegionObj = new GameObject("WorldRegion");

        worldRegionObj.transform.position = new Vector3(WorldRegion.REGIONSIZE * WorldRegion.REGIONPRECISION * coors.x, 0.0f, WorldRegion.REGIONSIZE * WorldRegion.REGIONPRECISION * coors.y);

        WorldRegion worldRegion = worldRegionObj.AddComponent <WorldRegion>();

        worldRegion.manager          = this;
        worldRegion.lod              = WorldRegion.REGIONSIZE;
        worldRegion.worldRegionCoors = coors;

        this.regions[Mathf.FloorToInt(coors.x), Mathf.FloorToInt(coors.y)] = worldRegion;

        return(worldRegion);
    }
Exemplo n.º 35
0
        void Message(Client player, string[] cmd, int iarg)
        {
            WorldRegion region = player.Session.CurrentRegion;

            if (region == null)
            {
                throw new ErrorException("No region here");
            }

            if (cmd.Length < 3)
            {
                throw new ErrorException("Too few arguments");
            }

            region.SetMessage(player, cmd.JoinFrom(2));
            return;
        }
Exemplo n.º 36
0
        void AddResident(Client player, string[] cmd, int iarg)
        {
            WorldRegion region = player.Session.CurrentRegion;

            if (region == null)
            {
                throw new ErrorException("No region here");
            }

            if (cmd.Length != 3)
            {
                throw new ErrorException("Too few arguments");
            }
            region.AddPlayer(player, cmd [2]);
            ScoreboardRegionManager.UpdateAllPlayersRegion();
            return;
        }
Exemplo n.º 37
0
        public static bool ProtectBlockPlace(VanillaSession session, WorldRegion region, PlayerBlockPlacement bp)
        {
            if (IsBlockProtected(session, region) == false)
                return false;

            if (FilterFire(session, bp))
            {
                string i = "";
                if (session.ActiveItem != null)
                    i += "(server)" + session.ActiveItem.ItemID;
                if (bp.Item != null)
                    i += "(client)" + bp.Item.ItemID;

                Chatting.Parser.TellAdmin(session.Player.Name + " tried to use " + i + " in " + region.Name + " at " + session.Position);
                //session.Player.Kick("Arson");
                return true;
            }

            //If adventure protection is active, allow all actions
            if (session.Mode == GameMode.Adventure) //buggy but best bet so far
                return false; //ok, only activate levers and chests

            //Block all placements, non resident must be inside the region
            session.TellSystem(Chat.Aqua, "move inside the region before you open a door or chest");

            //New method, works - no longer works
            /*
            PlayerDigging pd = new PlayerDigging();
            pd.Position = bp.BlockPosition.Offset(bp.FaceDirection);
            pd.Face = Face.Down;
            pd.Status = PlayerDigging.StatusEnum.CheckBlock;
            session.FromClient(pd);
            */

            //Old method - not perfect, disabling:
            /*BlockChange bc = new BlockChange(bp.BlockPosition.Offset(bp.FaceDirection), BlockID.Air);
            session.Player.SendToClient(bc);*/
            return true;
        }
Exemplo n.º 38
0
        public static bool IsBlockProtected(WorldSession session, WorldRegion r)
        {
            if (r == null)
                return false;

            if (session.Mode == GameMode.Creative && session.Player.Admin())
                return false;
            if (r.IsResident(session.Player))
                return false;

            switch (r.Type)
            {
                case Protected.Type:
                case Preserved.Type:
                case Adventure.Type:
                case Honeypot.Type:
                case SpawnRegion.Type:
                case WarpZone.Type:
                    return true;
            }

            return false;
        }
Exemplo n.º 39
0
        protected void DrawRegion(Graphics g, WorldRegion w)
        {
            if (w.Dimension != (int)Dimension)
                return;
			
            Point topleft = FromCoord(w.MinX, w.MinZ);
            Point bottomright = FromCoord(w.MaxX, w.MaxZ);
            Size size = new Size(bottomright.X - topleft.X, bottomright.Y - topleft.Y);
            Rectangle rect = new Rectangle(topleft, size);
			
            if (size.Width < 1 || size.Height < 1)
                return;
            if (w.MaxX < w.MinX || w.MaxY < w.MinY || w.MaxZ < w.MinZ)
                g.FillRectangle(Brushes.Red, new Rectangle(topleft, size));
			
            var pi = Position.CloneInt();
            if (!w.Overlap(new MineProxy.Region(pi.X, pi.X, 0, 10000, pi.Z, pi.Z)))
            {
                //Draw defaullt content
                using (Pen p = new Pen(TiledMapPainter.AgeColor(w.Stats.LastVisitResident)))
                    g.DrawRectangle(p, new Rectangle(topleft, size));
                g.DrawString(w.Name, Font, Brushes.LimeGreen, rect);
                return;
            }

            //Draw selected region
            g.DrawRectangle(Pens.Orange, new Rectangle(topleft, size));

            Point bottomleft = FromCoord(w.MinX, w.MaxZ);
            TimeSpan lastVisit = DateTime.UtcNow - w.Stats.LastVisitResident;
            string lastVisitText = lastVisit.TotalDays.ToString("0.0") + " days ago";
            if (lastVisit.TotalDays > 500)
                lastVisitText = "not visited";

            string text = w + "\n" + lastVisitText + "\n" + w.GetResidents();
            size = g.MeasureString(text, Font, 300).ToSize();
            size.Width += 6;
            size.Height += 6;
            rect = new Rectangle(bottomleft, size);
            g.FillRectangle(Brushes.DarkGreen, rect);
            g.DrawRectangle(Pens.LightGreen, rect);
            rect.X += 3;
            rect.Y += 3;
            g.DrawString(text, Font, Brushes.WhiteSmoke, rect);

            if (w.SubRegions == null)
                return;
            foreach (WorldRegion s in w.SubRegions)
                DrawRegion(g, s);
        }
Exemplo n.º 40
0
 static void DeleteRecursive(WorldRegion r)
 {
     r.Residents.Clear();
     r.SubRegions.Clear();
 }
Exemplo n.º 41
0
 static void SetStats(WorldRegion r, Client player)
 {
     if (r == null)
         return;
     if (r.Stats == null)
         r.Stats = new RegionStats();
     r.Stats.LastVisit = DateTime.UtcNow;
     if (r.IsResident(player))
         r.Stats.LastVisitResident = DateTime.UtcNow;
 }
Exemplo n.º 42
0
        static void DeleteSingle(WorldRegion r, RegionList regions)
        {
            lock (regions)
            {
                var parent = WorldRegion.GetParentList(regions, r);
                if (parent == null)
                    return;

                //Move all subregions to parent list
                if (r.SubRegions != null)
                {
                    foreach (var s in r.SubRegions)
                        parent.Add(s);
                }

                r.Residents.Clear();
                r.SubRegions.Clear();
            }
            RegionLoader.Save(regions);
        }
Exemplo n.º 43
0
 public OpenWindowRegion(WindowOpen window, WorldRegion region)
 {
     this.Window = window;
     this.Region = region;
 }
Exemplo n.º 44
0
 static void DeleteSubregions(WorldRegion r)
 {
     r.SubRegions.Clear();
 }
Exemplo n.º 45
0
        internal static WorldRegion Create(Dimensions dimension, CoordDouble start, CoordDouble end, string regionName, Client player, string resident, RegionList regions)
        {
            if (regions == null)
                throw new ErrorException("No regions in this world");

            WorldRegion w = new WorldRegion(dimension, start, end, regionName);
            w.Residents.Add(resident);
            w.Type = "protected";

            lock (regions)
            {
                //Test for overlapping regions
                WorldRegion existing = RegionCrossing.GetBaseRegion(regions.List, w, dimension);
                if (existing == null)
                {
                    //New Top level region
                    regions.List.Add(w);
                    RegionLoader.Save(regions);
                    return w;
                } 

                //Make sure you already are a part of the region
                if (existing.ResidentPermissions(player) == false)
                    throw new ErrorException("You can't set a subregion unless you are a resident in the parent region.");

                //All inside, make subregion
                if (existing.Cover(w))
                {
                    if (existing.SubRegions == null)
                        existing.SubRegions = new List<WorldRegion>();
                    existing.SubRegions.Add(w);
                    RegionLoader.Save(regions);
                    return w;
                }
                //Need to make a wrapping region

                //Only admins may create wrapping regions
                if (player != null && player.Admin() == false)
                    throw new ErrorException("New region must be fully inside " + existing);

                //New region covering several old ones?
                var parentList = WorldRegion.GetParentList(regions, existing);
                if (parentList == null)
                    throw new ErrorException("Parent list not found for " + existing);

                //regions to move inside the new one
                var moving = new List<WorldRegion>();

                //Determine if we are breaking any boundaries
                bool breaking = false;
                foreach (var s in parentList)
                {
                    if (w.Cover(s))
                    {
                        moving.Add(s);
                    } else if (w.Overlap(s)) //Overlap but not cover completely
                    {
                        player.TellSystem(Chat.Red, "Breaking boundaries: " + s);
                        breaking = true;
                    }
                }
                if (breaking)
                {
                    player.TellSystem(Chat.Red, "Failed creating: " + w);
                    player.TellSystem(Chat.Red, "Aborting: Broke region boundaries");
                    return null;
                }

                //Move subregions into new region and remove from parentlist
                w.SubRegions = moving;
                foreach (var s in moving)
                {
                    player.TellSystem(Chat.Aqua, "New subregion: " + s);
                    parentList.Remove(s);
                }
                parentList.Add(w);
                RegionLoader.Save(regions);
                return w;
            }
        }
Exemplo n.º 46
0
        //Return null if no match is found
        //Return current if the list is the parent
        //Return the parent region if found
        public static WorldRegion GetParentRegion(List<WorldRegion> list, WorldRegion current)
        {
            foreach (WorldRegion r in list)
            {
                if (r.Dimension != current.Dimension)
                    continue;
                
                if (current.Overlap(r) == false) 
                    continue;   
                
                if (r == current)
                    return r;   //Signal that the parent is the list holder
                        
                if (r.SubRegions == null) 
                    throw new InvalidOperationException("Expected subregions");

                WorldRegion w = GetParentRegion(r.SubRegions, current);
                        
                if (w == current)
                    return r;   //return true parent
                if (w != null)
                    return w; //return parent found in sub
                //if null continue
            }
            return null;
        }
Exemplo n.º 47
0
 public static void WriteRegion(Client player, WorldRegion region, bool inside)
 {
     if (LogDate != DateTime.Now.Date)
         OpenLog();
     
     if (inside)
         regionLog.WriteLine(Timestamp + "\t" +
             player.MinecraftUsername + "\tEntered\t" + region + "\tat" + player.Session.Position);
     else
         regionLog.WriteLine(Timestamp + "\t" +
             player.MinecraftUsername + "\tLeft\t" + region + "\tat" + player.Session.Position);
             
     //regionLog.Flush ();
 }
 public TileChangesRegion(WorldRegion region, Point offset, int layer)
 {
     Region = region;
     Offset = offset;
     Layer = layer;
 }