private static GunPart GetRandomBody(float cost) { //Determines Projectile speed //Determines Projectile prefab //Determines Recoil (positive) //Determines Damage (positive) //Determines Projectile Size //Determines Projectile Gravity GunPart returnPart = new GunPart(); //Approach zero as cost reaches infinity => 1/x int bodyType = Random.Range(0, 3); returnPart.baseProjectileSpeed = Mathf.Clamp(Random.Range((cost / 100) * 4, (cost / 100) * 8), 2, 128); returnPart.projectile = Resources.Load <GameObject>("BulletPrefab/BaseBullet"); returnPart.baseDamagePerBullet = Random.Range((cost / 100) * 1, (cost / 50) * 2); returnPart.baseRecoil = new Vector3(Random.Range(0, 5 * returnPart.baseDamagePerBullet), Random.Range(0, 5 * returnPart.baseDamagePerBullet), 0); returnPart.baseProjectileGravity = (Random.Range(-5 * returnPart.baseDamagePerBullet, 5 * returnPart.baseDamagePerBullet)); returnPart.baseProjectileSize = Random.Range(1 + (returnPart.baseDamagePerBullet / 200), 2 + (returnPart.baseDamagePerBullet / 200)); returnPart.GenericRandomize(cost); return(returnPart); }
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { parts = parts.OrderBy(x => GunHelper.GetPartType(x).layer).ToList(); List <Texture2D> textures = new List <Texture2D>(); List <Vector2> offsets = new List <Vector2>(); foreach (string key in parts) { try { GunPart partType = GunHelper.GetPartType(key); Texture2D texture = ModContent.GetTexture(partType.useTexture); textures.Add(texture); Vector2 offset = partType.offset; offsets.Add(offset); } catch (Exception e) { Gunplay.instance.Logger.Error("Something failed when getting invTexture in PostDrawInInventory! " + e.Message); } } for (int index = 0; index < textures.Count; index++) { Texture2D texture = textures[index]; Vector2 offset = offsets[index]; spriteBatch.Draw(texture, position + offset, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); } }
Gun GenerateNewGun(float numToSpend) { List <Gun.GunPartType> gunPartTypes = new List <Gun.GunPartType>(); for (int i = 0; i < (int)Gun.GunPartType.COUNT; i++) { gunPartTypes.Add((Gun.GunPartType)i); } Gun.GunPartType[] MyArray = gunPartTypes.ToArray(); System.Random rnd = new System.Random(); Gun.GunPartType[] MyRandomArray = MyArray.OrderBy(x => rnd.Next()).ToArray(); Gun returnGun = gameObject.AddComponent <Gun>(); for (int i = 0; i < (int)Gun.GunPartType.COUNT; i++) { returnGun.gunParts[(int)MyRandomArray[i]] = GunPart.GetRandom(MyRandomArray[i], numToSpend); } return(returnGun); }
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Vector2 position = item.position - Main.screenPosition + new Vector2(item.width / 2, item.height / 2); List <Texture2D> textures = new List <Texture2D>(); List <Vector2> offsets = new List <Vector2>(); parts = parts.OrderBy(x => GunHelper.GetPartType(x).layer).ToList(); foreach (string key in parts) { try { GunPart partType = GunHelper.GetPartType(key); Texture2D tex = ModContent.GetTexture(partType.useTexture); textures.Add(tex); Vector2 offset = partType.offset; offsets.Add(offset); } catch (Exception e) { Gunplay.instance.Logger.Error("Something failed when getting invTexture in PostDrawInWorld! " + e.Message); } } for (int index = 0; index < textures.Count; index++) { Texture2D texture = textures[index]; Vector2 offset = offsets[index] / 2f; spriteBatch.Draw(texture, position + offset, null, lightColor, rotation, texture.Size() * 0.5f, scale, SpriteEffects.None, 0f); } }
void morphRandom(GunPart part) { // Scale randomScale(part); // Rotate randomRotate(part); }
//Next is health, gun parts /** * @pre: N/A. * @post: Gun should be set up for use by player. * @param: None. * @return: None. */ public override void Start() { base.Start(); parts = new GunPart[NUM_PARTS]; if (buildOnStart) { BuildGun(); } }
void randomRotate(GunPart part) { Vector3 newRotate = new Vector3(); newRotate.x = Random.Range(part.rotateMin.x, part.rotateMax.x); newRotate.y = Random.Range(part.rotateMin.y, part.rotateMax.y); newRotate.z = Random.Range(part.rotateMin.z, part.rotateMax.z); rotatePart(part, newRotate); }
void randomScale(GunPart part) { Vector3 newScale = new Vector3(); newScale.x = Random.Range(part.scaleMin.x, part.scaleMax.x); newScale.y = Random.Range(part.scaleMin.y, part.scaleMax.y); newScale.z = Random.Range(part.scaleMin.z, part.scaleMax.z); scalePart(part, newScale); }
private static GunPart GetRandomBodyMod(float cost) { //Determines a specialtychance and specialtytype [usually empty] GunPart returnPart = new GunPart(); returnPart.baseSpecialtyIndex = (Specialty)Random.Range(0, (int)Specialty.COUNT); returnPart.baseSpecialtyChance = Random.Range(1, cost / 250); returnPart.GenericRandomize(cost); return(returnPart); }
private static GunPart GetRandomStock(float cost) { //Determines Recoil (negative) //Determines BaseBulletSpread (negative) GunPart returnPart = new GunPart(); returnPart.baseRecoil = new Vector3(Random.Range(2, 5 * (cost / 100)), Random.Range(2, 5 * (cost / 100))); returnPart.baseBulletSpread = -Random.Range(2, 5 * (cost / 100)); returnPart.GenericRandomize(cost); return(returnPart); }
private static GunPart GetRandomCapacitor(float cost) { //Determines clip/magazine size //Determines Reload Speed GunPart returnPart = new GunPart(); returnPart.baseClipSize = (int)Random.Range(8, 15 * Mathf.Sqrt(cost / 50)); returnPart.baseReloadSpeed = Random.Range(1, 5) * Mathf.Sqrt(returnPart.baseClipSize / (cost / 100)); returnPart.GenericRandomize(cost); return(returnPart); }
private static GunPart GetRandomSightMod(float cost) { //Determines what variables are seen on hud //Determines a specialtychance and specialtytype [usually empty] when scoped GunPart returnPart = new GunPart(); returnPart.baseSpecialtyIndex = (Specialty)Random.Range(0, (int)Specialty.COUNT); returnPart.baseSpecialtyChance = Random.Range(1, cost / 250); returnPart.GenericRandomize(cost); return(returnPart); }
private static GunPart GetRandomSight(float cost) { //Determines zoom type //Determines zoom amount GunPart returnPart = new GunPart(); returnPart.zoomType = (ZoomType)((int)ZoomType.COUNT - Mathf.FloorToInt(Mathf.Sqrt(Random.Range((cost / 350), ((int)ZoomType.COUNT + 1) * ((int)ZoomType.COUNT + 1)) - 1))); returnPart.zoomMultiplier = Random.Range(1f, 2.5f) * (int)returnPart.zoomType; returnPart.GenericRandomize(cost); return(returnPart); }
public GunPart TakeOtherFromInventory(int index) { if (index <= otherParts.Count - 1) { GunPart returnItem = otherParts[index]; otherParts.RemoveAt(index); return(returnItem); } else { GunPart returnItem = otherParts[otherParts.Count - 1]; otherParts.RemoveAt(otherParts.Count - 1); return(returnItem); } }
/** * @pre: None. * @post: Gun's parts should be rolled, ready for stats to be calculated. * @param: None. * @return: Stub for now, should return if build occurs with no issues function returns correctly. */ public override bool BuildGun() { parts = new GunPart[NUM_PARTS]; ammo = Instantiate(RollAmmo(), this.transform); barrel = Instantiate(RollBarrel(), this.transform); caliber = Instantiate(RollCaliber(), this.transform); cyclicModifier = Instantiate(RollCyclicModifier(), this.transform); cyclicModifier.Attach(this); magazine = Instantiate(RollMagazine(), this.transform); sight = Instantiate(RollSight(), this.transform); stock = Instantiate(RollStock(), this.transform); underBarrel = Instantiate(RollUnderBarrel(), this.transform); underBarrel.Attach(this); readyForUse = true; return(true); }
private static GunPart GetRandomBarrel(float cost) { //Determines Bullets per shot //Determines Cost per bullet //Determines ShotsPerSecond //Determines BaseBulletSpread //Determines Recoil (positive) //Determines Damage (negative) GunPart returnPart = new GunPart(); returnPart.baseBulletsPerShot = Random.Range(1, 4); if (returnPart.baseBulletsPerShot == 1) { returnPart.baseBulletsPerShot = (int)Random.Range(1 + (cost / 250), Mathf.Sqrt(cost / 150)); } else if (returnPart.baseBulletsPerShot == 2) { returnPart.baseBulletsPerShot = 1; } else if (returnPart.baseBulletsPerShot == 3) { returnPart.baseBulletsPerShot = (int)Random.Range(4 * cost / 150, 8 * cost / 100); } returnPart.baseShotsPerSecond = Random.Range(1 * (cost / 50), 5 * (cost / 150)) / (returnPart.baseBulletsPerShot); returnPart.baseBulletSpread = Random.Range(0, 5 * (returnPart.baseBulletsPerShot * returnPart.baseShotsPerSecond)); returnPart.baseRecoil = new Vector3(Random.Range(0, 5 * (returnPart.baseBulletsPerShot * returnPart.baseShotsPerSecond)), Random.Range(0, 5 * (returnPart.baseBulletsPerShot * returnPart.baseShotsPerSecond))); returnPart.baseDamagePerBullet = -Random.Range(0, 2 * returnPart.baseBulletsPerShot * returnPart.baseShotsPerSecond); if (returnPart.baseBulletsPerShot == 1) { returnPart.baseDamagePerBullet = -Random.Range(25 * (cost / 100), 50 * (cost / 50)); returnPart.baseShotsPerSecond /= 15; } returnPart.GenericRandomize(cost); return(returnPart); }
public static GunPart GetRandom(Gun.GunPartType _GunPartType, float cost) { GunPart returnPart = null; switch (_GunPartType) { case Gun.GunPartType.BODY: returnPart = GetRandomBody(cost); break; case Gun.GunPartType.BODYMOD: returnPart = GetRandomBodyMod(cost); break; case Gun.GunPartType.BARREL: returnPart = GetRandomBarrel(cost); break; case Gun.GunPartType.BARRELMOD: returnPart = GetRandomBarrelMod(cost); break; case Gun.GunPartType.STOCK: returnPart = GetRandomStock(cost); break; case Gun.GunPartType.SIGHT: returnPart = GetRandomSight(cost); break; case Gun.GunPartType.SIGHTMOD: returnPart = GetRandomSightMod(cost); break; case Gun.GunPartType.CAPACITOR: returnPart = GetRandomCapacitor(cost); break; } returnPart.name = _GunPartType.ToString(); returnPart.GunPartType = _GunPartType; return(returnPart); }
public static string GetPartName(string key) { GunPart partType = GetPartType(key); return(partType.materialName + " " + partType.type); }
public static void AddPart(GunPart partType) { Gunplay.parts.Add(partType.key, partType); }
void rotatePart(GunPart part, Vector3 rotation) { part.transform.Rotate(rotation, Space.Self); part.transform.eulerAngles = snapVectorToInt(part.transform.eulerAngles, part.rotateSnap); }
void scalePart(GunPart part, Vector3 scale) { part.transform.localScale = Vector3.Scale(part.transform.localScale, scale); }
// Start is called before the first frame update void Start() { gunPart = GunPart.GetRandom(500); }
/// <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 }
private void createAbominations(RectangularHull p, int nbrOfHulls, int nbrOfParts) { bool hasEngine = false; // abominations needs movement //random # of hulls RectangularHull[] hulls = new RectangularHull[nbrOfHulls]; RectangularHull oldCarrier = p; for (int i = 0; i < hulls.Length; i++) { int rndCarrier = SRandom.Next(-1, i - 1); hulls[i] = new RectangularHull(); int pos = SRandom.Next(0, 3); int count = 0; while (oldCarrier.TakenPositions[pos] && count < 4) { pos = (pos + 1) % 4; count++; if (count == 4) { count = 0; oldCarrier = FindEmptySlotHull(p, hulls, i); } } oldCarrier.AddPart(hulls[i], pos); if (rndCarrier == -1) { oldCarrier = p; } else { oldCarrier = hulls[rndCarrier]; } } //random # and type of parts Part[] parts = new Part[nbrOfParts]; for (int i = 0; i < parts.Length; i++) { int type = SRandom.Next(0, 3); Part newPart = null; switch (type) { case 0: newPart = new EnginePart(); hasEngine = true; break; case 1: newPart = new GunPart(); break; case 2: newPart = new SprayGunPart(); break; case 3: newPart = new RectangularHull(); break; } int partPos = SRandom.Next(0, 3); int pos = SRandom.Next(-1, hulls.Length - 1); RectangularHull currentHull = null; if (pos == -1) { currentHull = p; } else { currentHull = hulls[pos]; } int count = 0; while (count < 4) { if (currentHull.TakenPositions[partPos]) { partPos = (partPos + 1) % 4; } else { currentHull.AddPart(newPart, partPos); count = 4; } count++; } if (!hasEngine) { count = 0; while (p.TakenPositions[count] && count < 3) { count++; } p.AddPart(new EnginePart(), count); } //random movePattern //attackTimer.maxTime = SRandom.Next(0, 6); int movePattern = SRandom.Next(0, 99); specialMove = SPREAD_OUT; switch (movePattern) { //case 0: // specialMove = PIRATOS; // TurnSpeed = 0.2f * (float)Math.PI; // break; case 1: specialMove = PIRATOSBOSS; TurnSpeed = 0.1f * (float)Math.PI; break; case 3: usingWaitTimer = true; waitTimer.maxTime = SRandom.Next(0, 6); break; } } }
public void AddToInventory(GunPart input) { otherParts.Add(input); FindObjectOfType <AudioManager>().Play("pickup"); input.transform.parent = transform; }
/** * @pre: N/A. * @post: Gun should be set up for use by player. * @param: None. * @return: None. */ public override void Start() { parts = new GunPart[NUM_PARTS]; BuildGun(); CalculateStats(); }
public void AddToInventory(GunPart input) { otherParts.Add(input); input.transform.parent = transform; }