Exemple #1
0
        public GameObject(Vector2 spritePosition, string textureName, DrawManager.Layer drawLayer = DrawManager.Layer.Playground, int spriteWidth = 0, int spriteHeight = 0)
        {
            Tuple <Texture, List <Animation> > ss = GfxManager.GetSpritesheet(textureName);

            texture    = ss.Item1;
            animations = ss.Item2;
            Animation  = animations[0];

            //texture = GfxManager.GetTexture(textureName);
            if (texture == null)
            {
                texture = GfxManager.GetSpritesheet(textureName).Item1;
            }

            sprite = new Sprite(Animation.FrameWidth > 0 ? Animation.FrameWidth : texture.Width, Animation.FrameHeight > 0 ? Animation.FrameHeight : texture.Height);


            //texture = GfxManager.GetTexture(textureName);
            sprite          = new Sprite(spriteWidth > 0 ? spriteWidth : texture.Width, spriteHeight > 0 ? spriteHeight : texture.Height);
            sprite.pivot    = new Vector2(sprite.Width / 2, sprite.Height / 2);
            sprite.position = spritePosition;
            layer           = drawLayer;
            IsActive        = true;
            UpdateManager.AddItem(this);
            DrawManager.AddItem(this);
        }
Exemple #2
0
        public WeaponsGUI(Vector2 position, int width = 0, int height = 0) : base(position, "weaponFrame", DrawManager.Layer.GUI, width, height)
        {
            sprite.pivot  = Vector2.Zero;
            sprite.Camera = CameraManager.GetCamera("GUI");
            weapons       = new BulletGUIitem[(int)BulletManager.BulletType.Minipig];

            float yPos = this.Position.Y + this.Height / 2;

            for (int i = 0; i < weapons.Length; i++)
            {
                weapons[i] = new BulletGUIitem(new Vector2(this.Position.X + 7 + (itemWidth / 2) + i * (itemWidth + 4), yPos), textureNames[i], this, 2, (int)itemWidth, (int)itemWidth);

                if (i == 0)
                {//first standard weapon
                    //weapons[i].NumBullets = 1;
                    weapons[i].IsSelected  = true;
                    weapons[i].IsAvailable = true;
                    weapons[i].IsInfinite  = true;
                }
            }

            //selectionTexture = GfxManager.GetSpritesheet("weaponSelection");
            Tuple <Texture, List <Animation> > aa = GfxManager.GetSpritesheet("weaponSelection");

            selectionTexture = aa.Item1;

            selection        = new Sprite(selectionTexture.Width, selectionTexture.Height);
            selection.pivot  = new Vector2(selection.Width / 2, selection.Height / 2);
            SelectedWeapon   = 0;
            selection.Camera = CameraManager.GetCamera("GUI");
        }
Exemple #3
0
        //AudioSource source002;
        //AudioClip shootMusic;

        public Tank(Vector2 spritePosition, string textureName) : base(spritePosition, textureName, DrawManager.Layer.Playground)
        {
            //tracksTexture = GfxManager.GetTexture("tracks");
            //turretTexture = GfxManager.GetTexture("turret");

            Tuple <Texture, List <Animation> > track = GfxManager.GetSpritesheet("tracks");

            tracksTexture = track.Item1;
            Tuple <Texture, List <Animation> > torretta = GfxManager.GetSpritesheet("turret");

            turretTexture = torretta.Item1;

            tracks = new Sprite(tracksTexture.Width, tracksTexture.Height);
            turret = new Sprite(turretTexture.Width, turretTexture.Height);

            tracks.pivot = new Vector2(tracks.Width / 2, 0);
            turret.pivot = new Vector2(0, turret.Height / 2);

            tracksOffset = new Vector2(-3, sprite.pivot.Y - 4 - tracks.Height / 2);
            turretOffset = new Vector2(-4, -20);

            minAngle = 0;
            maxAngle = -(float)Math.PI;

            turretLength = turretTexture.Width;

            shakeOffset = new Vector2(0, 0);

            float boxH         = sprite.Height + (tracks.Height / 2) - 4;
            float yOff         = (boxH - sprite.Height) / 2;
            float circleRadius = (float)Math.Sqrt(sprite.Width * sprite.Width + boxH * boxH) / 2;

            Circle bCircle = new Circle(new Vector2(0, yOff), null, circleRadius);
            Rect   bBox    = new Rect(new Vector2(0, yOff), null, sprite.Width, boxH);

            RigidBody      = new RigidBody(sprite.position, this, bCircle, bBox);
            RigidBody.Type = (uint)PhysicsManager.ColliderType.Actor;
            RigidBody.SetCollisionMask((uint)PhysicsManager.ColliderType.Tile | (uint)PhysicsManager.ColliderType.Bullet | (uint)PhysicsManager.ColliderType.PowerUp);

            RigidBody.IsGravityAffected = true;

            //source002 = new AudioSource();
            //shootMusic = new AudioClip("Assets/Music/shoot.wav");
        }