コード例 #1
0
ファイル: TurretTrap.cs プロジェクト: sodomon2/dwarfcorp
        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);
        }
コード例 #2
0
ファイル: TurretTrap.cs プロジェクト: Rod995/dwarfcorp
        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);
        }