public void CreateSprite(SpriteType spriteType, Vector3 pos, Vector3 dir) { SpriteProp prop = GetProp(spriteType); if (prop == null) { return; } SpriteBase sprite = null; switch (prop.spriteType) { case SpriteType.BLOOD: sprite = SpriteBlood.pool.Get(); (sprite as SpriteBlood).Init((int)prop.spriteType, prop.lifeTime, prop.materials[Random.Range(0, prop.materials.Length)], pos, dir); break; case SpriteType.BLOOD_BIG: sprite = SpriteBloodBig.pool.Get(); (sprite as SpriteBloodBig).Init((int)prop.spriteType, prop.lifeTime, prop.materials[Random.Range(0, prop.materials.Length)], pos, dir, prop.scaleVal, prop.scaleTime); break; default: break; } if (sprite != null) { _spriteMgr.Add(sprite); } }
public static List <Sprite> GetSprites(string jsonFile) { JsonTextReader reader = new JsonTextReader(new StringReader(File.ReadAllText(jsonFile))); SpriteProp prop = SpriteProp.NotSet; Sprite sprite = new Sprite(); List <Sprite> sprites = new List <Sprite>(); while (reader.Read()) { if (reader.Value != null) { if (reader.TokenType == JsonToken.PropertyName) { switch (reader.Value.ToString()) { case "width": prop = SpriteProp.Width; break; case "height": prop = SpriteProp.Height; break; case "x": prop = SpriteProp.X; break; case "y": prop = SpriteProp.Y; break; case "pixelRatio": prop = SpriteProp.PixelRatio; break; default: sprite.Name = reader.Value.ToString(); break; } } else { if (prop != SpriteProp.NotSet) { switch (prop) { case SpriteProp.Width: sprite.Width = int.Parse(reader.Value.ToString()) - 2; break; case SpriteProp.Height: sprite.Height = int.Parse(reader.Value.ToString()) - 2; break; case SpriteProp.X: sprite.X = int.Parse(reader.Value.ToString()) + 1; break; case SpriteProp.Y: sprite.Y = int.Parse(reader.Value.ToString()) + 1; break; case SpriteProp.PixelRatio: sprites.Add(sprite); sprite = new Sprite(); prop = SpriteProp.NotSet; break; } } } //Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value); } } return(sprites); }
public SpritePropPanel_OnPropChangeArgs(SpriteProp prop) { Prop = prop; }