/// <summary>Create the level.</summary> /// <param name="levelIndex">The index of the level.</param> public Level(int levelIndex) { // load the backgrounds GameObjectList backgrounds = new GameObjectList(0, "backgrounds"); SpriteGameObject background_main = new SpriteGameObject("Backgrounds/spr_sky"); background_main.Position = new Vector2(0, GameEnvironment.Screen.Y - background_main.Height); backgrounds.Add(background_main); Add(new GameObjectList(1, "waterdrops")); Add(new GameObjectList(2, "enemies")); LoadTiles("Content/Levels/" + levelIndex + ".txt"); // add a few random mountains for (int i = 0; i < 5; i++) { SpriteGameObject mountain = new SpriteGameObject("Backgrounds/spr_mountain_" + (GameEnvironment.Random.Next(2) + 1), 1, "", 0, SpriteGameObject.Backgroundlayer.background); mountain.Position = new Vector2((float)GameEnvironment.Random.NextDouble() * (width * cellWidth) - mountain.Width / 2, (height * cellHeight) - mountain.Height); backgrounds.Add(mountain); } Clouds clouds = new Clouds(2, "", this); backgrounds.Add(clouds); Add(backgrounds); SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100); timerBackground.Position = new Vector2(10, 10); Add(timerBackground); quitButton = new Button("Sprites/spr_button_quit", 100); quitButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 10); Add(quitButton); }
public StatusBar() : base() { clickableObjects = new GameObjectList(); background = new SpriteGameObject("spr_bar"); overHeadArrowsIcon = new ClickableSpriteGameObject("arrow_raining", IconType.OverheadArrowsIcon); rollingBoulderIcon = new ClickableSpriteGameObject("bolder_powerupp", IconType.RollingBoulderIcon); boilingOilIcon = new ClickableSpriteGameObject("spr_keuze_mage", IconType.BoilingOilIcon); moneyCount = new TextGameObject("GameFont"); overHeadArrowsIcon.Position = new Vector2(975, 30); rollingBoulderIcon.Position = new Vector2(1075, 30); boilingOilIcon.Position = new Vector2(1175, 30); moneyCount.Position = new Vector2(800, 30); moneyCount.Text = ""; clickableObjects.Add(overHeadArrowsIcon); clickableObjects.Add(rollingBoulderIcon); clickableObjects.Add(boilingOilIcon); Add(background); Add(overHeadArrowsIcon); Add(rollingBoulderIcon); Add(boilingOilIcon); Add(moneyCount); }
public PainterGameWorld() { background = new SpriteGameObject("spr_background"); scoreBar = new SpriteGameObject("spr_scorebar"); cannon = new Cannon(); canSprites = new GameObjectList(); canSprites.Add(new PaintCan(450f, Color.Red)); canSprites.Add(new PaintCan(575f, Color.Green)); canSprites.Add(new PaintCan(700f, Color.Blue)); scoreText = new TextGameObject("GameFont"); scoreText.Position = new Vector2(5, 7); livesSprites = new GameObjectList(); for(int iLife = 0; iLife < MAX_LIVES; iLife++) { SpriteGameObject life = new SpriteGameObject("spr_lives", 0, iLife.ToString()); life.Position = new Vector2(iLife * life.BoundingBox.Width, scoreBar.Position.Y + scoreBar.BoundingBox.Height + 15); livesSprites.Add(life); } //Add the background sprite to the gameworld Add(background); Add(scoreBar); Add(cannon); Add(canSprites); Add(scoreText); Add(livesSprites); Reset(); }
/// <summary> /// The collision method will be called by objects inside the given list /// </summary> /// <param name="list"></param> public override void checkExternalCollisions(GameObjectList list) { int start = 0; for (int i = 0; i < Count; i++) { for (int j = start; j < list.Count; j++) { IGameObject a = this[i]; IGameObject b = list[j]; GameLibrary.Global.DEBUG.comparisons++; if (a.right < b.left) { break; } if (a.left > b.right) { start++; continue; } if (a.top > b.bottom || a.bottom < b.top) { continue; } a.collisionWith(b); b.collisionWith(a); } } }
public void LoadTiles(string path) { //Haalt de tekst uit tekstfile int width; List<string> textlines = new List<string>(); StreamReader fileReader = new StreamReader(path); string line = fileReader.ReadLine(); width = line.Length; while (line != null) { textlines.Add(line); line = fileReader.ReadLine(); } //Tijdslimiet i wordt afgelezen uit tekstfile int i = int.Parse(textlines[textlines.Count - 1]); SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100, "timerBackground"); timerBackground.Position = new Vector2(10, 10); this.Add(timerBackground); TimerGameObject timer = new TimerGameObject(i, 101, "timer"); timer.Position = new Vector2(25, 30); this.Add(timer); int height = textlines.Count - 2; //Creëert het speelveld TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles"); //Plaatst de hintbutton GameObjectList hintfield = new GameObjectList(100, "hintfield"); this.Add(hintfield); string hint = textlines[textlines.Count - 2]; SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1, "hint_frame"); hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10); hintfield.Add(hint_frame); TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2, "hintText"); hintText.Text = hint; hintText.Position = new Vector2(120, 25); hintText.Color = Color.Black; hintfield.Add(hintText); VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); this.Add(hintTimer); //Vult het speelveld met de goede tiles this.Add(tiles); tiles.CellWidth = 72; tiles.CellHeight = 55; for (int x = 0; x < width; ++x) for (int y = 0; y < textlines.Count - 2; ++y) { Tile t = LoadTile(textlines[y][x], x, y); tiles.Add(t, x, y); } levelwidth = width * tiles.CellWidth; levelheight = height * tiles.CellHeight; }
private void Dt_TableNewRow(object sender, DataTableNewRowEventArgs e) { T p = Activator.CreateInstance <T>(); GameObjectList list = (GameObjectList)GetDataList(scen); int id = list.GetFreeGameObjectID(); e.Row["id"] = id; p.ID = id; list.Add(p); }
/// <summary>Add a water tile.</summary> private Tile LoadWaterTile(int x, int y) { GameObjectList waterdrops = Find("waterdrops") as GameObjectList; TileField tiles = Find("tiles") as TileField; WaterDrop w = new WaterDrop(); w.Origin = w.Center; w.Position = new Vector2((x + 0.5f) * tiles.CellWidth, (y + 0.5f) * tiles.CellHeight - 10); waterdrops.Add(w); return(new Tile()); }
public void LoadTiles(string path) { List <string> textLines = new List <string>(); StreamReader fileReader = new StreamReader(path); string line = fileReader.ReadLine(); int width = line.Length; while (line != null) { textLines.Add(line); line = fileReader.ReadLine(); } TileField tiles = new TileField(textLines.Count - 1, width, 1, "tiles"); int height = textLines.Count - 1; GameObjectList hintField = new GameObjectList(100); Add(hintField); string hint = textLines[textLines.Count - 2]; SpriteGameObject hintFrame = new LockedSpriteGameObject("Overlays/spr_frame_hint", 1); hintField.Position = new Vector2((GameEnvironment.Screen.X - hintFrame.Width) / 2, 10); hintField.Add(hintFrame); TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); hintText.Text = textLines[textLines.Count - 2]; hintText.Position = new Vector2(120, 25); hintText.Color = Color.Black; hintField.Add(hintText); int timerTime = int.Parse(textLines[textLines.Count - 1]); timer.SetTime = timerTime; VisibilityTimer hintTimer = new VisibilityTimer(hintField, 1, "hintTimer"); Add(hintTimer); Add(tiles); tiles.CellWidth = 72; tiles.CellHeight = 55; this.width = width * tiles.CellWidth; this.height = height * tiles.CellHeight; for (int x = 0; x < width; x++) { Tile t = new Tile(); tiles.Add(t, x, 0); } for (int x = 0; x < width; ++x) { for (int y = 1; y < textLines.Count - 1; ++y) { Tile t = LoadTile(textLines[y - 1][x], x, y); tiles.Add(t, x, y); } } }
/// <summary>Update the follower.</summary> public override void Update(GameTime gameTime) { GameObjectList gameWorld = Root as GameObjectList; Player player = gameWorld.Find("player") as Player; float direction = player.Position.X - position.X; if (Math.Sign(direction) != Math.Sign(velocity.X) && player.Velocity.X != 0.0f && velocity.X != 0.0f) { TurnAround(); } base.Update(gameTime); }
private void SetupEnitites() { GameObjectList entities = GetObject("entities") as GameObjectList; foreach (string id in entities.Children) { if (GetObject(id) is Entity) { (GetObject(id) as Entity).SendData(); } } }
private Tile LoadSpeedTile(int x, int y) { GameObjectList waterdrops = Find("waterdrops") as GameObjectList; TileField tiles = Find("tiles") as TileField; SpeedObject s = new SpeedObject(); s.Origin = s.Center; s.Position = new Vector2(x * tiles.CellWidth, y * tiles.CellHeight - 10); s.Position += new Vector2(tiles.CellWidth, tiles.CellHeight) / 2; waterdrops.Add(s); return(new Tile()); }
public void SetLastState(GameTime gameTime, GameObjectList gameObjects) { foreach (var gameObject in gameObjects) { var inputState = gameObject.Components.Get <CInputState>(); foreach (var input in _allInputActions) { inputState.WasPressed[input] = inputState.IsPressed[input]; } } }
public Tile LoadItem(int x, int y) { LevelGrid tiles = GetObject("tiles") as LevelGrid; Item item = new Item(); GameObjectList entities = GetObject("entities") as GameObjectList; GameObjectList items = GetObject("items") as GameObjectList; items.Add(item); item.MovePositionOnGrid(x, y); //return new Tile(new Point(x, y), "Sprites/Tiles/spr_floor_sheet_test_1@4x4", TileType.Floor, TextureType.Grass); return(new Tile(new Point(x, y), "Sprites/Tiles/spr_grass_sheet_0@4x4", TileType.Floor, TextureType.Grass)); }
public void InfoScreen(ItemSlot caller) { this.caller = caller; caller.SlotItem.ItemInfo(caller); GameObjectList infoList = caller.SlotItem.InfoList; int interfall = 2; int height = CalculateInfoTextHeight(infoList, interfall); int width = interfall * 2 + CalculateInfoTextWidth(infoList); infoWindow = new Window(width, height, false, false); infoWindow.Add(infoList); }
public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); if (makePirate) { GameObjectList level = this.parent.Parent as GameObjectList; PirateShip pirate = new PirateShip(position + new Vector2(70, 50), 1010, "pirate"); GameObjectList pirateList = level.Find("pirateList") as GameObjectList; pirateList.Add(pirate); makePirate = false; } }
/// <summary> /// Uses the main ability of the weapon. /// </summary> /// <param name="monsterList">Give the current list of all the monsters currently in the level</param> /// <param name="field">Give the tilefield of the level, important for replacement attacks</param> public virtual void UseMainAbility(GameObjectList monsterList, GameObjectGrid field) { if (!mainAbility.IsOnCooldown) { mainAbility.Use(); idAnimation = idMainAbility; monsterObjectList = monsterList; fieldList = field; //PlayAnimation(idAnimation); AnimationMainCheck(); } }
/// <summary> /// Checks if the monster (if it is currently playing the attack animation) hit a player /// </summary> protected virtual void AnimationCheck() { GameObjectList players = currentLevel.GameWorld.Find("playerLIST") as GameObjectList; foreach (Character player in players.Children) { if (BoundingBox.Intersects(player.BoundingBox)) { AttackHit(player); } } }
private void FrameFunction_Architecture_AfterGetConvinceDestinationPerson() // 说服 { this.CurrentGameObjects = this.CurrentArchitecture.ConvinceDestinationPersonList.GetSelectedList(); if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count == 1)) { foreach (Person person in this.CurrentPersons) { person.GoForConvince(this.CurrentGameObjects[0] as Person); } this.mainGameScreen.PlayNormalSound("GameSound/Tactics/Outside.wav"); } }
private Tile LoadZenyTile(int x, int y) { GameObjectList ZenyS = this.Find("ZenyS") as GameObjectList; TileField tiles = this.Find("tiles") as TileField; Zeny w = new Zeny(); w.Origin = w.Center; w.Position = new Vector2(x * tiles.CellWidth, y * tiles.CellHeight - 10); w.Position += new Vector2(tiles.CellWidth, tiles.CellHeight) / 2; ZenyS.Add(w); return(new Tile()); }
public Boolean removeObjectFromList(clsGameObject Object) { if (GameObjectList.Contains(Object) == true) { GameObjectList.Remove(Object); return(true); } else { return(false); } }
private void FrameFunction_Architecture_AfterGetFriendlyDiplomaticRelation() { GameObjectList selectedList = this.CurrentArchitecture.ResetDiplomaticRelationList.GetSelectedList(); if (selectedList != null) { foreach (DiplomaticRelationDisplay display in selectedList) { display.Relation = 0; } } }
private void FrameFunction_Architecture_AfterGetStudySkillPerson() { this.CurrentGameObjects = this.CurrentArchitecture.PersonStudySkillList.GetSelectedList(); if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count > 0)) { foreach (Person person in this.CurrentGameObjects) { person.GoForStudySkill(); } this.mainGameScreen.PlayNormalSound("GameSound/Tactics/Outside.wav"); } }
/// <summary>returns true if any of the specified objects are within the specified volume. trigger volume must have been postprocessed</summary> public bool volume_test_objects(ITriggerVolume trigger_volume, GameObjectList object_list) { foreach (var o in object_list) { if (trigger_volume.Contains(o)) { return(true); } } return(false); }
private void FrameFunction_Architecture_AfterGetSearchPerson() // 搜索 { this.CurrentGameObjects = this.CurrentArchitecture.Persons.GetSelectedList(); if (this.CurrentGameObjects != null) { foreach (Person person in this.CurrentGameObjects) { person.shoudongjinxingsousuo(); } this.mainGameScreen.PlayNormalSound("GameSound/Tactics/Outside.wav"); } }
private void FrameFunction_Architecture_AfterGetAllyDiplomaticRelation() { GameObjectList selectedList = this.CurrentArchitecture.AllyDiplomaticRelationList.GetSelectedList(); if (selectedList != null && (selectedList.Count == 1)) { this.CurrentDiplomaticRelationDisplay = selectedList[0] as DiplomaticRelationDisplay; //this.CurrentDiplomaticRelationDisplay.Relation = 301; //this.mainGameScreen.xianshishijiantupian(this.CurrentArchitecture.BelongedFaction.Leader, this.CurrentArchitecture.BelongedFaction.Leader.Name, "AllyDiplomaticRelation", "AllyDiplomaticRelation.jpg", "AllyDiplomaticRelation.wav", this.CurrentDiplomaticRelationDisplay.FactionName, true); this.mainGameScreen.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Person, FrameFunction.GetAllyDiplomaticRelationPerson, true, true, true, true, this.CurrentArchitecture.Persons, null, "外交人员", "Ability"); } }
private void FrameFunction_Architecture_AfterGetRecruitmentPerson() // 补充 { if (this.CurrentArchitecture != null) { this.CurrentGameObjects = this.CurrentArchitecture.Persons.GetSelectedList(); if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count == 1)) { this.CurrentPerson = this.CurrentGameObjects[0] as Person; this.CurrentPerson.RecruitMilitary(this.CurrentMilitary); } } }
private void FrameFunction_Architecture_AfterGetStudyTitlePerson() // 修习称号 { this.CurrentGameObjects = this.CurrentArchitecture.PersonStudyTitleList.GetSelectedList(); if ((this.CurrentGameObjects != null) && (this.CurrentGameObjects.Count == 1)) { Person person = this.CurrentGameObjects[0] as Person; if (person != null) { this.CurrentPerson = person; this.mainGameScreen.ShowTabListInFrame(UndoneWorkKind.Frame, FrameKind.Title, FrameFunction.GetStudyTitle, false, true, true, false, person.GetStudyTitleList(), null, "研习", ""); } } }
public GameObjectList GetSectionNoOrientationAutoAIDetailsByConditions(bool allowOffensiveCampaign, bool valueRecruitment) { GameObjectList list = new GameObjectList(); foreach (SectionAIDetail detail in this.SectionAIDetails.Values) { if ((((detail.OrientationKind == SectionOrientationKind.无) && detail.AutoRun) && (detail.AllowOffensiveCampaign == allowOffensiveCampaign)) && (detail.ValueRecruitment == valueRecruitment)) { list.Add(detail); } } return(list); }
internal void RefreshEditable() { this.ResetEditableTextures(); base.OKButtonEnabled = this.gameObjectList.HasSelectedItem(); if (this.MultiSelecting) { this.SelectedItemList = this.gameObjectList.GetSelectedList(); } else if (base.OKButtonEnabled) { this.SelectedItem = this.gameObjectList.GetSelectedList()[0]; } }
public void Set(VirtualCell.CellType k, GameObjectList v) { if (hidden_dict == null) { RebuildHiddenDictionary(); } hidden_dict[k] = v; keys.Add(k); GameObjectListContainer v_container = new GameObjectListContainer(); v_container._inner_list = v; values.Add(v_container); }
private void FrameFunction_Architecture_AfterGetFriendlyDiplomaticRelation() { GameObjectList selectedList = this.CurrentArchitecture.ResetDiplomaticRelationList.GetSelectedList(); if (selectedList != null) { foreach (DiplomaticRelationDisplay display in selectedList) { this.mainGameScreen.xianshishijiantupian(this.CurrentArchitecture.Scenario.NeutralPerson, this.CurrentArchitecture.BelongedFaction.Leader.Name, "ResetDiplomaticRelation", "ResetDiplomaticRelation.jpg", "ResetDiplomaticRelation.wav", display.FactionName, true); display.Relation = 0; } } }
public GameObjectList GetDiplomaticRelationListByFactionName(string factionName) { GameObjectList list = new GameObjectList(); foreach (DiplomaticRelation relation in this.DiplomaticRelations.Values) { if ((relation.RelationFaction1String == factionName) || (relation.RelationFaction2String == factionName)) { list.Add(relation); } } return(list); }
public override int GetHashCode() { int hash = 1; hash ^= GameObjectList.GetHashCode(); hash ^= tasks_.GetHashCode(); hash ^= Scores.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public GameObjectList GetDiplomaticRelationListByFactionID(int factionID) { GameObjectList list = new GameObjectList(); foreach (DiplomaticRelation relation in this.DiplomaticRelations.Values) { if ((relation.RelationFaction1ID == factionID) || (relation.RelationFaction2ID == factionID)) { list.Add(relation); } } return(list); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); // store a static reference to the ContentManager ContentManager = Content; // create an empty game world gameWorld = new GameObjectList(); // by default, we're not running in full-screen mode FullScreen = false; }
/// <summary>Load the level.</summary> public void LoadTiles(string path) { this.path = path; List<string> textlines = new List<string>(); StreamReader fileReader = new StreamReader(path); string line = fileReader.ReadLine(); // first row of the level width = line.Length; // calculated level width while (line != null) { // read all lines textlines.Add(line); line = fileReader.ReadLine(); } height = textlines.Count - 2; // add the hint GameObjectList hintfield = new GameObjectList(100); Add(hintfield); SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); // hint background hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10); hintfield.Add(hint_frame); TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); // hint text hintText.Text = textlines[textlines.Count - 2]; // last line in the level descriptor hintText.Position = new Vector2(120, 25); hintText.Color = Color.Black; hintfield.Add(hintText); VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); // timeout Add(hintTimer); TimerGameObject timer = new TimerGameObject(101, "timer"); timer.Position = new Vector2(25, 30); timer.TimeLeft = TimeSpan.FromSeconds(double.Parse(textlines[textlines.Count - 1])); Add(timer); // construct the level TileField tiles = new TileField(height, width, 1, "tiles"); Add(tiles); // tile dimentions tiles.CellWidth = 72; cellWidth = 72; tiles.CellHeight = 55; cellHeight = 55; for (int x = 0; x < width; ++x) for (int y = 0; y < height; ++y) { Tile t = LoadTile(textlines[y][x], x, y); tiles.Add(t, x, y); } }
public GameWorld() { //soundeffecten inladen InsaneKillerArcher.AssetManager.PlayMusic("background_music"); //laat bovenaan staan, is aleen de achtergrond. Add(new SpriteGameObject("background")); statusBar = new StatusBar(); Add(statusBar); castle = new Castle(); groundList = new GameObjectList(); for (int i = 0; i < InsaneKillerArcher.Screen.X/32; i++) { ground = new SpriteGameObject("gras"); ground.Position = new Vector2(i * ground.Width, InsaneKillerArcher.Screen.Y - ground.Height); groundList.Add(ground); } player = new Player(); player.Position = new Vector2(50, InsaneKillerArcher.Screen.Y - castle.mainCastle.Height - player.Body.Height + 35); catapultBoulders = new GameObjectList(); archers = new GameObjectList(); catapults = new GameObjectList(); Add(archers); Add(catapults); enemySpawner = new EnemySpawner(2, 5); arrows = new GameObjectList(); archerArrows = new GameObjectList(); animatedProjectiles = new GameObjectList(); Add(castle); Add(enemySpawner); Add(player); Add(catapultBoulders); Add(arrows); Add(archerArrows); Add(animatedProjectiles); Add(groundList); }
public AudioEngine(ContentManager content, GameObjectList tempObjType) { objType = tempObjType; switch (objType) { case GameObjectList.Player: jump1 = content.Load<SoundEffect>("Sounds/hup1"); jump2 = content.Load<SoundEffect>("Sounds/hup2"); jump3 = content.Load<SoundEffect>("Sounds/hup3"); dash = content.Load<SoundEffect>("Sounds/woosh"); break; default: break; } }
public void LoadTiles(string path) { int width; List<string> textlines = new List<string>(); StreamReader fileReader = new StreamReader(path); string line = fileReader.ReadLine(); width = line.Length; while (line != null) { textlines.Add(line); line = fileReader.ReadLine(); } TileField tiles = new TileField(textlines.Count - 2, width, 1, "tiles"); GameObjectList hintfield = new GameObjectList(100); this.Add(hintfield); string hint = textlines[textlines.Count - 1]; SpriteGameObject hint_frame = new SpriteGameObject("Overlays/spr_frame_hint", 1); hintfield.Position = new Vector2((GameEnvironment.Screen.X - hint_frame.Width) / 2, 10); hint_frame.Meebewegen(); hintfield.Add(hint_frame); TextGameObject hintText = new TextGameObject("Fonts/HintFont", 2); hintText.Text = textlines[textlines.Count - 2]; hintText.Position = new Vector2(120, 25); hintText.Color = Color.Black; hintfield.Add(hintText); VisibilityTimer hintTimer = new VisibilityTimer(hintfield, 1, "hintTimer"); this.Add(hintTimer); GameObject.lvltimer = Convert.ToDouble(textlines[textlines.Count - 1]); // de laatste lijn in de textfile heeft de tijd this.Add(tiles); tiles.CellWidth = 72; tiles.CellHeight = 55; for (int x = 0; x < width; ++x) for (int y = 0; y < textlines.Count - 2; ++y) { Tile t = LoadTile(textlines[y][x], x, y); tiles.Add(t, x, y); } }
public override void Loaded() { if (objects == null) objects = new GameObjectList(); else { foreach (GameObject obj in objects) { if (obj.ID > objCount) objCount = obj.ID; } } foreach (GameObject o in objects) { foreach (Component c in o.components) { c.Loaded(); } } }
public Level(int levelIndex) { // load the backgrounds GameObjectList backgrounds = new GameObjectList(0, "backgrounds"); SpriteGameObject background_main = new SpriteGameObject("Backgrounds/spr_sky"); background_main.Position = new Vector2(0, GameEnvironment.Screen.Y - background_main.Height); backgrounds.Add(background_main); SpriteGameObject background_extended = new SpriteGameObject("Backgrounds/spr_sky"); background_extended.Position = new Vector2(background_main.Width, GameEnvironment.Screen.Y - background_main.Height); backgrounds.Add(background_extended); // add a few random mountains for (int i = 0; i < 10; i++) { SpriteGameObject mountain = new SpriteGameObject("Backgrounds/spr_mountain_" + (GameEnvironment.Random.Next(2) + 1), GameEnvironment.Random.Next(4)+3); mountain.Position = new Vector2((float)GameEnvironment.Random.NextDouble() * (2 * background_main.Width) - mountain.Width / 2, GameEnvironment.Screen.Y - mountain.Height); backgrounds.Add(mountain); } Clouds clouds = new Clouds(4); backgrounds.Add(clouds); this.Add(backgrounds); SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100); timerBackground.Position = new Vector2(10, 10); timerBackground.Meebewegen(); this.Add(timerBackground); TimerGameObject timer = new TimerGameObject(101, "timer"); timer.Position = new Vector2(25, 30); this.Add(timer); quitButton = new Button("Sprites/spr_button_quit", 100); quitButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 10); this.Add(quitButton); this.Add(new GameObjectList(1, "waterdrops")); this.Add(new GameObjectList(2, "enemies")); this.LoadTiles("Content/Levels/" + levelIndex + ".txt"); }
public Level(int levelIndex) : base() { GameObjectList backgrounds = new GameObjectList(0, "backgrounds"); SpriteGameObject background_main = new SpriteGameObject("Backgrounds/spr_sky"); background_main.Position = new Vector2(0, GameEnvironment.Screen.Y - background_main.Height); backgrounds.Add(background_main); for(int i = 0; i < 5; i++) { SpriteGameObject mountain = new SpriteGameObject("Backgrounds/spr_mountain_" + (GameEnvironment.Random.Next(2) + 1), 1); mountain.Position = new Vector2((float)GameEnvironment.Random.NextDouble() * GameEnvironment.Screen.X - mountain.Width / 2, GameEnvironment.Screen.Y - mountain.Height); backgrounds.Add(mountain); } Clouds clouds = new Clouds(2); backgrounds.Add(clouds); Add(backgrounds); SpriteGameObject timerBackground = new SpriteGameObject("Sprites/spr_timer", 100); timerBackground.Position = new Vector2(10, 10); Add(timerBackground); TimerGameObject timer = new TimerGameObject(0.5, 1, 101, "timer"); timer.Position = new Vector2(25, 30); Add(timer); quitButton = new Button("Sprites/spr_button_quit", 100); quitButton.Position = new Vector2(GameEnvironment.Screen.X - quitButton.Width - 10, 10); Add(quitButton); Add(new GameObjectList(1, "waterdrops")); Add(new GameObjectList(2, "enemies")); LoadTiles("Content/Levels/" + levelIndex + ".txt"); }
public override void Initialize() { base.Initialize(); Objects = new ObservableList<VisibilityStruct>(); var objectVisibilities = FindObjectsOfType<ObjectVisibility>(); foreach (var objectVisibility in objectVisibilities) { objectVisibility.RestoreState(); if (objectVisibility.Entries == null || objectVisibility.Entries.Length == 0) continue; var index = 0; foreach (var objectVisibilityInfo in objectVisibility.Entries) { var materialProperties = objectVisibilityInfo.GameObject.GetComponentsInChildren<MaterialProperties>(); if (materialProperties == null || materialProperties.Length == 0) continue; Objects.Add(new VisibilityStruct { Name = objectVisibilityInfo.GameObject.name, Opacity = materialProperties[0].Opacity, Enabled = materialProperties[0].Enabled, MatProps = materialProperties }); index++; } } var go = GameObject.Find("Visibilities"); if (go == null) return; GoList = go.GetComponentInChildren<GameObjectList>(); UpdateVisibilities(); }
public static void SetGameObjectList(GameObjectList objectList) { gameObjectList = objectList; }
public PlayingState() { levels = new GameObjectList(0,"levels"); levels.Add(new Level(1)); this.Add(levels); }
void Start() { InstanceObjectList = this; }
public Scene() { name = "New scene"; objects = new GameObjectList(); data = new Dictionary<string, object>(); }