Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ElevatedOperationContext"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="applicationContext">A reference to the application context.</param>
        /// <param name="mapDescriptor">A reference to the map descriptor in use.</param>
        /// <param name="map">A reference to the map.</param>
        /// <param name="creatureManager">A reference to the creature manager in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        /// <param name="creatureFactory">A reference to the creature factory in use.</param>
        /// <param name="containerManager">A reference to the container manager in use.</param>
        /// <param name="gameOperationsApi">A reference to the game operations api.</param>
        /// <param name="combatOperationsApi">A reference to the combat operations api.</param>
        /// <param name="pathFinderAlgo">A reference to the path finding algorithm in use.</param>
        /// <param name="predefinedItemSet">A reference to the predefined item set declared.</param>
        /// <param name="scheduler">A reference to the scheduler instance.</param>
        public ElevatedOperationContext(
            ILogger logger,
            IApplicationContext applicationContext,
            IMapDescriptor mapDescriptor,
            IMap map,
            ICreatureManager creatureManager,
            IItemFactory itemFactory,
            ICreatureFactory creatureFactory,
            IContainerManager containerManager,
            IGameOperationsApi gameOperationsApi,
            ICombatOperationsApi combatOperationsApi,
            IPathFinder pathFinderAlgo,
            IPredefinedItemSet predefinedItemSet,
            IScheduler scheduler)
            : base(
                logger,
                mapDescriptor,
                map,
                creatureManager,
                itemFactory,
                creatureFactory,
                containerManager,
                gameOperationsApi,
                combatOperationsApi,
                pathFinderAlgo,
                predefinedItemSet,
                scheduler)
        {
            applicationContext.ThrowIfNull(nameof(applicationContext));

            this.ApplicationContext = applicationContext;
        }
Example #2
0
        public Engine()
        {
            this.creatureFactory = new CreatureFactory();
            this.gearFactory = new GearFactory();

            this.enemyUnits = new List<ICreature>();
            this.playerCharacterItem = new List<IItem>();
            this.playerCharacterWeapon = new List<IWeapon>();
        }
Example #3
0
 public CreatureSpawner(IPlayArea playArea, ICreatureFactory creatureFactory, ICreatureRegistry creatureRegistry,
                        IAutonomousFactory autonomousFactory, IAutonomousRegistry autonomousRegistry, IRecipientRegistry recipientRegistry)
 {
     _playArea           = playArea;
     _creatureFactory    = creatureFactory;
     _creatureRegistry   = creatureRegistry;
     _autonomousFactory  = autonomousFactory;
     _autonomousRegistry = autonomousRegistry;
     _recipientRegistry  = recipientRegistry;
 }
    void Awake()
    {
        state      = new CreatureState();
        metabolism = new CreatureMetabolism(gameObject, settings.StartingEnergy);

        size            = new CreatureSize(sizeSettings, settings.Size, metabolism, transform);
        sense           = new CreatureSense(senseSettings, settings.SenseRadius, state, metabolism, transform);
        movement        = new CreatureMovement(velocitySettings, settings.Velocity, state, metabolism, sense, transform);
        creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, settings.Size);
    }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="applicationContext">A reference to the application context.</param>
        /// <param name="mapDescriptor">A reference to the map descriptor in use.</param>
        /// <param name="map">A reference to the map.</param>
        /// <param name="creatureManager">A reference to the creature manager in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        /// <param name="creatureFactory">A reference to the creature factory in use.</param>
        /// <param name="containerManager">A reference to the container manager in use.</param>
        /// <param name="pathFinderAlgo">A reference to the path finding algorithm in use.</param>
        /// <param name="predefinedItemSet">A reference to the predefined item set declared.</param>
        /// <param name="monsterSpawnsLoader">A reference to the monster spawns loader.</param>
        /// <param name="scheduler">A reference to the global scheduler instance.</param>
        public Game(
            ILogger logger,
            IApplicationContext applicationContext,
            IMapDescriptor mapDescriptor,
            IMap map,
            ICreatureManager creatureManager,
            IItemFactory itemFactory,
            ICreatureFactory creatureFactory,
            IContainerManager containerManager,
            IPathFinder pathFinderAlgo,
            IPredefinedItemSet predefinedItemSet,
            IMonsterSpawnLoader monsterSpawnsLoader,
            IScheduler scheduler)
        {
            logger.ThrowIfNull(nameof(logger));
            applicationContext.ThrowIfNull(nameof(applicationContext));
            mapDescriptor.ThrowIfNull(nameof(mapDescriptor));
            map.ThrowIfNull(nameof(map));
            creatureManager.ThrowIfNull(nameof(creatureManager));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            creatureFactory.ThrowIfNull(nameof(creatureFactory));
            containerManager.ThrowIfNull(nameof(containerManager));
            pathFinderAlgo.ThrowIfNull(nameof(pathFinderAlgo));
            predefinedItemSet.ThrowIfNull(nameof(predefinedItemSet));
            monsterSpawnsLoader.ThrowIfNull(nameof(monsterSpawnsLoader));
            scheduler.ThrowIfNull(nameof(scheduler));

            this.logger             = logger.ForContext <Game>();
            this.applicationContext = applicationContext;
            this.mapDescriptor      = mapDescriptor;
            this.map               = map;
            this.creatureManager   = creatureManager;
            this.itemFactory       = itemFactory;
            this.creatureFactory   = creatureFactory;
            this.containerManager  = containerManager;
            this.pathFinder        = pathFinderAlgo;
            this.predefinedItemSet = predefinedItemSet;
            this.scheduler         = scheduler;

            // Initialize game vars.
            this.worldInfo = new WorldInformation()
            {
                Status     = WorldState.Loading,
                LightColor = (byte)LightColors.White,
                LightLevel = (byte)LightLevels.World,
            };

            // Load the spawns
            this.monsterSpawns = monsterSpawnsLoader.LoadSpawns();

            // Hook some event handlers.
            this.scheduler.EventFired += this.ProcessFiredEvent;
            this.map.WindowLoaded     += this.OnMapWindowLoaded;
        }
Example #6
0
        public Engine()
        {
            this.creatureFactory = new CreatureFactory();
            this.gearFactory     = new GearFactory();

            this.playerCharacterItem   = new List <IItem>();
            this.playerCharacterWeapon = new List <IWeapon>();

            this.enemyUnitItem   = new List <IItem>();
            this.enemyUnitWeapon = new List <IWeapon>();
        }
    /// <summary>
    /// Mutates creature attributes, based on parent creature attributes
    /// </summary>
    /// <param name="parent">parent creature</param>
    public void Mutate(ICreature parent)
    {
        float newStartingEnergy = MutateAttribute(parent.StartingEnergy);
        float newSize           = Mathf.Clamp(MutateAttribute(parent.Size), 0.1f, 1000f);
        float newVelocity       = MutateAttribute(parent.Velocity);
        float newSenseRadius    = MutateAttribute(parent.SenseRadius);

        metabolism      = new CreatureMetabolism(gameObject, newStartingEnergy);
        size            = new CreatureSize(sizeSettings, newSize, metabolism, transform);
        sense           = new CreatureSense(senseSettings, newSenseRadius, state, metabolism, transform);
        movement        = new CreatureMovement(velocitySettings, newVelocity, state, metabolism, sense, transform);
        creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, newSize);
    }
Example #8
0
        public void GivenAFactoryWithSomeCreatureTemplates()
        {
            _templates = new List <Creature>
            {
                CreateMockCreature("Goblin"),
                CreateMockCreature("Orc"),
                CreateMockCreature("Bat"),
                CreateMockCreature("Wolf"),
            };

            _randomGenerator = new Mock <IRandomNumberGenerator>();

            _factory = new CreatureFactory(_templates, _randomGenerator.Object);
        }
Example #9
0
 public static void Start(
     Settings settings = null,
     ICreatureFactory creatureFactory     = null,
     IItemFactory itemFactory             = null,
     DefaultTerrainFactory terrainFactory = null
     )
 {
     settings        = settings ?? new Settings();
     creatureFactory = creatureFactory ?? new DefaultCreatureFactory();
     terrainFactory  = terrainFactory ?? new DefaultTerrainFactory();
     itemFactory     = itemFactory ?? new DefaultItemFactory();
     CurrentGame     = new Game(settings, creatureFactory, itemFactory, terrainFactory);
     CurrentGame.Start();
     CurrentGame.Stop();
 }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationContext"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="mapDescriptor">A reference to the map descriptor in use.</param>
        /// <param name="map">A reference to the map in use.</param>
        /// <param name="creatureFinder">A reference to the creature finder in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        /// <param name="creatureFactory">A reference to the creature factory in use.</param>
        /// <param name="containerManager">A reference to the container manager in use.</param>
        /// <param name="gameOperationsApi">A reference to the game operations api.</param>
        /// <param name="combatOperationsApi">A reference to the combat operations api.</param>
        /// <param name="pathFinderAlgo">A reference to the path finding algorithm in use.</param>
        /// <param name="predefinedItemSet">A reference to the predefined item set declared.</param>
        /// <param name="scheduler">A reference to the scheduler instance.</param>
        public OperationContext(
            ILogger logger,
            IMapDescriptor mapDescriptor,
            IMap map,
            ICreatureFinder creatureFinder,
            IItemFactory itemFactory,
            ICreatureFactory creatureFactory,
            IContainerManager containerManager,
            IGameOperationsApi gameOperationsApi,
            ICombatOperationsApi combatOperationsApi,
            IPathFinder pathFinderAlgo,
            IPredefinedItemSet predefinedItemSet,
            IScheduler scheduler)
            : base(logger, () => scheduler.CurrentTime)
        {
            mapDescriptor.ThrowIfNull(nameof(mapDescriptor));
            map.ThrowIfNull(nameof(map));
            creatureFinder.ThrowIfNull(nameof(creatureFinder));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            creatureFactory.ThrowIfNull(nameof(creatureFactory));
            containerManager.ThrowIfNull(nameof(containerManager));
            gameOperationsApi.ThrowIfNull(nameof(gameOperationsApi));
            combatOperationsApi.ThrowIfNull(nameof(combatOperationsApi));
            pathFinderAlgo.ThrowIfNull(nameof(pathFinderAlgo));
            predefinedItemSet.ThrowIfNull(nameof(predefinedItemSet));
            scheduler.ThrowIfNull(nameof(scheduler));

            this.MapDescriptor     = mapDescriptor;
            this.Map               = map;
            this.CreatureFinder    = creatureFinder;
            this.ItemFactory       = itemFactory;
            this.CreatureFactory   = creatureFactory;
            this.ContainerManager  = containerManager;
            this.GameApi           = gameOperationsApi;
            this.CombatApi         = combatOperationsApi;
            this.PathFinder        = pathFinderAlgo;
            this.PredefinedItemSet = predefinedItemSet;
            this.Scheduler         = scheduler;
        }
Example #11
0
 public CreatureFactory(CreatureRequirements requirements)
 {
     _factory      = requirements.Conscious ? (ICreatureFactory) new HumanFactory() : new NonHumanFactory();
     _requirements = requirements;
 }
Example #12
0
 public CreatureController(ICreatureFactory factory)
 {
     _factory = factory;
 }
Example #13
0
 public EnvironmentGeneratorBase(IBuildingFactory buildingFactory, ICreatureFactory creatureFactory, IWeaponFactory weaponFactory)
 {
     _buildingFactory = buildingFactory;
     _creatureFactory = creatureFactory;
     _weaponFactory   = weaponFactory;
 }