Exemplo n.º 1
0
        public void Init(List<Body> bodys, List<Barrel> barels, int player)
        {
            bodies = bodys; barrels = barels;
            bodyPick = 0;
            gunPick = 0;
            SetBody(0);
            SetGun(0);
            reload = reloading;
            armor = maxArmor;

            if (player == 1) { tankObject.SetRotate(0); }
            if (player == 2) { tankObject.SetRotate(180 * (float)(Math.PI / 180.0f)); }
            tankSprite.SetRotate(-90 * (float)(Math.PI / 180.0f));
            tankSprite.SetPosition(-tankSprite.Width / 2.0f, tankSprite.Height / 2.0f);

            turretSprite.SetRotate(-90 * (float)(Math.PI / 180.0f));
            turretSprite.SetPosition(-10, turretSprite.Width / 2.0f);

            tankObject.AddChild(tankSprite);
            tankObject.AddChild(turretObject);
            turretObject.AddChild(turretSprite);
            turretObject.AddChild(turretSprite);

            tankObject.AddChild(tankTL);
            tankObject.AddChild(tankTR);
            tankObject.AddChild(tankBL);
            tankObject.AddChild(tankBR);
            tankTL.SetPosition(-tankSprite.Height / 2, -tankSprite.Width / 2);
            tankTR.SetPosition(tankSprite.Height / 2, -tankSprite.Width / 2);
            tankBR.SetPosition(tankSprite.Height / 2, tankSprite.Width / 2);
            tankBL.SetPosition(-tankSprite.Height / 2, tankSprite.Width / 2);

            tankObject.myPoints.Add(tankTL.position);
            tankObject.myPoints.Add(tankTR.position);
            tankObject.myPoints.Add(tankBR.position);
            tankObject.myPoints.Add(tankBL.position);

            turretSprite.AddChild(shotFX);
            shotSprite.Load("Resources/shotLarge.png");
            shotFX.AddChild(shotSprite);
            shotFX.SetPosition(turretSprite.Width / 2.0f, turretSprite.Height);
            shotSprite.SetPosition(-(shotSprite.Width / 2.0f), 0);
        }
Exemplo n.º 2
0
        public void Init()
        {
            stopwatch.Start();
            lastTime = stopwatch.ElapsedMilliseconds;

            InitAudioDevice();
            snd_drive  = LoadSound("Resources/Sound/drive.ogg");
            snd_rotate = LoadSound("Resources/Sound/rotate.ogg");
            snd_fire   = LoadSound("Resources/Sound/fire.ogg");
            snd_load   = LoadSound("Resources/Sound/reload.ogg");


            for (int p = 0; p < 9; p++)
            {
                float b = (obsPositions.Length / 2);
                float c = p - b;
                obsPositions[p] = new Vector3((GetScreenWidth() / 2) + (p * 64) - (b * 64), (GetScreenHeight() / 2) + (((float)Math.Pow(c, 3)) + (9 * c)), 0);
            }

            Texture2D body1     = LoadTexture("Resources/tankBody_blue_outline.png");
            Texture2D body1a    = LoadTexture("Resources/tankBody_red_outline.png");
            Texture2D body2     = LoadTexture("Resources/tankBody_darkLarge_outline.png");
            Texture2D body3     = LoadTexture("Resources/tankBody_huge_outline.png");
            Texture2D bodyS     = LoadTexture("Resources/tankBody_dark.png");
            Texture2D barrel1   = LoadTexture("Resources/tankBlue_barrel1_outline.png");
            Texture2D barrel2   = LoadTexture("Resources/tankBlue_barrel2_outline.png");
            Texture2D barrel3   = LoadTexture("Resources/tankBlue_barrel3_outline.png");
            Texture2D s_barrel1 = LoadTexture("Resources/specialBarrel1_outline.png");
            Texture2D s_barrel2 = LoadTexture("Resources/specialBarrel2_outline.png");
            Texture2D s_barrel3 = LoadTexture("Resources/specialBarrel3_outline.png");
            Texture2D s_barrel4 = LoadTexture("Resources/specialBarrel4_outline.png");
            Texture2D s_barrel5 = LoadTexture("Resources/specialBarrel5_outline.png");
            Texture2D s_barrel6 = LoadTexture("Resources/specialBarrel6_outline.png");
            Texture2D s_barrel7 = LoadTexture("Resources/specialBarrel7_outline.png");
            Texture2D rocketL   = LoadTexture("Resources/barrelGrey_side.png");
            Texture2D bullet1   = LoadTexture("Resources/bulletDark1_outline.png");
            Texture2D bullet2   = LoadTexture("Resources/bulletDark2_outline.png");
            Texture2D bullet3   = LoadTexture("Resources/bulletDark3_outline.png");
            Texture2D bulletM   = LoadTexture("Resources/bulletDark1.png");
            Texture2D rocket1   = LoadTexture("Resources/spaceMissiles_003.png");
            Texture2D rocket2   = LoadTexture("Resources/spaceMissiles_006.png");
            Texture2D obs1      = LoadTexture("Resources/barricadeWood.png");
            Texture2D obs2      = LoadTexture("Resources/sandbagBeige.png");

            Body bodyBasic = new Body(body1, 100f, 1f, 100f, 0f);

            bodyBasic.Rename("Cruiser tank");
            Body bodyBasic2 = new Body(body1a, 100f, 1f, 100f, 0f);

            bodyBasic2.Rename("Cruiser tank");
            Body bodyBig = new Body(body2, 75f, 0.8f, 125f, 8f);

            bodyBig.Rename("Infantry tank");
            Body bodyBigger = new Body(body3, 50f, 0.6f, 150f, -32f);

            bodyBigger.Rename("Super-heavy tank");

            //bodies.Add(bodySmall);
            bodies.Add(bodyBasic);
            bodies.Add(bodyBig);
            bodies.Add(bodyBigger);

            bodies2.Add(bodyBasic2);
            bodies2.Add(bodyBig);
            bodies2.Add(bodyBigger);

            Ammo ammoAvg = new Ammo(bullet1, 1f, 600);
            Ammo ammoFst = new Ammo(bullet3, 0.75f, 700);
            Ammo ammoHvy = new Ammo(bullet2, 1.25f, 500);

            Barrel barrelAvg = new Barrel(s_barrel6, bullet1, 1f, 600, 59, 75, -8f, 0);

            barrelAvg.Rename("105mm cannon");
            barrelAvg.Details(snd_load, 45, false, 0.0f);
            Barrel barrelPrc = new Barrel(s_barrel7, bullet3, 0.75f, 700, 58, 60, -8f, 0);

            barrelPrc.Rename("Self-propelled Sabot");
            barrelPrc.Details(snd_load, 45, false, 0.0f);
            Barrel barrelHwz = new Barrel(s_barrel5, bullet2, 1.25f, 500, 59, 90, -8f, 0);

            barrelHwz.Rename("120mm Howitzer");
            barrelHwz.Details(snd_load, 45, false, 0.0f);
            Barrel barrel45g = new Barrel(s_barrel4, bulletM, 0.5f, 900, 28, 30, -16f, -4f); //20mm machine gun

            barrel45g.Rename("45mm gun");
            barrel45g.Details(snd_load, 45, false, 0.0f);
            Barrel barrelMrl = new Barrel(s_barrel1, rocket1, 2f, 850, 28, 120, -16f, 0);

            barrelMrl.Rename("Rocket launcher");
            barrelMrl.Details(snd_load, 45, false, 0.0f);
            Barrel barrelGui = new Barrel(rocketL, rocket1, 2f, 500, 90, 240, -24f, 0);

            barrelGui.Rename("Guided missile");
            barrelGui.Details(snd_load, 45, true, 3.0f);
            Barrel barrelMac = new Barrel(s_barrel4, bulletM, 0.5f, 900, 28, 30, -16f, -4f);

            barrels.Add(barrelAvg);
            barrels.Add(barrelPrc);
            barrels.Add(barrelHwz);
            barrels.Add(barrel45g);
            barrels.Add(barrelGui);

            body   = bodyBasic;
            barrel = barrelAvg;

            expSpr = new Texture2D[5]
            {
                LoadTexture("Resources/explosion1.png"),
                LoadTexture("Resources/explosion2.png"),
                LoadTexture("Resources/explosion3.png"),
                LoadTexture("Resources/explosion4.png"),
                LoadTexture("Resources/explosion5.png"),
            };
            expSprite.Load(expSpr);
            expSprite_.Load(expSpr);

            bulspr.Load("Resources/bulletBlue1_outline.png");
            bulspr.SetRotate(90 * (float)(Math.PI / 180.0f));
            bulspr.SetPosition(90, 0);

            bulspr_.Load("Resources/bulletBlue1_outline.png");
            bulspr_.SetRotate(90 * (float)(Math.PI / 180.0f));
            bulspr_.SetPosition(90, 0);

            explosionFX.AddChild(expSprite);
            explosionFX.ChangeLifetime(10);
            explosionFX_.AddChild(expSprite_);
            explosionFX_.ChangeLifetime(10);

            bullet.explosion  = explosionFX;
            bullet_.explosion = explosionFX_;

            bullet.AddChild(bulspr);
            bullet_.AddChild(bulspr_);

            bullet.myPoints.Add(new Vector3(-16, 16, 0));
            bullet.myPoints.Add(new Vector3(16, 16, 0));
            bullet.myPoints.Add(new Vector3(16, -16, 0));
            bullet.myPoints.Add(new Vector3(-16, -16, 0));
            bullet_.myPoints.Add(new Vector3(-16, 16, 0));
            bullet_.myPoints.Add(new Vector3(16, 16, 0));
            bullet_.myPoints.Add(new Vector3(16, -16, 0));
            bullet_.myPoints.Add(new Vector3(-16, -16, 0));

            p1.Init(bodies, barrels, 1);
            p2.Init(bodies2, barrels, 2);

            //
            for (int p = 0; p < obsPositions.Length; p++)
            {
                float        half  = obsPositions.Length / 2;
                float        third = obsPositions.Length / 3;
                SceneObject  buh   = new SceneObject(obsHealth, false);
                SpriteObject crap  = new SpriteObject(); crap.Load(obs1);
                buh.AddChild(crap);
                //buh.Rotate(pos.z * ((float)(Math.PI / 180.0f)));
                buh.SetPosition(obsPositions[p].x, obsPositions[p].y);
                crap.SetPosition(-crap.Width / 2, -crap.Height / 2);
                buh.myPoints.Add(new Vector3(-obsRad, obsRad, 0));
                buh.myPoints.Add(new Vector3(obsRad, obsRad, 0));
                buh.myPoints.Add(new Vector3(obsRad, -obsRad, 0));
                buh.myPoints.Add(new Vector3(-obsRad, -obsRad, 0));
                obstacles.Add(buh);
                if (p < (int)third - 1 || p > (int)(third * 2) - 1)
                {
                    crap.Load(obs2);
                }
            }
            //
            p1.Place(new Vector2(GetScreenWidth() / 4, GetScreenHeight() / 4 * 3));
            p2.Place(new Vector2(GetScreenWidth() / 4 * 3, GetScreenHeight() / 4));
        }