public PartController(Vector2 position, bool isEvil, IDs id = IDs.DEFAULT)
 {
     IsEvil = isEvil;
     if (id == IDs.DEFAULT)
     {
         id = EntityConstants.TypeToID(GetType());
     }
     Hull         = new RectangularHull(id);
     Hull.Carrier = this;
     Position     = position;
     this.id      = id;
     SetStats(id);
 }
Exemple #2
0
        internal int Carries(RectangularHull part)
        {
            int pos = -1;

            for (int i = 0; i < 4; i++)
            {
                if (parts[i].Part == part)
                {
                    return(i);
                }
            }
            return(pos);
        }
Exemple #3
0
        public ShipItem(Vector2 position, int linkPosition, RectangularHull hull, Part part, IDs id = IDs.DEFAULT) : base(position, id)
        {
            if (!id.Equals(IDs.RECTHULLPART))
            {
                angle = -(float)Math.PI / 2 * linkPosition;

                if (linkPosition % 2 == 0)
                {
                    angle += (float)Math.PI;
                }
            }
            Hull = hull;
            Part = part;
            //Width = Sprite.SpriteRect.Width * SCALEFACTOR;
            //Height = Sprite.SpriteRect.Height * SCALEFACTOR;
            LinkPosition = linkPosition;
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Adding base texture to Sprite

            Texture2D baseTex = new Texture2D(GraphicsDevice, 2, 2);
            Color[]   c       = new Color[4];
            c[0] = Color.White;
            c[1] = Color.White;
            c[2] = Color.White;
            c[3] = Color.White;
            baseTex.SetData(c);
            Texture2DPlus baseTexPlus = new Texture2DPlus(baseTex);
            Sprite.addBaseTexture(baseTexPlus);
            #endregion

            #region Loading fonts

            DrawHelper.DEBUGFONT   = Content.Load <SpriteFont>("fonts/debugfont");
            DrawHelper.SCOREFONT   = Content.Load <SpriteFont>("fonts/ScoreFont");
            DrawHelper.BIGFONT     = Content.Load <SpriteFont>("fonts/BigScoreFont");
            DrawHelper.UPGRADEFONT = Content.Load <SpriteFont>("fonts/currencyFont");
            #endregion

            #region Loading textures

            Texture2DPlus backgroundTex = new Texture2DPlus(Content.Load <Texture2D>("background/Background"));
            Texture2DPlus bluePlanetTex = new Texture2DPlus(Content.Load <Texture2D>("background/BluePlanet"));
            Texture2DPlus smallRedTex   = new Texture2DPlus(Content.Load <Texture2D>("background/LittleRedPlanet"));
            Texture2DPlus bigRedTex     = new Texture2DPlus(Content.Load <Texture2D>("background/RedBigPlanet"));
            Texture2DPlus cursorTex     = new Texture2DPlus(Content.Load <Texture2D>("textures/cursor"));

            Texture2DPlus errorTex             = new Texture2DPlus(Content.Load <Texture2D>("textures/noTexture"));
            Texture2DPlus enemyTex1            = new Texture2DPlus(Content.Load <Texture2D>("textures/enemyShip"), 2);
            Texture2DPlus enemyTex2            = new Texture2DPlus(Content.Load <Texture2D>("textures/enemyShoot"), 2);
            Texture2DPlus enemyTex3            = new Texture2DPlus(Content.Load <Texture2D>("textures/enemySpeed"), 2);
            Texture2DPlus enemyTex4            = new Texture2DPlus(Content.Load <Texture2D>("textures/asteroid"));
            Texture2DPlus shipTex              = new Texture2DPlus(Content.Load <Texture2D>("parts/Hull_3"));
            Texture2DPlus wallTex              = new Texture2DPlus(Content.Load <Texture2D>("textures/wall"));
            Texture2DPlus shotTex              = new Texture2DPlus(Content.Load <Texture2D>("textures/lazor"), 4);
            Texture2DPlus sprayBulletTex       = new Texture2DPlus(Content.Load <Texture2D>("textures/SprayBullet"), 2);
            Texture2DPlus mineBulletTex        = new Texture2DPlus(Content.Load <Texture2D>("textures/mineBullet_1"), 9);
            Texture2DPlus chargingBulletTex    = new Texture2DPlus(Content.Load <Texture2D>("textures/ChargingBullet"), 6);
            Texture2DPlus gravityBulletTex     = new Texture2DPlus(Content.Load <Texture2D>("textures/GravityBullet"), 6);
            Texture2DPlus homingTex            = new Texture2DPlus(Content.Load <Texture2D>("textures/homing"));
            Texture2DPlus healthDropTex        = new Texture2DPlus(Content.Load <Texture2D>("textures/healthPack"), 4);
            Texture2DPlus moneyDropTex         = new Texture2DPlus(Content.Load <Texture2D>("textures/MoneyDrop"), 7);
            Texture2DPlus healthDrop_TIER2_Tex = new Texture2DPlus(Content.Load <Texture2D>("textures/healthDrop_TIER2"), 4);
            Texture2DPlus wrenchTex            = new Texture2DPlus(Content.Load <Texture2D>("textures/wrench"));
            Texture2DPlus explosionDropTex     = new Texture2DPlus(Content.Load <Texture2D>("textures/explosionDrop"), 8);
            Texture2DPlus boltTex              = new Texture2DPlus(Content.Load <Texture2D>("textures/bolt"));
            Texture2DPlus moneyTex             = new Texture2DPlus(Content.Load <Texture2D>("textures/money"));
            Texture2DPlus energyDropTex        = new Texture2DPlus(Content.Load <Texture2D>("textures/energyDrop"), 8);
            Texture2DPlus unitBarBorderTex     = new Texture2DPlus(Content.Load <Texture2D>("textures/unitBarBorder"));
            Texture2DPlus gunTex1              = new Texture2DPlus(Content.Load <Texture2D>("parts/Gun_1"));
            Texture2DPlus mineGunTex           = new Texture2DPlus(Content.Load <Texture2D>("parts/MineGun"));
            Texture2DPlus sprayGunTex          = new Texture2DPlus(Content.Load <Texture2D>("parts/SprayGun"));
            Texture2DPlus chargingGunTex       = new Texture2DPlus(Content.Load <Texture2D>("parts/ChargingGun"));
            Texture2DPlus gravityGunTex        = new Texture2DPlus(Content.Load <Texture2D>("parts/GravityGun"));
            Texture2DPlus engineTex1           = new Texture2DPlus(Content.Load <Texture2D>("parts/Engine_1"));
            Texture2DPlus selectionBoxTex      = new Texture2DPlus(Content.Load <Texture2D>("parts/SelectionBox"));
            Texture2DPlus upgradeBkg           = new Texture2DPlus(Content.Load <Texture2D>("parts/UpgradeBarBkg"));
            Texture2DPlus popupTextBkgTex      = new Texture2DPlus(Content.Load <Texture2D>("textures/PopupTextBkg"));
            Texture2DPlus menuScreenBkg        = new Texture2DPlus(Content.Load <Texture2D>("parts/MenuScreenBkg"));
            Texture2DPlus rotateItemTex        = new Texture2DPlus(Content.Load <Texture2D>("textures/Rotate"));
            Texture2DPlus hammerItemTex        = new Texture2DPlus(Content.Load <Texture2D>("textures/Hammer"));
            Texture2DPlus alertTex             = new Texture2DPlus(Content.Load <Texture2D>("textures/AlertParticle"));
            Texture2DPlus logoTex              = new Texture2DPlus(Content.Load <Texture2D>("textures/logo"));

            //allUpgradeParts.Insert(PartTypes.DETECTORPART, shotTex);
            #endregion

            #region Loading sounds and adding them to list
            SoundHandler.Sounds[(int)IDs.DEFAULT]             = Content.Load <SoundEffect>("sounds/shotSnd");
            SoundHandler.Sounds[(int)IDs.GUNPART]             = Content.Load <SoundEffect>("sounds/shotSnd");
            SoundHandler.Sounds[(int)IDs.GRAVITYBULLET]       = Content.Load <SoundEffect>("sounds/blackholeSnd");
            SoundHandler.Sounds[(int)IDs.MENUCLICK]           = Content.Load <SoundEffect>("sounds/menuclickSnd");
            SoundHandler.Sounds[(int)IDs.CHARGINGGUNPART]     = Content.Load <SoundEffect>("sounds/chargeshotSnd");
            SoundHandler.Sounds[(int)IDs.EXPLOSIONDEATHSOUND] = Content.Load <SoundEffect>("sounds/ExplosionDeath");
            SoundHandler.Sounds[(int)IDs.PLAYERDEATHSOUND]    = Content.Load <SoundEffect>("sounds/player_death");
            SoundHandler.Sounds[(int)IDs.SLOWMOSOUND]         = Content.Load <SoundEffect>("sounds/slomo");
            SoundHandler.Sounds[(int)IDs.REVERSESLOWMOSOUND]  = Content.Load <SoundEffect>("sounds/reverse_slomo");
            SoundHandler.Sounds[(int)IDs.PICKUPSOUND]         = Content.Load <SoundEffect>("sounds/pickup");
            SoundHandler.Songs[(int)IDs.SONG1INTRO]           = Content.Load <SoundEffect>("sounds/OdysseanIntro");
            SoundHandler.Songs[(int)IDs.SONG1]    = Content.Load <SoundEffect>("sounds/Odyssean");
            SoundHandler.Songs[(int)IDs.SONG2]    = Content.Load <SoundEffect>("sounds/Galaxian");
            SoundHandler.Songs[(int)IDs.VICTORY]  = Content.Load <SoundEffect>("sounds/Victorian");
            SoundHandler.Songs[(int)IDs.GAMEOVER] = Content.Load <SoundEffect>("sounds/GameOver");
            //Console.WriteLine(SoundHandler.Songs[(int)IDs.SONG1INTRO].Duration);
            #endregion
            //Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Content\\textures");

            #region Adding sprites to list
            SpriteHandler.Sprites[(int)IDs.DEFAULT] = new Sprite(errorTex);
            //SpriteHandler.Sprites[(int)IDs.DEFAULT_ENEMY] = new Sprite(enemyTex1, 2, 4);
            //SpriteHandler.Sprites[(int)IDs.ENEMYSHOOT] = new Sprite(enemyTex2, 2, 4);
            //SpriteHandler.Sprites[(int)IDs.ENEMYSPEED] = new Sprite(enemyTex3, 2, 4);
            SpriteHandler.Sprites[(int)IDs.ENEMYASTER]       = new Sprite(enemyTex4);
            SpriteHandler.Sprites[(int)IDs.DEFAULT_BULLET]   = new Sprite(shotTex, 4);
            SpriteHandler.Sprites[(int)IDs.CHARGINGBULLET]   = new Sprite(chargingBulletTex, 24);
            SpriteHandler.Sprites[(int)IDs.GRAVITYBULLET]    = new Sprite(gravityBulletTex, 24);
            SpriteHandler.Sprites[(int)IDs.SPRAYBULLET]      = new Sprite(sprayBulletTex, 2);
            SpriteHandler.Sprites[(int)IDs.HOMINGBULLET]     = new Sprite(homingTex);
            SpriteHandler.Sprites[(int)IDs.HEALTHDROP]       = new Sprite(healthDropTex, 6);
            SpriteHandler.Sprites[(int)IDs.HEALTHDROP_TIER2] = new Sprite(healthDrop_TIER2_Tex, 6);
            SpriteHandler.Sprites[(int)IDs.EXPLOSIONDROP]    = new Sprite(explosionDropTex, 6);
            SpriteHandler.Sprites[(int)IDs.ENERGYDROP]       = new Sprite(energyDropTex, 6);
            SpriteHandler.Sprites[(int)IDs.MINEBULLET]       = new Sprite(mineBulletTex, 6);
            SpriteHandler.Sprites[(int)IDs.RECTHULLPART]     = new Sprite(shipTex);
            SpriteHandler.Sprites[(int)IDs.GUNPART]          = new Sprite(gunTex1);
            SpriteHandler.Sprites[(int)IDs.MINEGUNPART]      = new Sprite(mineGunTex);
            SpriteHandler.Sprites[(int)IDs.GRAVITYGUNPART]   = new Sprite(gravityGunTex);
            SpriteHandler.Sprites[(int)IDs.CHARGINGGUNPART]  = new Sprite(chargingGunTex);
            SpriteHandler.Sprites[(int)IDs.SPRAYGUNPART]     = new Sprite(sprayGunTex);
            SpriteHandler.Sprites[(int)IDs.ENGINEPART]       = new Sprite(engineTex1);
            SpriteHandler.Sprites[(int)IDs.DEFAULT_PARTICLE] = new Sprite();
            SpriteHandler.Sprites[(int)IDs.WALL]             = new Sprite(wallTex);
            SpriteHandler.Sprites[(int)IDs.WRENCH]           = new Sprite(wrenchTex);
            SpriteHandler.Sprites[(int)IDs.BOLT]             = new Sprite(boltTex);
            SpriteHandler.Sprites[(int)IDs.EMPTYPART]        = new Sprite(selectionBoxTex);
            SpriteHandler.Sprites[(int)IDs.UPGRADEBAR]       = new Sprite(upgradeBkg);
            SpriteHandler.Sprites[(int)IDs.POPUPTEXTBKG]     = new Sprite(popupTextBkgTex);
            SpriteHandler.Sprites[(int)IDs.MENUSCREENBKG]    = new Sprite(menuScreenBkg);
            SpriteHandler.Sprites[(int)IDs.MONEYDROP]        = new Sprite(moneyDropTex, 6);
            SpriteHandler.Sprites[(int)IDs.MONEY]            = new Sprite(moneyTex);
            SpriteHandler.Sprites[(int)IDs.ROTATEPART]       = new Sprite(rotateItemTex);
            SpriteHandler.Sprites[(int)IDs.HAMMERPART]       = new Sprite(hammerItemTex);
            SpriteHandler.Sprites[(int)IDs.ALERTPARTICLE]    = new Sprite(alertTex);
            SpriteHandler.Sprites[(int)IDs.LOGO]             = new Sprite(logoTex);
            #endregion

            #region Adding partIDs to list
            List <IDs> ids = new List <IDs>();
            for (int i = (int)IDs.DEFAULT_PART + 1; i <= (int)IDs.EMPTYPART; i++)
            {
                ids.Add((IDs)i);
            }
            ids.Add(IDs.ROTATEPART); //!!
            #endregion

            #region Initializing game objects etc.
            background = new Background(new Sprite(backgroundTex), bluePlanetTex, bluePlanetTex, bigRedTex, smallRedTex);
            //Camera.Player = player; //Reintroduce if camera is to be used
            AchievementController achController = new AchievementController();
            SaveHandler.InitializeGame(achController);
            GameMode    gameMode    = new GameMode();
            Projectiles projectiles = new Projectiles();
            GunPart.projectiles = projectiles;

            Player player = new Player(new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), projectiles); //ok, projectiles null before?
            eventOperator = new EventOperator(this, shipTex, gameMode, achController, player, ids);
            RectangularHull rectHull1 = new RectangularHull();
            RectangularHull rectHull2 = new RectangularHull();
            GunPart         gunPart1  = new ChargingGunPart();
            GunPart         gunPart2  = new ChargingGunPart();
            GunPart         gunPart3  = new GunPart(IDs.DEFAULT);
            EnginePart      engine1   = new EnginePart();
            EnginePart      engine2   = new EnginePart();
            EnginePart      engine3   = new EnginePart();
            Drops           drops     = new Drops(WindowSize.Width, WindowSize.Height);
            gameController = new GameController(player, projectiles, drops, gameMode);
            //wall = new Wall(new Vector2(-4000, -4000)); //! wall location
            UnitBar healthBar = new UnitBar(new Vector2(50, 50), new Sprite(unitBarBorderTex), Color.OrangeRed, 5); //! LOL
            UnitBar energyBar = new UnitBar(new Vector2(50, 85), new Sprite(unitBarBorderTex), Color.Gold, player.maxEnergy);
            playerUI = new PlayerUI(healthBar, energyBar, achController);
            Mouse.SetCursor(MouseCursor.FromTexture2D(cursorTex.Texture, cursorTex.Texture.Width / 2, cursorTex.Texture.Height / 2));
            #endregion

            // TODO: use this.Content to load your game content here
        }