Ejemplo n.º 1
0
        // Constructor
        public BatEnemy(World world, EnemyEvent enemyEvent)
            : base(world, enemyEvent)
        {
            // Load resources
            ConfigFile configFile = GetEnemyConfigFile();

            screenWidth               = configFile.SettingGroups[initSettings].Settings["screenWidth"].GetValueAsFloat();
            screenHeight              = configFile.SettingGroups[initSettings].Settings["screenHeight"].GetValueAsFloat();
            flyPercent                = configFile.SettingGroups[initSettings].Settings["flyPercent"].GetValueAsFloat();
            sightForPlayerDistance    = configFile.SettingGroups[initSettings].Settings["sightForPlayerDistance"].GetValueAsFloat();
            sightForWallDistance      = configFile.SettingGroups[initSettings].Settings["sightForWallDistance"].GetValueAsFloat();
            sightForPlayerAngle       = configFile.SettingGroups[initSettings].Settings["sightForPlayerAngle"].GetValueAsFloat();
            sightForPlayerAngleOffset = configFile.SettingGroups[initSettings].Settings["sightForPlayerAngleOffset"].GetValueAsFloat();
            enemySightDelay           = configFile.SettingGroups[initSettings].Settings["enemySightDelay"].GetValueAsFloat();
            turnAroundTimerDelay      = configFile.SettingGroups[initSettings].Settings["turnAroundTimerDelay"].GetValueAsFloat();
            divePixelOffset           = configFile.SettingGroups[initSettings].Settings["divePixelOffset"].GetValueAsFloat();

            this.FacingRight = false;
            this.Behavior    = new EnemyBehavior <BatBehavior>(enemyEvent);
            Vision           = new EnemyVision(sightForPlayerDistance, enemySightDelay);
            Movement         = new EnemyMovement(turnAroundTimerDelay);

            flapTimer      = new Timer();
            flapTimerDelay = 0.25f;
            diveTimer      = new Timer();
            diveTimerDelay = 0.5f;
        }
Ejemplo n.º 2
0
        public static BatEnemyRepresentation CreateBatRepresentation(BatEnemy enemy, EnemyEvent enemyEvent, ContentManager content)
        {
            BatEnemyRepresentation enemyRepresentation = new BatEnemyRepresentation(enemy, enemyEvent);
            enemyRepresentation.LoadContent(content);

            return enemyRepresentation;
        }
Ejemplo n.º 3
0
        public static BatEnemyRepresentation CreateBatRepresentation(BatEnemy enemy, EnemyEvent enemyEvent, ContentManager content)
        {
            BatEnemyRepresentation enemyRepresentation = new BatEnemyRepresentation(enemy, enemyEvent);

            enemyRepresentation.LoadContent(content);

            return(enemyRepresentation);
        }
Ejemplo n.º 4
0
        // constructor
        public EnemyBehavior(EnemyEvent enemyEvent)
        {
            if (!typeof(T).IsEnum)
            {
                throw new ArgumentException("T must be an enumerated type");
            }

            this.enemyEvent = enemyEvent;
        }
Ejemplo n.º 5
0
        private void spawnBatEnemyAt(int x, int y)
        {
            EnemyEvent             enemyEvent          = new EnemyEvent();
            Vector2                tilePosition        = calculateTilePosition(x, y);
            BatEnemy               enemy               = EnemyFactory.CreateBatEntity(world, enemyEvent, tilePosition);
            BatEnemyRepresentation enemyRepresentation = EnemyFactory.CreateBatRepresentation(enemy, enemyEvent, representationManager.Content);
            BatEnemyController     enemyController     = EnemyFactory.CreateBatController(enemy);

            spawnEnemy(enemy, enemyRepresentation, enemyController);
        }
Ejemplo n.º 6
0
        public static WalkerEnemy CreateWalkerEntity(World world, EnemyEvent enemyEvent, Vector2 enemyPosition)
        {
            ConfigFile configFile = Enemy.GetEnemyConfigFile();
            int health = configFile.SettingGroups[walkerGeneralSettings].Settings["health"].GetValueAsInt();
            float hitDelay = configFile.SettingGroups[walkerGeneralSettings].Settings["hitDelay"].GetValueAsFloat();
            float recoveryDelay = configFile.SettingGroups[walkerGeneralSettings].Settings["recoveryDelay"].GetValueAsFloat();

            WalkerEnemy enemy = new WalkerEnemy(world, enemyEvent);
            enemy.SetUpEnemy(enemyPosition, health, hitDelay, recoveryDelay);

            return enemy;
        }
Ejemplo n.º 7
0
        public static BatEnemy CreateBatEntity(World world, EnemyEvent enemyEvent, Vector2 enemyPosition)
        {
            ConfigFile configFile    = Enemy.GetEnemyConfigFile();
            int        health        = configFile.SettingGroups[batGeneralSettings].Settings["health"].GetValueAsInt();
            float      hitDelay      = configFile.SettingGroups[batGeneralSettings].Settings["hitDelay"].GetValueAsFloat();
            float      recoveryDelay = configFile.SettingGroups[batGeneralSettings].Settings["recoveryDelay"].GetValueAsFloat();

            BatEnemy enemy = new BatEnemy(world, enemyEvent);

            enemy.SetUpEnemy(enemyPosition, health, hitDelay, recoveryDelay);

            return(enemy);
        }
Ejemplo n.º 8
0
        // Constructor
        public WalkerEnemy(World world, EnemyEvent enemyEvent) 
            : base(world, enemyEvent)
        {
            // Load resources
            ConfigFile configFile = GetEnemyConfigFile();
            screenWidth = configFile.SettingGroups[initSettings].Settings["screenWidth"].GetValueAsFloat();
            screenHeight = configFile.SettingGroups[initSettings].Settings["screenHeight"].GetValueAsFloat();
            walkPercent = configFile.SettingGroups[initSettings].Settings["walkPercent"].GetValueAsFloat();
            sightForPlayerDistance = configFile.SettingGroups[initSettings].Settings["sightForPlayerDistance"].GetValueAsFloat();
            sightForGroundDistance = configFile.SettingGroups[initSettings].Settings["sightForGroundDistance"].GetValueAsFloat();
            enemySightDelay = configFile.SettingGroups[initSettings].Settings["enemySightDelay"].GetValueAsFloat();
            turnAroundTimerDelay = configFile.SettingGroups[initSettings].Settings["turnAroundTimerDelay"].GetValueAsFloat();

            this.FacingRight = false;
            this.Behavior = new EnemyBehavior<WalkerBehavior>(enemyEvent);
            Vision = new EnemyVision(sightForPlayerDistance, enemySightDelay);
            Movement = new EnemyMovement(turnAroundTimerDelay);
        }
Ejemplo n.º 9
0
 // Constructor
 public BatEnemyRepresentation(BatEnemy enemy, EnemyEvent enemyEvent)
     : base(enemy, enemyEvent)
 {
 }
Ejemplo n.º 10
0
 private void spawnWalkerEnemyAt(int x, int y)
 {
     EnemyEvent enemyEvent = new EnemyEvent();
     Vector2 tilePosition = calculateTilePosition(x, y);
     WalkerEnemy enemy = EnemyFactory.CreateWalkerEntity(world, enemyEvent, tilePosition);
     WalkerEnemyRepresentation enemyRepresentation = EnemyFactory.CreateWalkerRepresentation(enemy, enemyEvent, representationManager.Content);
     WalkerEnemyController enemyController = EnemyFactory.CreateWalkerController(enemy);
     spawnEnemy(enemy, enemyRepresentation, enemyController);
 }
Ejemplo n.º 11
0
 // Constructor
 public WalkerEnemyRepresentation(WalkerEnemy enemy, EnemyEvent enemyEvent)
     : base(enemy, enemyEvent)
 {
 }
Ejemplo n.º 12
0
        public static WalkerEnemyRepresentation CreateWalkerRepresentation(WalkerEnemy enemy, EnemyEvent enemyEvent, ContentManager content)
        {
            WalkerEnemyRepresentation enemyRepresentation = new WalkerEnemyRepresentation(enemy, enemyEvent);
            enemyRepresentation.LoadContent(content);

            return enemyRepresentation;
        }
Ejemplo n.º 13
0
        public static WalkerEnemyRepresentation CreateWalkerRepresentation(WalkerEnemy enemy, EnemyEvent enemyEvent, ContentManager content)
        {
            WalkerEnemyRepresentation enemyRepresentation = new WalkerEnemyRepresentation(enemy, enemyEvent);

            enemyRepresentation.LoadContent(content);

            return(enemyRepresentation);
        }