Ejemplo n.º 1
0
        private void addToQueue(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue)
        {
            int id = zoneContext.CurrentID;

            IMonsterHouseBaseStep monsterHouseStep = HouseStepSpawns.Pick(context.Rand).CreateNew();
            SpawnList <MapItem>   itemListSlice    = Items.GetSpawnList(id);

            for (int jj = 0; jj < itemListSlice.Count; jj++)
            {
                monsterHouseStep.Items.Add(new MapItem(itemListSlice.GetSpawn(jj)), itemListSlice.GetSpawnRate(jj));
            }
            SpawnList <ItemTheme> itemThemeListSlice = ItemThemes.GetSpawnList(id);

            for (int jj = 0; jj < itemThemeListSlice.Count; jj++)
            {
                monsterHouseStep.ItemThemes.Add(itemThemeListSlice.GetSpawn(jj).Copy(), itemThemeListSlice.GetSpawnRate(jj));
            }
            SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id);

            for (int jj = 0; jj < mobListSlice.Count; jj++)
            {
                MobSpawn newSpawn = mobListSlice.GetSpawn(jj).Copy();
                monsterHouseStep.Mobs.Add(newSpawn, mobListSlice.GetSpawnRate(jj));
            }
            SpawnList <MobTheme> mobThemeListSlice = MobThemes.GetSpawnList(id);

            for (int jj = 0; jj < mobThemeListSlice.Count; jj++)
            {
                monsterHouseStep.MobThemes.Add(mobThemeListSlice.GetSpawn(jj).Copy(), mobThemeListSlice.GetSpawnRate(jj));
            }

            queue.Enqueue(Priority, monsterHouseStep);
        }
        private static SingleSpawn Parse(Packet packet)
        {
            SingleSpawn data = new SingleSpawn();

            try
            {
                uint objectID = packet.ReadUInt32();

                if (MediaData.Mobs.ContainsKey(objectID)) // object is mob
                {
                    Mob mob = MediaData.Mobs[objectID];

                    #region Mob Parsing
                    if (mob.Type.StartsWith("MOB"))
                    {
                        MobSpawn mobSpawned = ParseMobSpawned(packet);

                        data.Type = SpawnedType.Mob;
                        data.Mob  = mobSpawned;
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Views.BindingFrom.WriteLine("[ERROR][0x3015][Single Spawn] " + ex.Message);
            }
            return(data);
        }
Ejemplo n.º 3
0
 //public static void SetMobSelected(uint id)
 //{
 //    if (MobSpawns.ContainsKey(id))
 //        MobSpawns[id].IsSelected = true;
 //}
 public static void AddMob(MobSpawn mob)
 {
     if (mob != null && mob.UniqueID > 0)
     {
         MobSpawns.Add(mob.UniqueID, mob);
     }
 }
Ejemplo n.º 4
0
        protected MobSpawn GetSeedChar(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs)
        {
            //the contents of that theme can be selected randomly,
            MobSpawn seedSpawn = null;

            //or, to add some sensibility, make it seeded from a random spawn that can already be found in the map
            if (map.TeamSpawns.CanPick)
            {
                TeamSpawner spawn = map.TeamSpawns.Pick(map.Rand);
                if (spawn != null)
                {
                    List <MobSpawn> exampleList = spawn.ChooseSpawns(map.Rand);
                    if (exampleList.Count > 0)
                    {
                        seedSpawn = exampleList[map.Rand.Next(exampleList.Count)];
                    }
                }
            }
            //choose the spawn, then seed the theme with it
            //the theme will take the aspects of the seedspawn and then be ready to spit out a list
            if (seedSpawn == null && specialMobs.CanPick)
            {
                seedSpawn = specialMobs.Pick(map.Rand);
            }
            return(seedSpawn);
        }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     current_spawned_entities = new List <GameObject>();
     mob_spawner       = gameObject.AddComponent(Type.GetType(Enum.GetName(typeof(EntityClass), entity_class), true)) as MobSpawn;
     mob_spawner.label = String.Concat(Enum.GetName(typeof(EntityClass), entity_class), "_", total_spawns);
     mob_spawner.setHostile(is_hostile);
     mob_spawner.setPath(path);
 }
Ejemplo n.º 6
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            ////remove existing spawns
            //ZoneManager.Instance.CurrentMap.TeamSpawns.Clear();

            ShopSecurityState securityState = status.StatusStates.Get <ShopSecurityState>();

            ////add guard spawns
            //for (int ii = 0; ii < securityState.Security.Count; ii++)
            //{
            //    SpecificTeamSpawner post_team = new SpecificTeamSpawner(securityState.Security.GetSpawn(ii).Copy());
            //    ZoneManager.Instance.CurrentMap.TeamSpawns.Add(post_team, securityState.Security.GetSpawnRate(ii));
            //}

            //set spawn rate
            ZoneManager.Instance.CurrentMap.RespawnTime = 0;

            //set spawn max
            ZoneManager.Instance.CurrentMap.MaxFoes = 0;

            //spawn 10 times
            List <Loc> randLocs = ZoneManager.Instance.CurrentMap.GetFreeToSpawnTiles();

            for (int ii = 0; ii < 10; ii++)
            {
                if (randLocs.Count == 0)
                {
                    break;
                }

                int      randIndex = DataManager.Instance.Save.Rand.Next(randLocs.Count);
                Loc      dest      = randLocs[randIndex];
                MobSpawn spawn     = securityState.Security.Pick(DataManager.Instance.Save.Rand);
                yield return(CoroutineManager.Instance.StartCoroutine(PeriodicSpawnEntranceGuards.PlaceGuard(spawn, dest, GuardStatus)));

                randLocs.RemoveAt(randIndex);
            }

            List <Loc> exitLocs = WarpToEndEvent.FindExits();

            //spawn once specifically on the stairs
            foreach (Loc exitLoc in exitLocs)
            {
                Loc?dest = ZoneManager.Instance.CurrentMap.GetClosestTileForChar(null, exitLoc);
                if (!dest.HasValue)
                {
                    continue;
                }

                MobSpawn spawn = securityState.Security.Pick(DataManager.Instance.Save.Rand);
                yield return(CoroutineManager.Instance.StartCoroutine(PeriodicSpawnEntranceGuards.PlaceGuard(spawn, dest.Value, GuardStatus)));
            }
        }
Ejemplo n.º 7
0
        public override void DrawOnMap(T map)
        {
            if (this.Draw.Width != this.Tiles.Length || this.Draw.Height != this.Tiles[0].Length)
            {
                this.DrawMapDefault(map);
                return;
            }

            base.DrawOnMap(map);

            //create new bosses from the spawns, adjusting their locations
            MobSpawnState mobSpawnState = new MobSpawnState();

            foreach (MobSpawn spawn in Bosses)
            {
                MobSpawn    newSpawn = spawn.Copy();
                MobSpawnLoc setLoc   = null;
                foreach (MobSpawnExtra extra in newSpawn.SpawnFeatures)
                {
                    MobSpawnLoc extraLoc = extra as MobSpawnLoc;
                    if (extraLoc != null)
                    {
                        setLoc = extraLoc;
                        break;
                    }
                }

                if (setLoc != null)
                {
                    setLoc.Loc = setLoc.Loc + this.Draw.Start;
                }
                else
                {
                    setLoc = new MobSpawnLoc(this.Draw.Center);
                    newSpawn.SpawnFeatures.Add(setLoc);
                }
                mobSpawnState.Spawns.Add(newSpawn);
            }

            ////place the boss bounds here
            //CheckIntrudeBoundsEvent trapZone = new CheckIntrudeBoundsEvent();
            //trapZone.Bounds = new Rect(Trigger.Start + new Loc(this.Draw.Start), Trigger.Size);
            //{
            //    LockdownMapEvent lockdown = new LockdownMapEvent();
            //    lockdown.Bounds = new Rect(this.Draw.Start - new Loc(1), this.Draw.Size + new Loc(2));
            //    trapZone.Effects.Add(lockdown);
            //    trapZone.Effects.Add(new BossSpawnEvent(this.Draw, mobSpawns.ToArray()));
            //}
            //map.CheckEvents.Add(trapZone);


            EffectTile newEffect = new EffectTile(TriggerTile, true, Trigger + this.Draw.Start);

            newEffect.TileStates.Set(mobSpawnState);
            newEffect.TileStates.Set(new BoundsState(new Rect(this.Draw.Start - new Loc(1), this.Draw.Size + new Loc(2))));
            newEffect.TileStates.Set(new SongState(Song));
            ((IPlaceableGenContext <EffectTile>)map).PlaceItem(Trigger + this.Draw.Start, newEffect);
        }
Ejemplo n.º 8
0
 public void DeleteSpawn()
 {
     Dictionary<string, object> props = new Dictionary<string, object>();
     props.Add("senderOid", ClientAPI.GetPlayerOid());
     props.Add("markerID", spawnInCreation.ID);
     NetworkAPI.SendExtensionMessage(0, false, "ao.DELETE_SPAWN_MARKER", props);
     spawnInCreation.DeleteMarker();
     spawnInCreation = null;
 }
Ejemplo n.º 9
0
        protected override IEnumerable <int> GetSpecies(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs)
        {
            MobSpawn baseMob = GetSeedChar(map, specialMobs);

            if (baseMob != null)
            {
                int earliestBaseStage = baseMob.BaseForm.Species;

                MonsterFeatureData featureIndex = DataManager.Instance.UniversalData.Get <MonsterFeatureData>();
                FormFeatureSummary baseData     = featureIndex.FeatureData[earliestBaseStage][0];
                yield return(baseData.Family);
            }
        }
Ejemplo n.º 10
0
        public static MobSpawn GetMobMinDistance()
        {
            MobSpawn mob = new MobSpawn();

            if (MobSpawns.Count > 0)
            {
                mob = MobSpawns
                      .Where(a => !a.Value.IsDie)
                      .OrderBy(a => a.Value.Distance)
                      .FirstOrDefault().Value;
            }

            return(mob);
        }
Ejemplo n.º 11
0
        public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue)
        {
            int id = zoneContext.CurrentID;

            foreach (int floorId in SpreadPlan.DropPoints)
            {
                if (floorId != zoneContext.CurrentID)
                {
                    continue;
                }
                foreach (IGenPriority vaultStep in VaultSteps)
                {
                    queue.Enqueue(vaultStep.Priority, vaultStep.GetItem());
                }

                {
                    SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id);
                    PickerSpawner <ListMapGenContext, MapItem> constructedSpawns = new PickerSpawner <ListMapGenContext, MapItem>(new LoopedRand <MapItem>(itemListSlice, ItemAmount[id]));

                    List <IStepSpawner <ListMapGenContext, MapItem> > steps = new List <IStepSpawner <ListMapGenContext, MapItem> >();
                    steps.Add(constructedSpawns);
                    if (ItemSpawners.ContainsItem(id))
                    {
                        IStepSpawner <ListMapGenContext, MapItem> treasures = ItemSpawners[id].Copy();
                        steps.Add(treasures);
                    }
                    PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> > groupRand   = new PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> >(steps.ToArray());
                    RandomRoomSpawnStep <ListMapGenContext, MapItem>             detourItems = ItemPlacements[id].Copy();
                    detourItems.Spawn = new MultiStepSpawner <ListMapGenContext, MapItem>(groupRand);
                    queue.Enqueue(ItemPriority, detourItems);
                }


                SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id);
                if (mobListSlice.CanPick)
                {
                    //secret enemies
                    SpecificTeamSpawner specificTeam = new SpecificTeamSpawner();

                    MobSpawn newSpawn = mobListSlice.Pick(context.Rand).Copy();
                    specificTeam.Spawns.Add(newSpawn);

                    //use bruteforce clone for this
                    PlaceRandomMobsStep <ListMapGenContext> secretMobPlacement = MobPlacements[id].Copy();
                    secretMobPlacement.Spawn = new LoopedTeamSpawner <ListMapGenContext>(specificTeam, MobAmount[id]);
                    queue.Enqueue(MobPriority, secretMobPlacement);
                }
            }
        }
Ejemplo n.º 12
0
        protected override List <int> GetTypes(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs)
        {
            Dictionary <int, int> elementFrequency = new Dictionary <int, int>();

            for (int ii = 0; ii < map.TeamSpawns.Count; ii++)
            {
                SpawnList <MobSpawn> mobSpawns = map.TeamSpawns.GetSpawn(ii).GetPossibleSpawns();
                foreach (MobSpawn spawn in mobSpawns.EnumerateOutcomes())
                {
                    MonsterFeatureData featureIndex = DataManager.Instance.UniversalData.Get <MonsterFeatureData>();
                    FormFeatureSummary baseData     = featureIndex.FeatureData[spawn.BaseForm.Species][Math.Max(0, spawn.BaseForm.Form)];
                    if (baseData.Element1 != 00)
                    {
                        MathUtils.AddToDictionary(elementFrequency, baseData.Element1, 1);
                    }
                    if (baseData.Element2 != 00)
                    {
                        MathUtils.AddToDictionary(elementFrequency, baseData.Element2, 1);
                    }
                }
            }

            if (elementFrequency.Count == 0)
            {
                for (int ii = 0; ii < specialMobs.Count; ii++)
                {
                    MobSpawn           spawn        = specialMobs.GetSpawn(ii);
                    MonsterFeatureData featureIndex = DataManager.Instance.UniversalData.Get <MonsterFeatureData>();
                    FormFeatureSummary baseData     = featureIndex.FeatureData[spawn.BaseForm.Species][Math.Max(0, spawn.BaseForm.Form)];
                    if (baseData.Element1 != 00)
                    {
                        MathUtils.AddToDictionary(elementFrequency, baseData.Element1, 1);
                    }
                    if (baseData.Element2 != 00)
                    {
                        MathUtils.AddToDictionary(elementFrequency, baseData.Element2, 1);
                    }
                }
            }

            List <int> result = new List <int>();

            if (elementFrequency.Count > 0)
            {
                //choose randomly from the top 3 types
                List <(int, int)> elements = new List <(int, int)>();
                foreach (int key in elementFrequency.Keys)
                {
                    elements.Add((key, elementFrequency[key]));
Ejemplo n.º 13
0
        protected bool CheckIfAllowed(BaseMapGenContext map, MobSpawn spawn, IEnumerable <int> species)
        {
            MonsterFeatureData featureIndex = DataManager.Instance.UniversalData.Get <MonsterFeatureData>();
            FormFeatureSummary baseData     = featureIndex.FeatureData[spawn.BaseForm.Species][0];

            foreach (int baseStage in species)
            {
                if (baseStage == baseData.Family)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 14
0
 void Start()
 {
     //DontDestroyOnLoad(gameObject);
     _money        = 20;
     _plusmoney    = 1;
     _TacticsGauge = 30;
     texted.text   = "資金: 0";
     _slider       = GameObject.Find("TacticalGauge").GetComponent <Slider>();
     spawns        = GetComponent <MobSpawn>();
     Style         = style.Normal;
     _slider.value = TacticsGauge;
     pause         = false;
     tt            = TOWER.GetComponent <tower>();
     times         = 0;
     //StartCoroutine(Loop());
     //GetComponent<Text>().text = (Money).ToString();
 }
Ejemplo n.º 15
0
        private void SpawnMobs(IFieldObject <MobSpawn> mobSpawn)
        {
            List <CoordF> spawnPoints = MobSpawn.SelectPoints(mobSpawn.Value.SpawnRadius);

            foreach (NpcMetadata mob in mobSpawn.Value.SpawnMobs)
            {
                int spawnCount = mob.NpcMetadataBasic.GroupSpawnCount;  // Spawn count changes due to field effect (?)
                if (mobSpawn.Value.Mobs.Count + spawnCount > mobSpawn.Value.MaxPopulation)
                {
                    break;
                }

                for (int i = 0; i < spawnCount; i++)
                {
                    IFieldObject <Mob> fieldMob = RequestFieldObject(new Mob(mob.Id, mobSpawn));
                    fieldMob.Coord = mobSpawn.Coord + spawnPoints[mobSpawn.Value.Mobs.Count % spawnPoints.Count];
                    AddMob(fieldMob);
                }
            }
        }
Ejemplo n.º 16
0
        public override List <MobSpawn> GenerateMobs(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs)
        {
            int                  mobCount = Amount.Pick(map.Rand);
            List <MobSpawn>      spawners = new List <MobSpawn>();
            IEnumerable <int>    species  = GetSpecies(map, specialMobs);
            SpawnList <MobSpawn> subList  = new SpawnList <MobSpawn>();

            for (int ii = 0; ii < specialMobs.Count; ii++)
            {
                MobSpawn spawn = specialMobs.GetSpawn(ii);
                if (CheckIfAllowed(map, spawn, species))
                {
                    subList.Add(spawn, specialMobs.GetSpawnRate(ii));
                }
            }
            for (int ii = 0; ii < map.TeamSpawns.Count; ii++)
            {
                SpawnList <MobSpawn> memberSpawns = map.TeamSpawns.GetSpawn(ii).GetPossibleSpawns();
                for (int jj = 0; ii < memberSpawns.Count; jj++)
                {
                    MobSpawn spawn = memberSpawns.GetSpawn(jj);
                    if (CheckIfAllowed(map, spawn, species))
                    {
                        subList.Add(spawn, memberSpawns.GetSpawnRate(jj));
                    }
                }
            }

            if (subList.Count > 0)
            {
                for (int ii = 0; ii < mobCount; ii++)
                {
                    spawners.Add(subList.Pick(map.Rand));
                }
            }

            return(spawners);
        }
Ejemplo n.º 17
0
 public SingleSpawn()
 {
     Type = SpawnedType.None;
     Mob  = new MobSpawn();
 }
Ejemplo n.º 18
0
 public void StartMobSpawner()
 {
     mobCreationState = MobCreationState.SpawnMob;
     spawnInCreation = new MobSpawn ();
     AtavismUiSystem.AddFrame ("MobSpawn", new Rect (10, Screen.height - 400, 200, 350));
 }
Ejemplo n.º 19
0
 public void HandleSpawnList(Dictionary<string, object> props)
 {
     AtavismLogger.LogDebugMessage ("Got spawn list");
     ClearSpawns();
     int numMarkers = (int)props ["numMarkers"];
     for (int i  = 0; i < numMarkers; i++) {
         MobSpawn spawn = new MobSpawn ();
         spawn.ID = (int)props ["markerID_" + i];
         spawn.position = (Vector3)props ["markerLoc_" + i];
         spawn.orientation = (Quaternion)props ["markerOrient_" + i];
         spawn.CreateMarkerObject (spawnMarkerTemplate);
         mobSpawns.Add (spawn.ID, spawn);
         AtavismLogger.LogDebugMessage ("Added spawn: " + spawn.ID);
     }
 }
Ejemplo n.º 20
0
 public void HandleSpawnData(Dictionary<string, object> props)
 {
     int spawnID = (int)props ["spawnID"];
     spawnInCreation = mobSpawns[spawnID];
     //spawnInCreation.ID =
     spawnInCreation.numSpawns = (int)props ["numSpawns"];
     spawnInCreation.despawnTime = (int)props ["despawnTime"];
     spawnInCreation.respawnTime = (int)props ["respawnTime"];
     spawnInCreation.spawnRadius = (int)props ["spawnRadius"];
     spawnInCreation.mobTemplateID = (int)props ["mobTemplate"];
     spawnInCreation.mobTemplate = GetMobTemplateByID(spawnInCreation.mobTemplateID);
     spawnInCreation.roamRadius = (int)props ["roamRadius"];
     //spawnInCreation.hasCombat = (bool)props["hasCombat"];
     //spawnInCreation.startsQuests = (List<object>)props["startsQuests"];
     LinkedList<object> questList = (LinkedList<object>)props ["startsQuests"];
     foreach (object quest in questList) {
         spawnInCreation.startsQuests.Add ((int)quest);
     }
     //spawnInCreation.endsQuests = (List<object>)props["endsQuests"];
     questList = (LinkedList<object>)props ["endsQuests"];
     foreach (object quest in questList) {
         spawnInCreation.endsQuests.Add ((int)quest);
     }
     LinkedList<object> dialogueList = (LinkedList<object>)props ["startsDialogues"];
     foreach (object dialogue in dialogueList) {
         spawnInCreation.startsDialogues.Add ((int)dialogue);
     }
     spawnInCreation.pickupItemID = (int)props ["pickupItem"];
     spawnInCreation.isChest = (bool)props ["isChest"];
     mobCreationState = MobCreationState.EditSpawn;
 }
        //public static ItemSpawned ParseItemSpawned(Packet packet, Item item)
        //{
        //    ItemSpawned result = new ItemSpawned();
        //    try
        //    {
        //        string type = item.Type;

        //        if (type.StartsWith("ITEM_ETC_GOLD"))
        //        {
        //            packet.ReadUInt32(); // Amount:so tien
        //        }
        //        else if (type.StartsWith("ITEM_QSP"))
        //        {
        //            packet.ReadAscii(); // Name
        //        }
        //        else if (type.StartsWith("ITEM_CH") || type.StartsWith("ITEM_EU"))
        //        {
        //            packet.ReadUInt8(); // Plus
        //        }

        //        uint uniqueID = packet.ReadUInt32(); //  UniqueID

        //        packet.ReadUInt8(); //XSEC
        //        packet.ReadUInt8(); //YSEC
        //        packet.ReadSingle(); //X
        //        packet.ReadSingle(); //Z
        //        packet.ReadSingle(); //Y

        //        packet.ReadUInt16(); //POS

        //        byte owner = packet.ReadUInt8();//is owner
        //        if (owner == 1) // Owner exist
        //        {
        //            uint ownerID = packet.ReadUInt32(); //characte id
        //        }

        //        byte blue = packet.ReadUInt8(); //Item Blued
        //        packet.ReadUInt8();//unk = 5
        //        packet.ReadUInt32();//mosterID

        //        result = new ItemSpawned(uniqueID, item, owner, blue);
        //    }
        //    catch (Exception ex)
        //    {
        //        Views.BindingView.Write("[ERROR] [ParseSpawnSpecificObject::ParseItemSpawned]");
        //        Views.BindingView.WriteLine(ex.Message);
        //    }
        //    return result;
        //}

        public static MobSpawn ParseMobSpawned(Packet packet)
        {
            MobSpawn result = new MobSpawn();
            //try
            //{
            uint uniqueID = packet.ReadUInt32();     // MOB UniqueID

            //current coor
            byte  xsec   = packet.ReadUInt8();
            byte  ysec   = packet.ReadUInt8();
            float xcoord = packet.ReadSingle();
            float zcoord = packet.ReadSingle();
            float ycoord = packet.ReadSingle();

            ushort Position = packet.ReadUInt16(); // Position
            byte   move     = packet.ReadUInt8();  // Moving
            byte   Running  = packet.ReadUInt8();  // Running

            //next coor
            if (move == 1)
            {
                xsec = packet.ReadUInt8();
                ysec = packet.ReadUInt8();
                if (ysec == 0x80)
                {
                    xcoord = packet.ReadUInt16() - packet.ReadUInt16();
                    zcoord = packet.ReadUInt16() - packet.ReadUInt16();
                    ycoord = packet.ReadUInt16() - packet.ReadUInt16();
                }
                else
                {
                    xcoord = packet.ReadUInt16();
                    zcoord = packet.ReadUInt16();
                    ycoord = packet.ReadUInt16();
                }
            }
            else
            {
                packet.ReadUInt8();     // Unknown
                packet.ReadUInt16();    // Unknwon
            }

            byte alive = packet.ReadUInt8(); // Alive

            packet.ReadUInt8();              // Unknown
            packet.ReadUInt8();              // Unknown
            packet.ReadUInt8();              // Zerk Active
            packet.ReadSingle();             // Walk Speed
            packet.ReadSingle();             // Run Speed
            packet.ReadSingle();             // Zerk Speed
            packet.ReadUInt32();             // Unknown
            byte type = packet.ReadUInt8();

            if (alive == 1)
            {
                Coordinate coordinate = new Coordinate(xsec, ysec, xcoord, ycoord, zcoord);
                double     distance   = Coordinate.Distance(coordinate, Globals.Character.Coordinate);
                result = new MobSpawn(uniqueID, coordinate, distance);
            }
            //}
            //catch (Exception ex)
            //{
            //    Views.BindingView.Write("[ERROR] [ParseSpawnSpecificObject::ParseMobSpawned]");
            //    Views.BindingView.WriteLine(ex.Message);
            //}
            return(result);
        }
Ejemplo n.º 22
0
        public override void Apply(T map)
        {
            Grid.LocTest checkBlock = (Loc testLoc) =>
            {
                return(!map.Tiles[testLoc.X][testLoc.Y].TileEquivalent(map.RoomTerrain) || map.HasTileEffect(testLoc));
            };

            //choose a room to put the chest in
            //do not choose a room that would cause disconnection of the floor
            List <int> possibleRooms = new List <int>();

            for (int ii = 0; ii < map.RoomPlan.RoomCount; ii++)
            {
                FloorRoomPlan testPlan = map.RoomPlan.GetRoomPlan(ii);
                //if (map.RoomPlan.IsChokePoint(new RoomHallIndex(ii, false)))
                //    continue;
                if (!BaseRoomFilter.PassesAllFilters(testPlan, this.Filters))
                {
                    continue;
                }

                //also do not choose a room that contains the end stairs
                IViewPlaceableGenContext <MapGenExit> exitMap = (IViewPlaceableGenContext <MapGenExit>)map;
                if (Collision.InBounds(testPlan.RoomGen.Draw, exitMap.GetLoc(0)))
                {
                    continue;
                }

                possibleRooms.Add(ii);
            }

            if (possibleRooms.Count == 0)
            {
                return;
            }

            List <Loc> freeTiles = new List <Loc>();
            IRoomGen   room      = null;

            while (possibleRooms.Count > 0)
            {
                int chosenRoom = map.Rand.Next(possibleRooms.Count);
                room = map.RoomPlan.GetRoom(possibleRooms[chosenRoom]);

                //get all places that the chest is eligible
                freeTiles = Grid.FindTilesInBox(room.Draw.Start, room.Draw.Size, (Loc testLoc) =>
                {
                    if (map.Tiles[testLoc.X][testLoc.Y].TileEquivalent(map.RoomTerrain) && !map.HasTileEffect(testLoc) &&
                        map.Tiles[testLoc.X][testLoc.Y + 1].TileEquivalent(map.RoomTerrain) && !map.HasTileEffect(new Loc(testLoc.X, testLoc.Y + 1)) &&
                        !map.PostProcGrid[testLoc.X][testLoc.Y].Status[(int)PostProcType.Panel] &&
                        !map.PostProcGrid[testLoc.X][testLoc.Y].Status[(int)PostProcType.Item])
                    {
                        if (Grid.GetForkDirs(testLoc, checkBlock, checkBlock).Count < 2)
                        {
                            foreach (MapItem item in map.Items)
                            {
                                if (item.TileLoc == testLoc)
                                {
                                    return(false);
                                }
                            }
                            foreach (Team team in map.AllyTeams)
                            {
                                foreach (Character testChar in team.EnumerateChars())
                                {
                                    if (testChar.CharLoc == testLoc)
                                    {
                                        return(false);
                                    }
                                }
                            }
                            foreach (Team team in map.MapTeams)
                            {
                                foreach (Character testChar in team.EnumerateChars())
                                {
                                    if (testChar.CharLoc == testLoc)
                                    {
                                        return(false);
                                    }
                                }
                            }
                            return(true);
                        }
                    }
                    return(false);
                });
                if (freeTiles.Count > 0)
                {
                    break;
                }
                possibleRooms.RemoveAt(chosenRoom);
            }

            //can't find any free tile in any room, return
            if (freeTiles.Count == 0)
            {
                return;
            }

            if (!ItemThemes.CanPick)
            {
                return;
            }
            //choose which item theme to work with
            ItemTheme chosenItemTheme = ItemThemes.Pick(map.Rand);

            //the item spawn list in this class dictates the items available for spawning
            //it will be queried for items that match the theme selected
            List <MapItem> chosenItems = chosenItemTheme.GenerateItems(map, Items);

            if (chosenItems.Count == 0)
            {
                return;
            }

            int randIndex = map.Rand.Next(freeTiles.Count);
            Loc loc       = freeTiles[randIndex];


            EffectTile spawnedChest = new EffectTile(37, true);

            if (Ambush && MobThemes.CanPick)
            {
                spawnedChest.Danger = true;
                //the mob theme will be selected randomly
                MobTheme chosenMobTheme = MobThemes.Pick(map.Rand);

                //the mobs in this class are the ones that would be available when the game wants to spawn things outside of the floor's spawn list
                //it will be queried for monsters that match the theme provided
                List <MobSpawn> chosenMobs = chosenMobTheme.GenerateMobs(map, Mobs);


                MobSpawnState mobSpawn = new MobSpawnState();
                foreach (MobSpawn mob in chosenMobs)
                {
                    MobSpawn copyMob = mob.Copy();
                    if (map.Rand.Next(ALT_COLOR_ODDS) == 0)
                    {
                        copyMob.BaseForm.Skin = 1;
                    }
                    mobSpawn.Spawns.Add(copyMob);
                }
                spawnedChest.TileStates.Set(mobSpawn);
            }

            ItemSpawnState itemSpawn = new ItemSpawnState();

            itemSpawn.Spawns = chosenItems;
            spawnedChest.TileStates.Set(itemSpawn);

            Rect wallBounds = new Rect(room.Draw.X - 1, room.Draw.Y - 1, room.Draw.Size.X + 2, room.Draw.Size.Y + 2);

            spawnedChest.TileStates.Set(new BoundsState(wallBounds));

            ((IPlaceableGenContext <EffectTile>)map).PlaceItem(loc, spawnedChest);
            map.PostProcGrid[loc.X][loc.Y].Status[(int)PostProcType.Panel] = true;
            map.PostProcGrid[loc.X][loc.Y].Status[(int)PostProcType.Item]  = true;

            GenContextDebug.DebugProgress("Placed Chest");
        }
Ejemplo n.º 23
0
        public override void Apply(T map)
        {
            if (!ItemThemes.CanPick)
            {
                return;
            }

            if (!MobThemes.CanPick)
            {
                return;
            }

            Rect bounds = new Rect(0, 0, map.Width, map.Height);

            //determine the number of free tiles to put items on; trim the maximum item spawn accordingly (maximum <= 1/2 of free tiles)
            //determine the number of free tiles to put mobs on; trim the maximum mob spawn accordingly (maximum <= 1/2 of free tiles)
            List <Loc> itemTiles = new List <Loc>();
            int        mobSpace  = 0;

            for (int x = bounds.X; x < bounds.X + bounds.Size.X; x++)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Size.Y; y++)
                {
                    Loc testLoc = new Loc(x, y);
                    if (!map.TileBlocked(testLoc))
                    {
                        if (!map.HasTileEffect(new Loc(x, y)) && !map.PostProcGrid[x][y].Status[(int)PostProcType.Panel] && !map.PostProcGrid[x][y].Status[(int)PostProcType.Item])
                        {
                            bool hasItem = false;
                            foreach (MapItem item in map.Items)
                            {
                                if (item.TileLoc == testLoc)
                                {
                                    hasItem = true;
                                    break;
                                }
                            }
                            if (!hasItem)
                            {
                                itemTiles.Add(testLoc);
                            }
                        }
                        bool hasMob = false;
                        foreach (Team team in map.AllyTeams)
                        {
                            foreach (Character testChar in team.EnumerateChars())
                            {
                                if (testChar.CharLoc == testLoc)
                                {
                                    hasMob = true;
                                    break;
                                }
                            }
                        }
                        foreach (Team team in map.MapTeams)
                        {
                            foreach (Character testChar in team.EnumerateChars())
                            {
                                if (testChar.CharLoc == testLoc)
                                {
                                    hasMob = true;
                                    break;
                                }
                            }
                        }
                        if (!hasMob)
                        {
                            mobSpace++;
                        }
                    }
                }
            }

            //choose which item theme to work with
            ItemTheme chosenItemTheme = ItemThemes.Pick(map.Rand);

            //the item spawn list in this class dictates the items available for spawning
            //it will be queried for items that match the theme selected
            List <MapItem> chosenItems = chosenItemTheme.GenerateItems(map, Items);

            //place the items
            for (int ii = 0; ii < chosenItems.Count; ii++)
            {
                if (itemTiles.Count > 0)
                {
                    MapItem item      = new MapItem(chosenItems[ii]);
                    int     randIndex = map.Rand.Next(itemTiles.Count);
                    ((IPlaceableGenContext <MapItem>)map).PlaceItem(itemTiles[randIndex], item);
                    itemTiles.RemoveAt(randIndex);
                }
            }



            //the mob theme will be selected randomly
            MobTheme chosenMobTheme = MobThemes.Pick(map.Rand);

            //the mobs in this class are the ones that would be available when the game wants to spawn things outside of the floor's spawn list
            //it will be queried for monsters that match the theme provided
            List <MobSpawn> chosenMobs = chosenMobTheme.GenerateMobs(map, Mobs);

            //cover the room in a check that holds all of the monsters, and covers the room's bounds
            CheckIntrudeBoundsEvent check = new CheckIntrudeBoundsEvent();

            check.Bounds = bounds;
            {
                RevealAllEvent reveal = new RevealAllEvent();
                check.Effects.Add(reveal);

                GiveMapStatusSingleEvent statusEvent = new GiveMapStatusSingleEvent(30, 0);
                check.Effects.Add(statusEvent);

                MonsterHouseMapEvent house = new MonsterHouseMapEvent();
                house.Bounds = bounds;

                foreach (MobSpawn mob in chosenMobs)
                {
                    MobSpawn copyMob = mob.Copy();
                    if (map.Rand.Next(ALT_COLOR_ODDS) == 0)
                    {
                        copyMob.BaseForm.Skin = 1;
                    }
                    house.Mobs.Add(copyMob);
                }
                check.Effects.Add(house);
            }

            AddIntrudeStep(map, check);
        }