Ejemplo n.º 1
0
        public Cannon()
        {
            var bodyMesh = Game.Current.GetMesh("Cannon");

            _LoadColider = new ObbCollider()
            {
                Extents = _LoadColiderExtents,
                Color   = ItemPart.DefaultPartColor,
            };
            Add(_LoadColider as ItemPart);
            Add(new MeshStaticPart(bodyMesh));
            var bodyObb = TgcObb.computeFromAABB(bodyMesh.BoundingBox);
            var bodyE   = bodyObb.Extents;

            bodyObb.Extents = new Vector3(bodyE.X * _BodyObbScaleY, bodyE.Y, bodyE.Z * _BodyObbScaleY);
            Add(new HollowObbCollider(bodyObb, bodyObb.Position - bodyMesh.Position, _MinBorderScale, _MaxBorderScale));
            bodyObb.dispose();

            var baseMesh = Game.Current.GetMesh("CannonBase");
            var baseObb  = TgcObb.computeFromAABB(baseMesh.BoundingBox);
            var baseE    = baseObb.Extents;

            baseObb.Extents   = new Vector3(baseE.X, baseE.Y * _BaseObbScaleY, baseE.Z);
            Add(_Base         = new MeshUnRotatedPart(baseMesh));
            Add(_BaseCollider = new ObbTranslatedUnRotatedCollider(baseObb, _BaseObbTranslation));

            Add(_Smoke = new TranslatedParticlePart()
            {
                Translation = new Vector3(0, 33, -4),
                Sound       = Game.Current.GetSound("Cannon.wav", EffectVolume),
                Animation   = new AnimatedQuad()
                {
                    Texture      = Game.Current.GetParticle("ExplosionGrey.png"),
                    FrameSize    = new Size(146, 146),
                    Size         = new Vector2(25, 25),
                    FirstFrame   = 2,
                    CurrentFrame = 2,
                    FrameRate    = 15,
                    TotalFrames  = 47,
                }
            });
            RotationChanged += Cannon_RotationChanged;
            _ChargeSound     = Game.Current.GetSound("CannonCharge.wav", 0);
        }
Ejemplo n.º 2
0
        public Cannon()
        {
            var bodyMesh = Game.Current.GetMesh("Cannon");
            _LoadColider = new ObbCollider()
            {
                Extents = _LoadColiderExtents,
                Color = ItemPart.DefaultPartColor,
            };
            Add(_LoadColider as ItemPart);
            Add(new MeshStaticPart(bodyMesh));
            var bodyObb = TgcObb.computeFromAABB(bodyMesh.BoundingBox);
            var bodyE = bodyObb.Extents;
            bodyObb.Extents = new Vector3(bodyE.X * _BodyObbScaleY, bodyE.Y, bodyE.Z * _BodyObbScaleY);
            Add(new HollowObbCollider(bodyObb, bodyObb.Position - bodyMesh.Position, _MinBorderScale, _MaxBorderScale));
            bodyObb.dispose();

            var baseMesh = Game.Current.GetMesh("CannonBase");
            var baseObb = TgcObb.computeFromAABB(baseMesh.BoundingBox);
            var baseE = baseObb.Extents;
            baseObb.Extents = new Vector3(baseE.X, baseE.Y * _BaseObbScaleY, baseE.Z);
            Add(_Base = new MeshUnRotatedPart(baseMesh));
            Add(_BaseCollider = new ObbTranslatedUnRotatedCollider(baseObb, _BaseObbTranslation));

            Add(_Smoke = new TranslatedParticlePart()
            {
                Translation = new Vector3(0, 33, -4),
                Sound = Game.Current.GetSound("Cannon.wav", EffectVolume),
                Animation = new AnimatedQuad()
                {
                    Texture = Game.Current.GetParticle("ExplosionGrey.png"),
                    FrameSize = new Size(146, 146),
                    Size = new Vector2(25, 25),
                    FirstFrame = 2,
                    CurrentFrame = 2,
                    FrameRate = 15,
                    TotalFrames = 47,
                }
            });
            RotationChanged += Cannon_RotationChanged;
            _ChargeSound = Game.Current.GetSound("CannonCharge.wav", 0);
        }