public void Initialize() { myClouds = new List <CloudElement>(); GenerateInitialClouds(myContent); myOcean = new StaticElement(1.0f, new Vector2(0, mySurfaceLevel)); myBoat = new PlayerElement(1.0f, 0.01f, 0.0f, 1.5f, new Vector2(0, mySurfaceLevel), myGraphics, myConfig.Sinkbombs, myConfig.Level, myConfig.MovementDifficulty, myConfig.WeaponDifficulty); myBoat.AccessSinkBombReleased += SinkBombReleased; //myBoat.BulletFired += BulletFired; //Not used in these levels mySubs = new List <EnemyElement>(); myCreatures = new List <SeaCreatureElement>(); myMines = new List <MineElement>(); mySinkBombs = new List <SinkBombElement>(); myBooms = new List <StaticElement>(); mySoundEffects = new List <SoundEffect>(); //Level1 = three subs at the time, each having one mine for (int i = 0; i < myConfig.Subs; i++) { EnemyElement mySub = new EnemyElement(mySurfaceLevel, 0.6f, 0.0f, 0.0f, 1.0f, new Vector2(0, 0), myGraphics, myConfig.Mines, myConfig.MovementDifficulty, myConfig.WeaponDifficulty); mySub.AccessMineReleased += MineReleased; myBoat.AccessWhereIsTheBoat += mySub.BoatIsFoundAt; mySubs.Add(mySub); } for (int i = 0; i < 3; i++) { SeaCreatureElement myCreature = new SeaCreatureElement(mySurfaceLevel, 0.6f, 0.0f, 0.0f, 1.0f, new Vector2(0, 0), myGraphics); myCreatures.Add(myCreature); } int tempStaticTextTop = myGraphics.PreferredBackBufferHeight - 190; myStatusPanelLeft = new ScoreAndLevelBanner(new Vector2(20, tempStaticTextTop), new Vector2(300, 80), myGraphics); myStatusPanelCenter = new ScoreAndLevelBanner(new Vector2((myGraphics.PreferredBackBufferWidth / 2) - 160, tempStaticTextTop), new Vector2(300, 80), myGraphics); myStatusPanelRight = new ScoreAndLevelBanner(new Vector2(myGraphics.PreferredBackBufferWidth - 320, tempStaticTextTop), new Vector2(300, 80), myGraphics); }
public static StaticElement GetBox(int width, int height, int startRow, int startColumn) { string[] stringBox = GetStringBox(width, height); var box = new StaticElement(stringBox, startRow, startColumn); return(box); }
public StaticElement GenerateMyBoom(ContentManager myContent, float aScale, Vector2 aPosition, int aTimeToLive) { StaticElement boom = new StaticElement(aScale, aPosition, aTimeToLive); boom.LoadContent(myContent, "Elements/Boom"); return(boom); }
public static void PrintLevel(LevelModel level) { string[] levelPrintable = Composer.Compose(level.Matrix); var levelState = new StaticElement(levelPrintable); levelState.Print(); }
public static string[] SaveStaticElementDataData(StaticElement StaticElementScript) { return(new string[] { StaticElementScript.GetType().AssemblyQualifiedName, StaticElementScript.gameObject.activeInHierarchy.ToString() }); }
private void GenerateInitialIceberg(ContentManager myContent) { myIceberg = new StaticElement(1.0f, new Vector2(0, 0)); myIceberg.LoadContent(myContent, "Elements/Iceberg"); int minX = ((myGraphics.PreferredBackBufferWidth / myIceberg.AccessSize.Width) - 2) * myIceberg.AccessSize.Width; int maxX = myGraphics.PreferredBackBufferWidth - myIceberg.AccessSize.Width; int icebergX = RandomNumber.Between(minX, maxX); int icebergY = 130; myIceberg.AccessPosition = new Vector2(icebergX, icebergY); }
public Menu( int width, int height, int row = 0, int column = 0, ConsoleColor colorForeground = ConsoleColor.White, ConsoleColor colorBackground = ConsoleColor.Black, ConsoleColor colorFrame = ConsoleColor.Green, ConsoleColor colorSelectedForeground = ConsoleColor.Black, ConsoleColor colorSelectedBackground = ConsoleColor.Yellow ) { var frame = Composer.GetStringBox(width, height); ColorForeground = colorForeground; ColorBackground = colorBackground; ColorSelectedForeground = colorSelectedForeground; ColorSelectedBackground = colorSelectedBackground; ColorFrame = colorFrame; _menuFrame = new StaticElement(frame, ColorFrame, row, column); IsShown = false; }
bool AcceptBeforeDeliver(TrashObj[] toDeliver) { Element[] trashToPrint = new Element[toDeliver.Length * 3 + 3]; Book currBook; string str; for (int i = 0; i < toDeliver.Length; ++i) { if (toDeliver[i].stored is Book) { currBook = toDeliver[i].stored as Book; str = Validator.ValidStr(currBook.shortTitle, 16) + " | "; str += Validator.ValidStr(currBook.autherName, 16) + " | "; str += Validator.ValidStr(currBook.price.ToString(), 7); trashToPrint[i * 3] = new StaticElement(str, new Coord(5, (short)(i + 5))); trashToPrint[i * 3 + 1] = new StaticElement(toDeliver[i].cnt.ToString(), new Coord(53, (short)(i + 5))); if (toDeliver[i].cnt == 0) { trashToPrint[i * 3 + 2] = new StaticElement("not in stock", new Coord(62, (short)(i + 5))); } else { trashToPrint[i * 3 + 2] = new StaticElement("", new Coord(62, (short)(i + 5))); } } } str = Validator.ValidStr("Title", 16) + " | "; str += Validator.ValidStr("Auther name", 16) + " | "; str += Validator.ValidStr("Price", 7) + " | "; str += Validator.ValidStr("Cnt", 5) + " | "; trashToPrint[toDeliver.Length * 3] = new StaticElement(str, new Coord(5, 4)); if (toDeliver.Length != 0) { string buyBtn = "_____\n|Buy|\n-----"; trashToPrint[toDeliver.Length * 3 + 1] = new ActiveStaticElement(buyBtn, new Coord((short)(str.Length / 2 - buyBtn.Length / 2 - 10), (short)(toDeliver.Length + 6))); buyBtn = "________\n|Cancel|\n--------"; trashToPrint[toDeliver.Length * 3 + 2] = new ActiveStaticElement(buyBtn, new Coord((short)(str.Length / 2 - buyBtn.Length / 2 + 10), (short)(toDeliver.Length + 6))); } else { trashToPrint[toDeliver.Length * 3 + 1] = trashToPrint[toDeliver.Length * 3 + 2] = null; } byte choose; ActiveElementDraw trashWindow = new ActiveElementDraw(head, trashToPrint); trashWindow.InitStatic(); while (true) { trashWindow.Print(); choose = trashWindow.Input(InbisibleInput()); choose -= 13; if (choose == 255) { continue; } if (choose == toDeliver.Length * 3 + 1) { trashWindow.ClearScreen(); return(true); } if (choose == toDeliver.Length * 3 + 2) { trashWindow.ClearScreen(); return(false); } } }
public void Update(GameTime aGameTime) { foreach (CloudElement sky in myClouds) { sky.Update(aGameTime); } foreach (EnemyElement sub in mySubs) { //Sub update will call its mines update sub.Update(aGameTime); } // Always update all sea creatures foreach (SeaCreatureElement creature in myCreatures) { creature.Update(aGameTime); } // Always update boat if (myIceberg == null) { myBoat.Update(Convert.ToInt32(myGraphics.PreferredBackBufferWidth - 60 - myBoat.AccessSize.Width * myBoat.AccessScale), aGameTime); } else { myBoat.Update(Convert.ToInt32(myIceberg.AccessPosition.X - 60 - myBoat.AccessSize.Width * myBoat.AccessScale), aGameTime); } // Check if helicopter is not active and if so, check if we need to activate it because boat if without sinkbombs if (myHelicopter.AccessActive == false && myBoat.AccessSinkBombsLeft == 0) { myHelicopter.SetActive(); } if (myHelicopter.AccessActive) { if (myHelicopter.AccessHovering && myBoat.MyHitBox.Intersects(myHelicopter.MyHitBox) && myHelicopter.AccessLoadedWeapons == false) { myBoat.ReloadMines(); myBoatHits = 0; myHelicopter.AccessLoadedWeapons = true; } myHelicopter.Update(aGameTime); } // Update all mines that are owned by the game (not released mines are owned by each sub) foreach (MineElement mine in myMines.ToList()) { mine.Update(aGameTime); // If a mine is within the hitbox for the boat if (mine.MyHitBox.Intersects(myBoat.MyHitBox)) { mySoundEffects[0].Play(); myBoatHits++; myBooms.Add(GenerateMyBoom(myContent, 1.0f, myBoat.AccessPosition, aGameTime.TotalGameTime.Seconds + 2)); myMines.Remove(mine); // Remove the mine } // Remove mines that have timed out (3 seconds at surface) if (mine.AccessSurfaced && mine.AccessSurfacedTime + 3 <= aGameTime.TotalGameTime.Seconds) { myMines.Remove(mine); } } // Update all sinkbombs that are owned by the game (not released sinkbombs are owned by the boat) foreach (SinkBombElement sinkBomb in mySinkBombs.ToList()) { sinkBomb.Update(aGameTime); foreach (EnemyElement sub in mySubs) { // If sinkbomb is within the hitbox for a sub if (sinkBomb.MyHitBox.Intersects(sub.MyHitBox)) { mySoundEffects[0].Play(); mySubHits++; myBooms.Add(GenerateMyBoom(myContent, 1.0f, sub.AccessPosition, aGameTime.TotalGameTime.Seconds + 2)); sub.ResetSub(); // Remove the sub mySinkBombs.Remove(sinkBomb); // Remove the sinkbomb } } // Remove sinkbombs that are out of view if (sinkBomb.AccessPosition.Y > myGraphics.PreferredBackBufferHeight) { mySinkBombs.Remove(sinkBomb); } } foreach (Bullet bullet in myBullets.ToList()) { bullet.Update(aGameTime); if (myIceberg != null && bullet.MyHitBox.Intersects(myIceberg.MyHitBox)) { mySoundEffects[0].Play(); myBooms.Add(GenerateMyBoom(myContent, 1.0f, myIceberg.AccessPosition, aGameTime.TotalGameTime.Seconds + 2)); myBullets.Remove(bullet); myIceberg = null; } if (bullet.MyHitBox.X > myGraphics.PreferredBackBufferWidth) { myBullets.Remove(bullet); } } // Clean up visual booms that has timed out foreach (StaticElement boom in myBooms.ToList()) { if (aGameTime.TotalGameTime.Seconds > boom.AccessTimeToLive) { myBooms.Remove(boom); } } }