public virtual void Initialize(RenderContext context) { IsInitialized = true; //Load All Possible Pickups here PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.Health, "Model/Dynamic/Player_Model")); }
public static Pickup GetRandom(Random rnd, int ScreenSize) { //Roll to generate a random enemy that is different from the previous generated enemy Pickup pickup = null; //Roll var roll = rnd.Next(0, Count); //Add pickup here for each roll if (roll == 0) { pickup = PickupPrefabList.GetPrefab <HealthPickup>(PickupName.Health); } else if (roll == 1) { pickup = PickupPrefabList.GetPrefab <SpeedUpPickup>(PickupName.SpeedUp); } else if (roll == 2) { pickup = PickupPrefabList.GetPrefab <SpeedDownPickup>(PickupName.SpeedDown); } else if (roll == 3) { pickup = PickupPrefabList.GetPrefab <WindUpPickup>(PickupName.WindUp); } else if (roll == 4) { pickup = PickupPrefabList.GetPrefab <WindDownPickup>(PickupName.WindDown); } else { pickup = null; } if (pickup != null) { //For Planes pickup.Scale(-15.0f); pickup.Rotate(0, 0, 180); //For models //pickup.Scale(3.0f); // pickup.Rotate(0, 0, 0); pickup.Translate(rnd.Next(0, 1700), rnd.Next((int)(ScreenSize * -0.4f), (int)(ScreenSize * 0.4f))); } return(pickup); }
public void Initialize(RenderContext context) { var scaleX = 1.5f; var scaleY = 1.2f; //Add Possible Grounds to the list, if all the files have the correct namegiving everything should be loaded in if (PiecePrefabList.Count == 0) { PiecePrefabList.AddPrefab(new PiecePrefab(context, Collision.Col1, "Piece1", scaleX, scaleY)); PiecePrefabList.AddPrefab(new PiecePrefab(context, Collision.Col2, "Piece2", scaleX, scaleY)); PiecePrefabList.AddPrefab(new PiecePrefab(context, Collision.Col3, "Piece4", scaleX, scaleY)); PiecePrefabList.AddPrefab(new PiecePrefab(context, Collision.Col4, "Piece6", scaleX, scaleY)); PiecePrefabList.AddPrefab(new PiecePrefab(context, Collision.Col5, "Piece8", -scaleX, scaleY)); } //Fill Pickups if (PickupPrefabList.Count == 0) { //Load All Possible Pickups here, models and name //Models /*aPickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.Health, "PickupLife")); * PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.SpeedUp, "PickupSpeed")); * PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.SpeedDown, "PickupSpeed")); * PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.WindUp, "PickupSwirl")); * PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.WindDown, "PickupSwirl")); */ // PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.Health, "PickupLife")); PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.SpeedUp, "PickupFast")); PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.SpeedDown, "PickupFast")); PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.WindUp, "PickupWhirl")); PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.WindDown, "PickupWhirl")); PickupPrefabList.AddPrefab(new PickupPrefab(context, PickupName.WindVulcano, "WindVulcano")); } //Fill trees if (TreePrefabList.Count == 0) { TreePrefabList.AddPrefab(new TreePrefab(context, TreeName.Tree1, "Tree1")); TreePrefabList.AddPrefab(new TreePrefab(context, TreeName.Tree2, "Tree2")); TreePrefabList.AddPrefab(new TreePrefab(context, TreeName.Tree3, "Tree3")); } //Fill Enemies if (EnemyPrefabList.Count == 0) { //Load all Possible Pickups here, models and name EnemyPrefabList.AddPrefab(new EnemyPrefab(context, EnemyName.Wheel, "EnemyRotator")); EnemyPrefabList.AddPrefab(new EnemyPrefab(context, EnemyName.Smash, "SmashingWall")); EnemyPrefabList.AddPrefab(new EnemyPrefab(context, EnemyName.FallDown, "Enemy1")); } //always the same startpieces m_Level.Add(new Level_0()); m_Level[0].Initialize(context); GenerateLevel(m_LevelsToGenerate, context); }
protected void AddVolcano(float height, float pos, RenderContext context) { //Generate a windVolcano var volcano = PickupPrefabList.GetPrefab <WindVulcano>(PickupName.WindVulcano); volcano.Create(context); var rnd = new Random(Guid.NewGuid().GetHashCode()); volcano.Rotate(0, 0, 0); volcano.Scale(2.5f, 7.0f, 1.0f); volcano.Translate(rnd.Next(0, 1700), pos - (height * 1.3f)); if (volcano != null) { AddChild(volcano); } }
public override void Initialize(RenderContext context) { Ground ground = GroundPrefabList.GetPrefab(Collision.Col1); ground.Translate(0, 0); AddChild(ground); Ground Top = GroundPrefabList.GetPrefab(Collision.Col1); Top.Rotate(0, 0, 180); Top.Translate(1200, 300); AddChild(Top); Pickup pickup = PickupPrefabList.GetPrefab <HealthPickup>(PickupName.Health); pickup.Translate(1200, 150); AddChild(pickup); var size = (Vector2)ground.RigidBody.UserData; Width = (int)size.X; base.Initialize(context); }
public virtual void Initialize(RenderContext context) { ScreenSize = context.ViewPortSize; //Increase the number of levels we have generated so we can see where we are to make it more difficult NrLevels++; //Each level has a ground and top collision var t = PiecePrefabList.GetRandom(new Random(Guid.NewGuid().GetHashCode()), "Top"); AddChild(t); //Change the Width of the level so they tile nicely var g = PiecePrefabList.GetRandom(new Random(Guid.NewGuid().GetHashCode()), "Ground"); Width = g.Width * 0.85f; AddChild(g); int nrEnemies = 0; int nrPickups = 1; //Med add Every 3 levels if (NrLevels > 5 && NrLevels < 10) { nrEnemies = randVal.Next(0, 3); nrPickups = randVal.Next(0, 3); } else if (NrLevels > 10) { nrEnemies = randVal.Next(0, 3); nrPickups = randVal.Next(0, 3); } if (NrLevels < 15) { AddVolcano(g.Height, g.Position.Y, context); } else if (NrLevels >= 15 && NrLevels < 50) { if (NrLevels % 3 == 0) { AddVolcano(g.Height, g.Position.Y, context); } } else if (NrLevels > 50) { if (NrLevels % 5 == 0) { AddVolcano(g.Height, g.Position.Y, context); } } //Add A pickup for (int i = 0; i < nrPickups; ++i) { //Can return null var pickup = PickupPrefabList.GetRandom(new Random(Guid.NewGuid().GetHashCode()), (int)ScreenSize.Y); if (pickup != null) { AddChild(pickup); } } //Add trees for (int i = 0; i < 3; ++i) { var tree = TreePrefabList.GetRandom(new Random(Guid.NewGuid().GetHashCode()), (int)ScreenSize.Y); if (tree != null) { var rnd = new Random(Guid.NewGuid().GetHashCode()); tree.Translate(tree.Position.X + rnd.Next(0, 1700), tree.Position.Y - 460.0f); AddChild(tree); } } for (int i = 0; i < nrEnemies; ++i) { var enemy = EnemyPrefabList.GetRandom(new Random(Guid.NewGuid().GetHashCode()), (int)ScreenSize.Y); if (enemy != null) { //if enemy is a smash we need 2 of them in opposite directions if (enemy.GetType() == typeof(Smash)) { Smash smashTop = EnemyPrefabList.GetPrefab <Smash>(EnemyName.Smash); smashTop.Translate(enemy.Position.X, enemy.Position.Y + smashTop.m_Distance * 2); //Set the directions enemy.Create(1); smashTop.Create(-1); AddChild(smashTop); } if (enemy.GetType() == typeof(Wheel)) { var rnd = new Random(Guid.NewGuid().GetHashCode()); enemy.Rotate(0, 0, 0); enemy.Scale(1f, -1f, 1.0f); enemy.Translate(rnd.Next(0, 1700), t.Position.Y + (t.Height * 0.9f)); } if (enemy.GetType() == typeof(FallDown)) { var rnd = new Random(Guid.NewGuid().GetHashCode()); enemy.Rotate(0, 180, 0); enemy.Scale(2f, 2f, 1.0f); enemy.Translate(rnd.Next(0, 1700), t.Position.Y + (t.Height * 0.7f)); } AddChild(enemy); } } //Set Everything to default if model or textures are missing foreach (GameModel model in m_Child.ToList <GameModel>()) { model.Initialize(context); } IsInitialized = true; }