Example #1
0
 public Spawner( GameWorld world, Texture2D texture, Vector2 position, float size,
     AlienType type, int cooldown, String texturename = TNames.easy_alien, int max_spawn = DEFAULT_MAX_SPAWN, AlienController.AIType ai = AlienController.AIType.PATROL, float patrol = 0.05f )
     : base(world, texture, position, size, type, ai: ai, patrol_speed: patrol)
 {
     m_texture_name = texturename;
     max_cool = cooldown;
     m_cooldown = cooldown;
     m_alien_color = Color.Red;
     m_max_spawn = max_spawn;
 }
Example #2
0
        // The Alien Constructor
        //
        // <param name="world"> The World this object would be contained inside </param>
        // <param name="texture"> The image that governs the shape of this object</param>
        // <param name="velocity"> The initial velocity from throwing</param>
        // <param name="density"> The object's mass per unit area </param>
        // <param name="friction"> Usually set to 0 for throwable objects, but sliding factor </param>
        // <param name="restitution"> Bounciness </param>
        public Alien( GameWorld world, Texture2D texture, Vector2 position, float size,

            AlienType type, AlienCollisionType collision_type = AlienCollisionType.NORMAL,
            String name = "Alien", String texturename = TNames.easy_alien, AlienController.AIType ai = AlienController.AIType.PEON,

            int attack_rate = 50, float attack_power = 10, int attack_cooldown = 120,
            float laser_slowdown = 0.8f,

            float patrol_speed = ALIEN_PATROL_SPEED, float max_range = TUTORIAL_MAX_RANGE,
            float attack_dist = TUTORIAL_ATTACK_RANGE, float chase_dist = TUTORIAL_MAX_CHASE,

            float destroy_threshold = 30,

            float rotation = 0.0f, float density = ALIEN_DENSITY, float friction = ALIEN_FRICTION,
            float restitution = ALIEN_RESTITUTION, float attack_speed = 1.0f )
            : base(world, texture, position, density, friction,
            restitution, ALIEN_DAMPING, rotation: rotation, name: name,
            is_destructible: true, radius: size)
        {
            m_laser_slowdown = laser_slowdown;
            m_ai_type = ai;
            m_destroy_threshold = destroy_threshold;

            m_move_step = patrol_speed;
            m_range = max_range;
            m_attack_dist = attack_dist;
            m_chase_dist = chase_dist;
            m_attack_speed = attack_speed;

            m_size_scale = (float)Math.Sqrt( size );
            m_laser_texture = TestWorld.laser_texture;
            m_attack_rate = attack_rate;                    // Will likely change
            m_attack_power = attack_power;                    // Will likely change
            m_is_attacking = false;
            m_attack_cooldown = attack_cooldown;
            m_width = ( m_size_scale ) * (float)texture.Width / ( GameWorld.SCALE );
            m_height = ( m_size_scale ) * (float)texture.Height / ( GameWorld.SCALE );

            m_radius = Math.Min( m_width, m_height ) / 2;
            m_size = m_radius;
            m_texture_name = texturename;
            m_width_height = new Vector2( m_width, m_height );
            m_type = type;
            m_collision_type = collision_type;
            m_animation_frame = 1;
            m_last_destroy_frame = false;
            m_ai_control = new AlienController( m_world, this, m_ai_type, m_world.m_ninja
                    , patrol_speed: m_move_step, max_range: m_range,
                    attack_dist: m_attack_dist, chase_dist: m_chase_dist );
            m_alien_color = Color.White;
            set_textures();
        }