public void AddSpawnedMonster(long uniqueId, HeroConfig.BasicStats basicStats, Entity entity)
        {
            if (spawnedMonstersThatAreNotEnvironmentRole.Contains(uniqueId))
            {
                return;
            }
            if (basicStats.ShowRole() == EntityRole.Environment)
            {
                return;
            }

            spawnedMonstersThatAreNotEnvironmentRole.Add(uniqueId);

            CacheTemplateArgsComponent argsComponent = entity.GetComponent <CacheTemplateArgsComponent>();

            if (argsComponent == null)
            {
                return;
            }

            SpawnSourceInfo source = new DungeonSystemSpawnSourceInfo();

            source = argsComponent.TemplateArgs.GetEntry <SpawnSourceInfo>(TemplateArgsName.SpawnSource);
            if (source.Source != SpawnSource.Dungeon_System)
            {
                return;
            }

            naturalBornMonstersThatAreNotEnvironment.Add(uniqueId);
        }
Exemplo n.º 2
0
        public DungeonFactory(DungeonConfig dungeonConfig, EntitySpawner entitySpawner,
                              CharacterId heroId, List <SsarTuple <int, GameObject> > gateAndId,
                              DamageSystem damageSystem, PromiseWorld world, ConfigManager configManager)
        {
            notNullReference.Check(dungeonConfig, "dungeonConfig");
            notNullReference.Check(entitySpawner, "entitySpawner");
            notNullReference.Check(heroId, "heroId");
            notNullReference.Check(gateAndId, "gateAndId");
            notNullReference.Check(damageSystem, "damageSystem");
            notNullReference.Check(configManager, "configManager");

            heroAndMonsterConfig = configManager.GetConfig <HeroAndMonsterConfig>();
            defaultEnvironment   = new DefaultDungeonEnvironment(entitySpawner, gateAndId);
            this.dungeonConfig   = dungeonConfig;

            world.EntityCreationEventHandler += (sender, arg) =>
            {
                Entity entity = arg.Entity;
                if (arg.EntityType != EntityType.Creature)
                {
                    return;
                }

                if (entity.GetComponent <SkillComponent>().CharacterId.Equals(heroId))
                {
                    defaultEnvironment.SetHero(new DefaultDungeonCharacter(entity, damageSystem));
                }
            };

            damageSystem.EntityDeathEventHandler_Late += (sender, args) =>
            {
                CacheTemplateArgsComponent argsComponent = args.Entity.GetComponent <CacheTemplateArgsComponent>();
                SpawnSourceInfo            source        = argsComponent?.TemplateArgs.GetEntry <SpawnSourceInfo>(TemplateArgsName.SpawnSource) ?? new DungeonSystemSpawnSourceInfo();
                EntityRole role = args.Entity.GetComponent <StatsComponent>().BasicStatsFromConfig.ShowRole();
                defaultEnvironment.AddDeadMonster(new EntityMonster(Time.timeSinceLevelLoad,
                                                                    args.Entity.GetComponent <SkillComponent>().CharacterId, args.Entity.UniqueId, source, role));
            };

            entitySpawner.EntitySpawnEventHandler += (sender, args) =>
            {
                if (args.Entity.Group == EntityGroup.GROUP_A)
                {
                    return;
                }
                defaultEnvironment.AddSpawnedMonster(args.UniqueId, args.BasicStats, args.Entity);
            };
        }