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

            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);
            RigidBody.IsGravityAffected = true;
        }
Exemple #2
0
        public WeaponsGUI(Vector2 position, int width = 0, int height = 0) : base(position, "weapons_GUI_frame", DrawManager.Layer.GUI, width, height)
        {
            sprite.pivot  = Vector2.Zero;
            sprite.Camera = CameraManager.GetCamera("GUI");
            weapons       = new BulletGUIitem[(int)BulletManager.BulletType.Rocket + 1];

            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.GetTexture("weapon_GUI_selection");
            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
 public GameObject(Vector2 spritePosition, string textureName, DrawManager.Layer drawLayer = DrawManager.Layer.Playground, int spriteWidth = 0, int spriteHeight = 0)
 {
     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 #4
0
        public Font(string textureName, string texturePath, int numColumns, int firstCharASCIIvalue, int charWidth, int charHeight)
        {
            TextureName = textureName;
            numCol      = numColumns;
            firstVal    = firstCharASCIIvalue;
            charW       = charWidth;
            charH       = charHeight;

            GfxManager.AddTexture(textureName, texturePath);
            Texture = GfxManager.GetTexture(textureName);
        }