private void Awake() { if (!singleton) { singleton = this; } // Reload All Textures BrushTool.ReloadTexture(); PencilTool.ReloadTexture(); EraserTool.ReloadTexture(); SprayTool.ReloadTexture(); CrayonTool.ReloadTexture(); ColorPenTool.ReloadTexture(); PatternDrawTool.ReloadTexture(); OutTexture = Draw.GetWhiteTexture(DrawSheetWidth, DrawSheetHeight); DrawSheetImage.texture = OutTexture; PaintTex = new MyTexture(OutTexture); ShapeTextures = LoadTexturesInPath("Shapes"); for (int i = 0; i < ShapeTextures.Length; i++) { ShapeTextures[i] = Draw.LoadImage(ShapeTextures[i]); } PatternTextures = LoadTexturesInPath("Patterns"); for (int i = 0; i < PatternTextures.Length; i++) { //PatternTextures[i].adv PatternTextures[i] = Draw.LoadImage(PatternTextures[i]); } HistoryCurrentIndex = -1; }
/// <summary> /// Separate method to call Unity API. WOULDN'T WORK IN MULTYTHREADING! /// Called after initialization of non-Unity data /// </summary> public static void setUnityAPI() { // has to be separate circle World.AllProvinces.PerformAction(x => x.setUnityAPI(grid.getMesh(x), grid.getBorders())); World.AllSeaProvinces.PerformAction(x => x.setUnityAPI(grid.getMesh(x), grid.getBorders())); foreach (var province in World.AllProvinces) { var node = province.GameObject.GetComponent <Node>(); node.Set(province, province.AllNeighbors()); World.Get.graph.AddNode(node); province.SetBorderMaterials(); } Country.setUnityAPI(); //seaProvinces = null; // todo clear resources grid = null; mapTexture = null; // Annex all countries to P)layer //foreach (var item in World.getAllExistingCountries().Where(x => x != Game.Player)) //{ // item.annexTo(Game.Player); //} //Quaternion.Ro(90f, Vector3.right); //World.Get.transform.Rotate(Vector3.right* 90f); //World.Get.transform.rotation.SetAxisAngle(Vector3.right, 90f); //del.x = 90f; //World.Get.transform.rotation = del; }
public static void ProcessSpriteMessage(MyRenderMessageDrawSprite sprite) { Vector2 rightVector = sprite.Rotation != 0f ? new Vector2((float)Math.Cos(sprite.Rotation), (float)Math.Sin(sprite.Rotation)) : sprite.RightVector; MyTexture tex = MyTextureManager.GetTexture <MyTexture2D>(sprite.Texture); //System.Diagnostics.Debug.Assert(tex != null); if (tex != null) { RectangleF destinationRectangle = sprite.DestinationRectangle; if (m_screenshot != null) { destinationRectangle.X *= m_screenshot.SizeMultiplier.X; destinationRectangle.Y *= m_screenshot.SizeMultiplier.Y; destinationRectangle.Width *= m_screenshot.SizeMultiplier.X; destinationRectangle.Height *= m_screenshot.SizeMultiplier.Y; } DrawSpriteMain( tex, null, ref destinationRectangle, sprite.ScaleDestination, sprite.SourceRectangle, sprite.Color, rightVector, ref sprite.Origin, sprite.Effects, sprite.Depth ); } }
/// <summary> /// Checks the normal map. /// </summary> /// <param name="texture">The texture.</param> private static void CheckTexture(MyTexture texture) { System.Diagnostics.Debug.Assert(texture != null, "Voxel texture missing"); MyUtilsRender9.AssertTexture((MyTexture2D)texture); texture.TextureLoaded -= CheckTexture; }
/// <summary> /// Separate method to call Unity API. WOULDN'T WORK IN MULTYTHREADING! /// Called after initialization of non-Unity data /// </summary> public static void setUnityAPI() { // Assigns a material named "Assets/Resources/..." to the object. //defaultCountryBorderMaterial = Resources.Load("materials/CountryBorder", typeof(Material)) as Material; defaultCountryBorderMaterial = GameObject.Find("CountryBorderMaterial").GetComponent <MeshRenderer>().material; //defaultProvinceBorderMaterial = Resources.Load("materials/ProvinceBorder", typeof(Material)) as Material; defaultProvinceBorderMaterial = GameObject.Find("ProvinceBorderMaterial").GetComponent <MeshRenderer>().material; //selectedProvinceBorderMaterial = Resources.Load("materials/SelectedProvinceBorder", typeof(Material)) as Material; selectedProvinceBorderMaterial = GameObject.Find("SelectedProvinceBorderMaterial").GetComponent <MeshRenderer>().material; //impassableBorder = Resources.Load("materials/ImpassableBorder", typeof(Material)) as Material; impassableBorder = GameObject.Find("ImpassableBorderMaterial").GetComponent <MeshRenderer>().material; //r3dTextPrefab = (GameObject)Resources.Load("prefabs/3dProvinceNameText", typeof(GameObject)); r3dTextPrefab = GameObject.Find("3dProvinceNameText"); World.GetAllProvinces().PerformAction(x => x.setUnityAPI(grid.getMesh(x), grid.getBorders())); World.GetAllProvinces().PerformAction(x => x.setBorderMaterials(false)); Country.setUnityAPI(); //seaProvinces = null; // todo clear resources grid = null; mapTexture = null; // Annex all countries to P)layer //foreach (var item in World.getAllExistingCountries().Where(x => x != Game.Player)) //{ // item.annexTo(Game.Player); //} }
/// <summary> /// Could run in threads /// </summary> public static void Create(MyTexture map) { bool isMapRandom = MapOptions.MapImage == null; //FactoryType.getResourceTypes(); // FORCING FactoryType to initialize? // remake it on messages? //Game.updateStatus("Reading provinces.."); preReadProvinces(map); var seaProvinces = getSeaProvinces(map, !isMapRandom); deleteSomeProvinces(seaProvinces, isMapRandom); // Game.updateStatus("Making countries.."); CreateCountries(); //Game.updateStatus("Making population.."); CreateRandomPopulation(); setStartResources(); //foreach (var item in World.getAllExistingCountries()) //{ // item.Capital.OnSecedeTo(item, false); //} }
public static Vector2 DrawLineWithTex(MyTexture OutTex, MyTexture PatternsTex, Brush _Brush, Vector2 Pos0, Vector2 Pos1) { MyVector Vect = new MyVector(); DrawLineWithTex(OutTex, _Brush, PatternsTex, (int)Pos0.x, (int)Pos0.y, (int)Pos1.x, (int)Pos1.y, ref Vect); return(Vect); }
/// <summary> /// Could run in threads /// </summary> public static void Create(MyTexture map) { bool isMapRandom = MapOptions.MapImage == null; //FactoryType.getResourceTypes(); // FORCING FactoryType to initialize? // remake it on messages? //Game.updateStatus("Reading provinces.."); CreateProvinces(map, !isMapRandom); // Game.updateStatus("Making countries.."); CreateCountries(); //Game.updateStatus("Making population.."); CreateRandomPopulation(); if (Game.IndustrialStart) { IndustrialStart(); } if (Game.devMode) { setStartResources(); // only for testing cause it bugs resource/factory connection } //foreach (var item in World.getAllExistingCountries()) //{ // item.Capital.OnSecedeTo(item, false); //} }
public static void setUnityAPI() { // Assigns a material named "Assets/Resources/..." to the object. //defaultCountryBorderMaterial = Resources.Load("materials/CountryBorder", typeof(Material)) as Material; defaultCountryBorderMaterial = GameObject.Find("CountryBorderMaterial").GetComponent <MeshRenderer>().material; //defaultProvinceBorderMaterial = Resources.Load("materials/ProvinceBorder", typeof(Material)) as Material; defaultProvinceBorderMaterial = GameObject.Find("ProvinceBorderMaterial").GetComponent <MeshRenderer>().material; //selectedProvinceBorderMaterial = Resources.Load("materials/SelectedProvinceBorder", typeof(Material)) as Material; selectedProvinceBorderMaterial = GameObject.Find("SelectedProvinceBorderMaterial").GetComponent <MeshRenderer>().material; //impassableBorder = Resources.Load("materials/ImpassableBorder", typeof(Material)) as Material; impassableBorder = GameObject.Find("ImpassableBorderMaterial").GetComponent <MeshRenderer>().material; //r3dTextPrefab = (GameObject)Resources.Load("prefabs/3dProvinceNameText", typeof(GameObject)); r3dTextPrefab = GameObject.Find("3dProvinceNameText"); mapObject = GameObject.Find("MapObject"); Province.generateUnityData(grid); Country.setUnityAPI(); seaProvinces = null; grid = null; map = null; // Annex all countries to P)layer //foreach (var item in Country.allCountries) //{ // item.annexTo(Game.Player); //} }
public static Vector2 DrawLine(MyTexture OutTex, Brush _Brush, Color DrawColor, Vector2 Pos0, Vector2 Pos1) { MyVector Vect = new MyVector(); DrawLine(OutTex, _Brush, new ByteColor(DrawColor), (int)Pos0.x, (int)Pos0.y, (int)Pos1.x, (int)Pos1.y, ref Vect); return(Vect); }
public override bool Equals(object obj) { MyTexture t = obj as MyTexture; if (t == null) { return(false); } if (this.File != t.File) { return(false); } if (this.Bitmap != t.Bitmap) { return(false); } if (this.TransparentColorUsed != t.TransparentColorUsed) { return(false); } if (this.TransparentColorUsed) { if (this.TransparentColor != t.TransparentColor) { return(false); } } return(true); }
public static MyTexture getInstance() { if (m_pContainer == null) { m_pContainer = m_pMainObject.GetComponent <MyTexture> (); } return(m_pContainer); }
private void Awake() { PickColorImage.texture = Draw.LoadImage(PickColorSprite); Texture2D NewTex = Draw.GetWhiteTexture(256, 32); BrightTexture = new MyTexture(NewTex); PickIntensityImage.texture = NewTex; }
void UpdatePreviewTexture() { Texture2D previewTex = Draw.GetWhiteTexture((int)PreviewImage.rectTransform.rect.width, (int)PreviewImage.rectTransform.rect.height); PreviewImage.texture = previewTex; MyTexture paintTex = new MyTexture((Texture2D)PreviewImage.texture); Draw.DrawBrushTip(paintTex, DrawTool.GetBrush(Size), Color.black, new Vector2(PreviewImage.texture.width / 2, PreviewImage.texture.height / 2)); previewTex.LoadRawTextureData(paintTex.Data); previewTex.Apply(); }
public Game() { if (readMapFormFile) { Texture2D mapImage = Resources.Load("provinces", typeof(Texture2D)) as Texture2D; ///texture; mapTexture = new MyTexture(mapImage); } else { generateMapImage(); } mapBorders = new Rect(0f, 0f, mapTexture.getWidth() * Options.cellMultiplier, mapTexture.getHeight() * Options.cellMultiplier); }
public override Texture Add(string file, Vector3b transparentColor) { MyTexture t = new MyTexture(file, transparentColor); for (int i = 0; i < this.Textures.Count; i++) { if (this.Textures[i].Equals(t)) { return(this.Textures[i]); } } this.Textures.Add(t); return(this.Textures[this.Textures.Count - 1]); }
public override Texture Add(string file) { MyTexture t = new MyTexture(file); for (int i = 0; i < this.Textures.Count; i++) { if (this.Textures[i].Equals(t)) { return(this.Textures[i]); } } this.Textures.Add(t); return(this.Textures[this.Textures.Count - 1]); }
public VoxelGrid(int width, int height, float size, MyTexture texture, List <Province> blockedProvinces, Game game, List <Province> provinces ) { this.width = width; this.height = height; this.game = game; // this.resolution = resolution; gridSize = size; voxelSize = size / width; voxels = new Voxel[width * height]; //voxelMaterials = new Material[voxels.Length]; dummyX = new Voxel(); dummyY = new Voxel(); dummyT = new Voxel(); //analyzingColor = color; //Color curColor, x1y1Color, x2y1Color, x1y2Color, x2y2Color; for (int i = 0, y = 0; y < height; y++) { for (int x = 0; x < width; x++) { //curColor = texture.GetPixel(x, y); //if (!blockedProvinces.Contains(curColor)) CreateVoxel(i, x, y, provinces.Find(province => province.getColorID() == texture.GetPixel(x, y))); i++; } } //for (int i = 0, y = 0; y < resolution; y++) //{ // for (int x = 0; x < resolution ; x++, i++) // { // x1y1Color = texture.GetPixel(x, y); // x2y1Color = texture.GetPixel(x + 1, y); // x1y2Color = texture.GetPixel(x, y + 1); // x2y2Color = texture.GetPixel(x + 1, y + 1); // if (!blockedProvinces.Contains(x1y1Color) // || !blockedProvinces.Contains(x2y1Color) // || !blockedProvinces.Contains(x1y2Color) // || !blockedProvinces.Contains(x2y2Color) // ) // CreateVoxel(i, x, y, x1y1Color); // else // CreateVoxel(i, x, y, Color.black); // } //} }
public Game(Texture2D mapImage) { DrawFogOfWar = true; if (mapImage == null) { generateMapImage(); } else { //Texture2D mapImage = Resources.Load("provinces", typeof(Texture2D)) as Texture2D; ///texture; mapTexture = new MyTexture(mapImage); } mapBorders = new Rect(0f, 0f, mapTexture.getWidth() * Options.cellMultiplier, mapTexture.getHeight() * Options.cellMultiplier); }
/// <summary> /// Separate method to call Unity API. WOULDN'T WORK IN MULTYTHREADING! /// Called after initialization of non-Unity data /// </summary> public static void setUnityAPI() { // Assigns a material named "Assets/Resources/..." to the object. //defaultCountryBorderMaterial = Resources.Load("materials/CountryBorder", typeof(Material)) as Material; //defaultCountryBorderMaterial = GameObject.Find("CountryBorderMaterial").GetComponent<MeshRenderer>().material; ////defaultProvinceBorderMaterial = Resources.Load("materials/ProvinceBorder", typeof(Material)) as Material; //defaultProvinceBorderMaterial = GameObject.Find("ProvinceBorderMaterial").GetComponent<MeshRenderer>().material; ////selectedProvinceBorderMaterial = Resources.Load("materials/SelectedProvinceBorder", typeof(Material)) as Material; //selectedProvinceBorderMaterial = GameObject.Find("SelectedProvinceBorderMaterial").GetComponent<MeshRenderer>().material; ////impassableBorder = Resources.Load("materials/ImpassableBorder", typeof(Material)) as Material; //impassableBorder = GameObject.Find("ImpassableBorderMaterial").GetComponent<MeshRenderer>().material; //r3dTextPrefab = (GameObject)Resources.Load("prefabs/3dProvinceNameText", typeof(GameObject)); //r3DProvinceTextPrefab = GameObject.Find("3DProvinceNameText"); //r3DCountryTextPrefab = GameObject.Find("3DCountryNameText"); World.GetAllLandProvinces().PerformAction(x => x.setUnityAPI(grid.getMesh(x), grid.getBorders())); World.AllSeaProvinces().PerformAction(x => x.setUnityAPI(grid.getMesh(x), grid.getBorders())); foreach (var item in World.GetAllLandProvinces()) { var node = item.GameObject.GetComponent <Node>(); node.Set(item, item.getAllNeighbors()); World.Get.graph.AddNode(node); } World.GetAllLandProvinces().PerformAction(x => x.SetBorderMaterials()); Country.setUnityAPI(); //seaProvinces = null; // todo clear resources grid = null; mapTexture = null; // Annex all countries to P)layer //foreach (var item in World.getAllExistingCountries().Where(x => x != Game.Player)) //{ // item.annexTo(Game.Player); //} //Quaternion.Ro(90f, Vector3.right); //World.Get.transform.Rotate(Vector3.right* 90f); //World.Get.transform.rotation.SetAxisAngle(Vector3.right, 90f); //del.x = 90f; //World.Get.transform.rotation = del; }
private Resourse(Texture2D bg, Texture2D t1, Texture2D t2, SpriteFont bigFont, SpriteFont scoreFont, SpriteFont startFont, SoundEffect eat, SoundEffect deadsound, SoundEffect endSound, SoundEffect bgm, SoundEffect levelUp, SoundEffect v ) { baseBallTexture = new MyTexture(t1, new Point(512, 298), new Point(2, 2)); playerBallTexture = new MyTexture(t2, new Point(512, 298), new Point(2, 2)); gameBackground = new MyTexture(bg, new Point(800, 600), new Point(1, 1)); this.bigFont = bigFont; this.scoreFont = scoreFont; this.startFont = startFont; this.eat = eat; this.bgm = bgm; this.deadSound = deadsound; this.endSound = endSound; this.levelUp = levelUp; this.victory = v; }
public static void preReadProvinces(MyTexture image) { ProvinceNameGenerator nameGenerator = new ProvinceNameGenerator(); Color currentProvinceColor = image.GetPixel(0, 0); int provinceCounter = 0; for (int j = 0; j < image.getHeight(); j++) // circle by province { for (int i = 0; i < image.getWidth(); i++) { if (currentProvinceColor != image.GetPixel(i, j) //&& !blockedProvinces.Contains(currentProvinceColor) && !isProvinceCreated(currentProvinceColor)) { allProvinces.Add(new Province(nameGenerator.generateProvinceName(), provinceCounter, currentProvinceColor, Product.getRandomResource(false))); provinceCounter++; } currentProvinceColor = image.GetPixel(i, j); //game.updateStatus("Reading provinces.. x = " + i + " y = " + j); } } }
////cut by random //seaProvince = FindProvince(mapTexture.getRandomPixel()); //if (!res.Contains(seaProvince)) // res.Add(seaProvince); //if (Rand.Get.Next(3) == 1) //{ // seaProvince = FindProvince(mapTexture.getRandomPixel()); // if (!res.Contains(seaProvince)) // res.Add(seaProvince); // if (Rand.Get.Next(20) == 1) // { // seaProvince = FindProvince(mapTexture.getRandomPixel()); // if (!res.Contains(seaProvince)) // res.Add(seaProvince); // } //} public static void CreateProvinces(MyTexture mapTexture, bool useProvinceColors) { ProvinceNameGenerator nameGenerator = new ProvinceNameGenerator(); if (!useProvinceColors) { var uniqueColors = mapTexture.AllUniqueColors2(); int counter = 0; int lakechance = 20;// foreach (var item in uniqueColors) { if (!item.Value && Rand.Get.Next(lakechance) != 0) { allLandProvinces.Add(new Province(nameGenerator.generateProvinceName(), counter, item.Key, Product.getRandomResource(false))); } //else // allSeaProvinces.Add(new SeaProvince("", counter, item.Key)); counter++; } } else { // Victoria 2 format var uniqueColors = mapTexture.AllUniqueColors(); for (int counter = 0; counter < uniqueColors.Count; counter++) { var color = uniqueColors[counter]; if (!(color.g + color.b >= 200f / 255f + 200f / 255f && color.r < 96f / 255f)) { //if (color.g + color.b + color.r > 492f / 255f) allLandProvinces.Add(new Province(nameGenerator.generateProvinceName(), counter, color, Product.getRandomResource(false))); } } } }
//private readonly Game game; //public VoxelGrid(int width, int height, float size, MyTexture texture, List<Province> blockedProvinces, IEnumerable<Province> provinces) public VoxelGrid(int width, int height, float size, MyTexture texture, IEnumerable <T> provinces) { this.width = width; this.height = height; //this.game = game; // this.resolution = resolution; gridSize = size; voxelSize = size / width; voxels = new Voxel <T> [width * height]; dummyX = new Voxel <T>(); dummyY = new Voxel <T>(); dummyT = new Voxel <T>(); for (int i = 0, y = 0; y < height; y++) { for (int x = 0; x < width; x++) { CreateVoxel(i, x, y, provinces.FirstOrDefault(t => t.ColorID == texture.GetPixel(x, y))); i++; } } }
private Resourse(Texture2D bg,Texture2D t1,Texture2D t2) { baseBallTexture = new MyTexture(t1,new Point(512, 298), new Point(2, 2)); playerBallTexture = new MyTexture(t2, new Point(512, 298), new Point(2, 2)); gameBackground = new MyTexture(bg, new Point(800,600), new Point(1, 1)); ; }
private static void generateMapImage() { int mapSize; int width; //#if UNITY_WEBGL if (devMode) { mapSize = 20000; width = 150 + Rand.Get.Next(60); } else { //mapSize = 25000; //width = 170 + Random.Next(65); //mapSize = 30000; //width = 180 + Random.Next(65); mapSize = 40000; width = 250 + Rand.Get.Next(40); } // 140 is sqrt of 20000 //int width = 30 + Random.Next(12); // 140 is sqrt of 20000 //#else // int mapSize = 40000; // int width = 200 + Random.Next(80); //#endif Texture2D mapImage = new Texture2D(width, mapSize / width); // standard for webGL Color emptySpaceColor = Color.black; //.setAlphaToZero(); mapImage.setColor(emptySpaceColor); int amountOfProvince = mapImage.width * mapImage.height / 140 + Rand.Get.Next(5); //amountOfProvince = 400 + Rand.random2.Next(100); for (int i = 0; i < amountOfProvince; i++) { mapImage.SetPixel(mapImage.getRandomX(), mapImage.getRandomY(), ColorExtensions.getRandomColor()); } int emptyPixels = 1;//non zero Color currentColor = mapImage.GetPixel(0, 0); int emergencyExit = 0; while (emptyPixels != 0 && emergencyExit < 100) { emergencyExit++; emptyPixels = 0; for (int j = 0; j < mapImage.height; j++) // circle by province { for (int i = 0; i < mapImage.width; i++) { currentColor = mapImage.GetPixel(i, j); if (currentColor == emptySpaceColor) { emptyPixels++; } else if (currentColor.a == 1f) { mapImage.drawRandomSpot(i, j, currentColor); } } } mapImage.setAlphaToMax(); } mapImage.Apply(); mapTexture = new MyTexture(mapImage); Texture2D.Destroy(mapImage); }
/// <summary> /// Checks the normal map. /// </summary> /// <param name="texture">The texture.</param> private static void CheckTexture(MyTexture texture) { MyUtils.AssertTexture((MyTexture2D)texture); texture.TextureLoaded -= CheckTexture; }
public static void FloodFillArea(MyTexture OutTex, Vector2 Pos, MyTexture PatternTex) { FillWithTexture(OutTex, (int)Pos.x, (int)Pos.y, PatternTex); }
public static void DrawBrushTip(MyTexture OutTex, Brush _Brush, Color DrawColor, Vector2 Pos) { DrawBrushTip(OutTex, _Brush, DrawColor, (int)Pos.x, (int)Pos.y); }
public static void DrawBrushTipWithTex(MyTexture OutTex, MyTexture PatternTex, Brush _Brush, Vector2 Pos) { DrawBrushTipWithTex(OutTex, _Brush, PatternTex, (int)Pos.x, (int)Pos.y); }
/// <summary> /// Tile loading method, reads gleed2d xml-file and sorts out paths and textures /// </summary> protected void LoadTiles() { Vector2 playerSpawn = new Vector2(0, 0); 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>(); foreach (Layer layer in level.Layers) { if (layer.Properties.Name.Equals("Collision")) //2# change here your layer's name { 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); } } } if (layer.Properties.Name.Equals("Textures")) { 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); textures.Add(myTexture); } } } if (layer.Properties.Name.Equals("Player")) { foreach (LayerItem item in layer.Items) { if (item.Properties is CircleItemProperties) { CircleItemProperties textureProperties = item.Properties as CircleItemProperties; playerSpawn = textureProperties.Position; } } } if (layer.Properties.Name.Equals("Collectibles")) { foreach (LayerItem item in layer.Items) { if (item.Properties is CircleItemProperties) { CircleItemProperties textureProperties = item.Properties as CircleItemProperties; collectibles.Add(new SpriteClasses.CollectCell(world, Content.Load<Texture2D>("Images/collectible2 Kopie"), new Vector2(textureProperties.Position.X, textureProperties.Position.Y), new Vector2(0, 0), 12, 1)); } } } if (layer.Properties.Name.Equals("Path")) { 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)); } } } } player = new SpriteClasses.PlayerSprite(world, Content.Load<Texture2D>("Test/anim_sp"), playerSpawn, new Vector2(0, 0), 4, 1); blood = new SpriteClasses.NPCSprites.MakrophageCell(world, Content.Load<Texture2D>("Test/enemyspritesheet"), new Vector2(-900, -600), new Vector2(0, 0), 5, 2); helper = new SpriteClasses.NPCSprites.HilferCell(world, Content.Load<Texture2D>("Images/helferzelle_alarm"), new Vector2(200, 200), new Vector2(0, 0), 4, 1); monozyt = new SpriteClasses.NPCSprites.MonozytCell(world, Content.Load<Texture2D>("Images/monozyt spritesheet"), new Vector2(400, 200), new Vector2(0, 0), 14, 1); plasma = new SpriteClasses.NPCSprites.PlasmaCell(world, Content.Load<Texture2D>("Images/plasmacellmoving spritesheet"), new Vector2(400, 300), new Vector2(0, 0), 8, 1); //upper nerve1 = new SpriteClasses.NPCSprites.NerveCell(world, Content.Load<Texture2D>("Test/nerve"), new Vector2(-935, 625), new Vector2(0, 0), 4, 2, "toggle"); nerve1.rotation = 1f; //lower nerve2 = new SpriteClasses.NPCSprites.NerveCell(world, Content.Load<Texture2D>("Test/nerve"), new Vector2(550, -250), new Vector2(0, 0), 4, 2, "toggle"); nerve2.rotation = (float)Math.PI; for (int i = 0; i < collectibles.Count; i++) collectibles[i].body.OnCollision += collectCoin; //lower spawner bloodSpawn1 = new Spawner(Content, 50, .04f, new Vector2(-1100, -33), new Vector2(4.5f, 3f), "bloodcell"); //upper spawner bloodSpawn2 = new Spawner(Content, 50, .04f, new Vector2(1030, -630), new Vector2(-4.5f, 3f), "bloodcell"); player.setupAttack(Content); }
public static List <Province> getSeaProvinces(MyTexture mapTexture, bool useProvinceColors) { List <Province> res = new List <Province>(); if (!useProvinceColors) { Province seaProvince; for (int x = 0; x < mapTexture.getWidth(); x++) { seaProvince = FindProvince(mapTexture.GetPixel(x, 0)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } seaProvince = FindProvince(mapTexture.GetPixel(x, mapTexture.getHeight() - 1)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } for (int y = 0; y < mapTexture.getHeight(); y++) { seaProvince = FindProvince(mapTexture.GetPixel(0, y)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } seaProvince = FindProvince(mapTexture.GetPixel(mapTexture.getWidth() - 1, y)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } seaProvince = FindProvince(mapTexture.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } if (Rand.Get.Next(3) == 1) { seaProvince = FindProvince(mapTexture.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } if (Rand.Get.Next(20) == 1) { seaProvince = FindProvince(mapTexture.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } } } else { // Victoria 2 format foreach (var item in GetAllProvinces()) { var color = item.getColorID(); if (color.g + color.b >= 200f / 255f + 200f / 255f && color.r < 96f / 255f) { //if (color.g + color.b + color.r > 492f / 255f) res.Add(item); } } } return(res); }
/// <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); }
public override Texture Add(string file, Vector3b transparentColor) { MyTexture t = new MyTexture(file, transparentColor); for (int i = 0; i < this.Textures.Count; i++) { if (this.Textures[i].Equals(t)) { return this.Textures[i]; } } this.Textures.Add(t); return this.Textures[this.Textures.Count - 1]; }
public override Texture Add(string file) { MyTexture t = new MyTexture(file); for (int i = 0; i < this.Textures.Count; i++) { if (this.Textures[i].Equals(t)) { return this.Textures[i]; } } this.Textures.Add(t); return this.Textures[this.Textures.Count - 1]; }