Exemplo n.º 1
0
        public override void CreateCosmeticChildren(ComponentManager manager)
        {
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32);

            BaseSprite = AddChild(new SimpleSprite(Manager, "Turret", Matrix.Identity, spriteSheet, new Point(2, 7))) as SimpleSprite;
            BaseSprite.OrientationType = SimpleSprite.OrientMode.YAxis;
            TurretSprite = AddChild(new SimpleSprite(Manager, "Turret", Matrix.CreateTranslation(Vector3.Up * 0.25f), spriteSheet, new Point(1, 7))) as SimpleSprite;
            TurretSprite.OrientationType = SimpleSprite.OrientMode.Fixed;
            SetTurretAngle(0.0f);

            BaseSprite.SetFlag(Flag.ShouldSerialize, false);
            TurretSprite.SetFlag(Flag.ShouldSerialize, false);
            AddChild(new Shadow(manager)).SetFlag(Flag.ShouldSerialize, false);

            AddChild(new GenericVoxelListener(Manager, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -1.0f, 0.0f), (changeEvent) =>
            {
                if (changeEvent.Type == VoxelChangeEventType.VoxelTypeChanged && changeEvent.NewVoxelType == 0)
                {
                    Die();
                }
            })).SetFlag(Flag.ShouldSerialize, false);

            Weapon = new Weapon("BowAttack", 5.0f, 1.0f, 5.0f, SoundSource.Create(ContentPaths.Audio.Oscar.sfx_trap_turret_shoot_1, ContentPaths.Audio.Oscar.sfx_trap_turret_shoot_2), ContentPaths.Effects.pierce)
            {
                ProjectileType = "Arrow",
                Mode           = Weapon.AttackMode.Ranged,
                LaunchSpeed    = 15
            };

            TheAttack = new Attack(Weapon);

            Sensor.OnEnemySensed += Sensor_OnEnemySensed;

            base.CreateCosmeticChildren(manager);
        }
        private void _level_OnGenerateTurret(object sender, LevelEvents.GenerateTurret e)
        {
            var turret = new TurretSprite(LoadTexture(TurretTexture), LoadTexture(TurretMG2Texture), SCOLLING_SPEED);

            // position the turret offscreen at the top
            turret.Position = new Vector2(e.XPosition, -100);

            turret.OnTurretShoots  += _turret_OnTurretShoots;
            turret.OnObjectChanged += _onObjectChanged;
            AddGameObject(turret);

            _turretList.Add(turret);
        }
Exemplo n.º 3
0
        public override void LoadContent()
        {
            _turret                 = new TurretSprite(LoadTexture(TurretTexture), LoadTexture(TurretMG2Texture), 0);
            _turret.Position        = new Vector2(605, 200);
            _turret.OnTurretShoots += _turret_OnTurretShoots;
            _turret.Active          = true;
            AddGameObject(_turret);

            _playerSprite = new PlayerSprite(LoadTexture(PlayerFighter));
            // position the player in the middle of the screen, at the bottom, leaving a slight gap at the bottom
            var playerXPos = _viewportWidth / 2 - _playerSprite.Width / 2;
            var playerYPos = _viewportHeight - _playerSprite.Height - 30;

            _playerSprite.Position = new Vector2(playerXPos, playerYPos);
            AddGameObject(_playerSprite);
        }
Exemplo n.º 4
0
        public override void CreateCosmeticChildren(ComponentManager manager)
        {
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32);

            BaseSprite = AddChild(new SimpleSprite(Manager, "Turret", Matrix.Identity, spriteSheet, new Point(2, 7))) as SimpleSprite;
            BaseSprite.OrientationType = SimpleSprite.OrientMode.YAxis;
            TurretSprite = AddChild(new SimpleSprite(Manager, "Turret", Matrix.CreateTranslation(Vector3.Up * 0.25f), spriteSheet, new Point(1, 7))) as SimpleSprite;
            TurretSprite.OrientationType = SimpleSprite.OrientMode.Fixed;
            SetTurretAngle(0.0f);

            BaseSprite.SetFlag(Flag.ShouldSerialize, false);
            TurretSprite.SetFlag(Flag.ShouldSerialize, false);
            AddChild(new Shadow(manager)).SetFlag(Flag.ShouldSerialize, false);

            AddChild(new GenericVoxelListener(Manager, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -1.0f, 0.0f), (changeEvent) =>
            {
                if (changeEvent.Type == VoxelChangeEventType.VoxelTypeChanged && changeEvent.NewVoxelType == 0)
                {
                    Die();
                }
            })).SetFlag(Flag.ShouldSerialize, false);
            base.CreateCosmeticChildren(manager);
        }