/// <summary> /// Creates a nerve cell /// </summary> /// <param name="_texture">2D texture</param> /// <param name="_position">position of nerve</param> /// <param name="_velocity">n/a</param> /// <param name="_frames">frames per animation</param> /// <param name="_animations">rows of animations</param> /// <param name="_switchType">"toggle", "timer"</param> public NerveCell(World _level, Texture2D _texture, Vector2 _position, Vector2 _velocity, int _frames, int _animations, String _switchType, float _rotation) : base(_level, _texture, _position, _velocity, _frames, _animations) { rotation = _rotation; animation.Depth = 0.011f; animation.Scale = .75f; aniM.AddAnimation("On", 2, 1, animation.Copy()); aniM.AddAnimation("Off", 1, 8, animation.Copy()); aniM.AddAnimation("Wobble", 1, _frames, animation.Copy()); aniM.Animation = "On"; aniM.FramesPerSecond = 60; synapse = SpriteClasses.SpriteManager.addSynapse(position, 0f, 2000f, 1f, 0f); synapse.IsVisible = false; if (_switchType == "toggle" || _switchType == "timer") switchType = _switchType; else switchType = "toggle"; rotates = false; Type = "Nerve"; //0 no bounce 1 bounce set from 0.0 to 1.0 body.Mass = 2000000f; body.Restitution = 0f; //slows the object when no force applied body.LinearDamping = 0f; body.CollidesWith = ~Category.Cat15; //body.IsSensor = true; JointFactory.CreateFixedRevoluteJoint(level, body, body.LocalCenter, new Vector2((float)ConvertUnits.ToSimUnits(_position.X), (float)ConvertUnits.ToSimUnits(_position.Y))); //body.ApplyForce(velocity); }
private void AddParticles() { if (time >= spawnTimer && listCount < spawnAmount) { time = 0; var tempProp = new SpriteClasses.Parallax.Prop(Globals.particles, position, speed); tempProp.rotation = spin; propList.Add(tempProp); } }
/// <summary> /// Tile loading method, reads gleed2d xml-file and sorts out paths and textures /// </summary> protected void LoadTiles() { SpriteClasses.SpriteManager.Content = content; SpriteClasses.SpriteManager.Level = world; finalScore = new List<ArrayList>(); using (Stream stream = TitleContainer.OpenStream("Content/Levels/level1.gleed")) //#1 change gere you level file path { XElement xml = XElement.Load(stream); level = LevelLoader.Load(xml); } tiles = new List<Tile>(); pathTiles = new List<PathTile>(); textures = new List<MyTexture>(); //despawn = new SpriteClasses.BloodControl.BloodDespawner(world, content.Load<Texture2D>("Test/test"), new Vector2(0, 0), new Vector2(0, 0), 1, 1, 2f, 2f); #region update sprites switch/foreach foreach (Layer layer in level.Layers) { String layerName = layer.Properties.Name.ToString(); switch (layerName) { case "Collision": { foreach (LayerItem item in layer.Items) { if (item.Properties is PathItemProperties) { PathItemProperties pathProperties = item.Properties as PathItemProperties; pathTile = new PathTile(pathProperties.LocalPoints, pathProperties.Position, world); pathTiles.Add(pathTile); } if (item.Properties is RectangleItemProperties) { RectangleItemProperties pathProperties = item.Properties as RectangleItemProperties; tile = new Tile(TileCollision.Impassable, pathProperties.Width, pathProperties.Height, pathProperties.Position, pathProperties.Rotation, world); tiles.Add(tile); } } } break; case "LevelTexture": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; string filename = "Levels/" + Path.GetFileNameWithoutExtension(textureProperties.TexturePathRelativeToContentRoot); //3# change here your tile textures' file path Texture2D texture = content.Load<Texture2D>(filename); myTexture = new MyTexture(texture, textureProperties.Position, textureProperties.Rotation, textureProperties.Scale * Globals.GlobalScale, .071f); textures.Add(myTexture); } } } break; case "Finish": { foreach (LayerItem item in layer.Items) { if (item.Properties is CircleItemProperties) { CircleItemProperties textureProperties = item.Properties as CircleItemProperties; Body Ziel = BodyFactory.CreateCircle(world, ConvertUnits.ToSimUnits(textureProperties.Radius), 1.0f); Ziel.Position = new Vector2(ConvertUnits.ToSimUnits(textureProperties.Position.X), ConvertUnits.ToSimUnits(textureProperties.Position.Y)); Ziel.IgnoreGravity = true; Ziel.CollidesWith = Category.Cat5; Ziel.OnCollision += collisionZiel; } } } break; case "Flow": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; velocityRectangles.Add(new VelocityRect(world, textureProperties.Position, textureProperties.Scale, textureProperties.Rotation, player)); } } } break; case "Plasma": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { kills_++; TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; allCells.Add(SpriteClasses.SpriteManager.addPlasmaCell(tempSpawn, new Vector2(0, 0), 'd')); } } } break; case "Player": { foreach (LayerItem item in layer.Items) { if (item.Properties is CircleItemProperties) { CircleItemProperties textureProperties = item.Properties as CircleItemProperties; Vector2 tempSpawn = textureProperties.Position; player = SpriteClasses.SpriteManager.addPlayerCell(tempSpawn); allCells.Add(player); } } } break; case "Makrophage": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; allCells.Add(SpriteClasses.SpriteManager.addMakrophageCell(tempSpawn, new Vector2(0, 0))); } } } break; case "Helper": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { kills_++; TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; allCells.Add(SpriteClasses.SpriteManager.addHilferCell(tempSpawn, new Vector2(0, 0))); } } } break; case "Monozyt": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; allCells.Add(SpriteClasses.SpriteManager.addMonozytCell(tempSpawn, new Vector2(0, 0))); } } } break; case "BloodSpawner": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; float tempScale = textureProperties.Scale.X; tempScale += textureProperties.Scale.Y; tempScale /= 2f; SpriteClasses.BloodControl.BloodSpawner tempBS = new SpriteClasses.BloodControl.BloodSpawner(tempSpawn, textureProperties.Rotation, 70, 17.5f, tempScale); tempBS.nameForLevel = textureProperties.Name; allCells.Add(tempBS); } } } break; case "BloodCellDespawner": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; float tempScale = textureProperties.Scale.X; tempScale += textureProperties.Scale.Y; tempScale /= 2f; SpriteClasses.BloodControl.BloodDespawner tempBS = SpriteClasses.SpriteManager.addBloodDespawner(tempSpawn, textureProperties.Rotation, tempScale); tempBS.nameForLevel = textureProperties.Name; allCells.Add(tempBS); } } } break; case "Gefecht": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; float tempScale = textureProperties.Scale.X; tempScale += textureProperties.Scale.Y; tempScale /= 2f; Vector2 tempSpawn = textureProperties.Position; SpriteClasses.Valves.Gefecht tempGef = SpriteClasses.SpriteManager.addGefecht(tempSpawn, textureProperties.Rotation, tempScale); tempGef.nameForLevel = textureProperties.Name; allCells.Add(tempGef); } } } break; case "Collection": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { collected_++; TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; allCells.Add(SpriteClasses.SpriteManager.addCollectCell(tempSpawn, new Vector2(0, 0))); } } } break; case "Nerve": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; SpriteClasses.NPCSprites.NerveCell tempNerve = SpriteClasses.SpriteManager.addNerveCell(tempSpawn, textureProperties.Rotation); tempNerve.nameForLevel = textureProperties.Name; allCells.Add(tempNerve); } } } break; case "Trigger": { foreach (LayerItem item in layer.Items) { if (item.Properties is TextureItemProperties) { TextureItemProperties textureProperties = item.Properties as TextureItemProperties; Vector2 tempSpawn = textureProperties.Position; SpriteClasses.NPCSprites.TriggerCell tempTrigg = SpriteClasses.SpriteManager.addTriggerCell(tempSpawn, textureProperties.Rotation); tempTrigg.nameForLevel = textureProperties.Name; allCells.Add(tempTrigg); } } } break; default: break; } } #endregion paralaxBG = new SpriteClasses.Parallax.Background(Content.Load<Texture2D>("Levels/level1_bg"), 20f); bloodBG = new SpriteClasses.Parallax.Prop(Content.Load<Texture2D>("Images/BGs/bloodcellparalax"), new Vector2(-1000, 1000), new Vector2(1, -3), 150f, 'R', 1f); bloodBG2 = new SpriteClasses.Parallax.Prop(Content.Load<Texture2D>("Images/BGs/bloodcellparalax"), new Vector2(-2000, -2000), new Vector2(3, 2), 80f, 'B', .7f); bloodBG3 = new SpriteClasses.Parallax.Prop(Content.Load<Texture2D>("Images/BGs/bloodcellparalax"), new Vector2(1000, 1000), new Vector2(-4, -1), 700f, 'W', 3f); veinBG = new SpriteClasses.Parallax.Prop(Content.Load<Texture2D>("Images/BGs/venesParalax"), new Vector2(-1100, -500), new Vector2(0, 0), 50f, 'F', 2f); veinBG.Rotation = (float)(2.0 / Math.PI); alarm = new SpriteClasses.alarmSprite(world, Content.Load<Texture2D>("Images/alarm"), new Vector2(0, 0), new Vector2(0, 0), 4, 1); fadingTest = SpriteClasses.SpriteManager.addFadingSprite(); allCells.Add(paralaxBG); allCells.Add(bloodBG); allCells.Add(veinBG); allCells.Add(bloodBG2); allCells.Add(alarm); allCells.Add(bloodBG3); allCells.Add(fadingTest); }