コード例 #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;
        }
コード例 #2
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);
        }