public ScoreUpParticle(int value, float x, float y, int lifetime) : base(0, -2, 1, lifetime) { string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); SpriteIndex index = SpriteIndex.Popup_minus1; string fileName = null; if (value < 0) { index = SpriteIndex.Popup_minus1; fileName = "-1"; } else if (value > 1) { index = SpriteIndex.Popup_plus2; fileName = "+2"; } else { index = SpriteIndex.Popup_plus1; fileName = "+1"; } sprite = new Sprite(x, y, index, (Bitmap)Bitmap.FromFile(assemblyFolder + "/../res/" + fileName + ".png"), 22, 1); }
// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
public Sprite(float x, float y, SpriteIndex spriteInd, Bitmap bmp, int frameWidth, float scale) { this.x = x; this.y = y; this.width = frameWidth; this.height = bmp.Height; origin = new Point(0, 0); this.frameWidth = frameWidth; this.spriteIndex = (int)spriteInd; currentFrame = 0; collisionBox = new Rectangle(0, 0, frameWidth, bmp.Height); frames = bmp.Width / frameWidth; if (bmp.Width % frameWidth != 0) { throw new Exception("FATAL ERROR! GO TO HELL!"); } this.scale = scale; this.collisionBox = new Rectangle(0, 0, (int)(frameWidth * scale), (int)(bmp.Height * scale)); }
void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(this.gameObject); return; } spriteIndex = GetComponent<SpriteIndex>(); Dictionary<string, object> temp; TextAsset buildingFile = Resources.Load("Buildings") as TextAsset; string buildingJSON = System.Text.Encoding.UTF8.GetString(buildingFile.bytes); temp = MiniJSON.Json.Deserialize(buildingJSON) as JSONObject; foreach (var building in temp) { JSONObject obj = temp[building.Key] as JSONObject; buildings.Add(building.Key, new BuildingData(GetString(obj, "name"), GetString(obj, "yield"), GetDouble(obj, "yieldAmount"), GetDouble(obj, "ratio"), GetString(obj, "fromResource"), GetString(obj, "toResource"), GetDouble(obj, "multiplier"), GetString(obj, "multipliedYield"))); } TextAsset questFile = Resources.Load("Quests") as TextAsset; string questsJSON = System.Text.Encoding.UTF8.GetString(questFile.bytes); temp = MiniJSON.Json.Deserialize(questsJSON) as JSONObject; foreach (var quest in temp) { JSONObject obj = temp[quest.Key] as JSONObject; quests.Add(quest.Key, new QuestData(obj["name"] as string, obj["description"] as string, obj["requirements"] as Dictionary<string, object>, obj["builds"] as string, (int)((long)obj["unlockedBy"]), (int)((long)obj["minimumSession"]), obj["questOpeningEvent"] as string, obj["questCompletedEvent"] as string, obj["questGiver"] as string)); } TextAsset eventFile = Resources.Load("Events") as TextAsset; string eventJSON = System.Text.Encoding.UTF8.GetString(eventFile.bytes); temp = MiniJSON.Json.Deserialize(eventJSON) as JSONObject; foreach (var evt in temp) { JSONObject obj = temp[evt.Key] as JSONObject; events.Add(evt.Key, new EventData(evt.Key, (obj.ContainsKey("questsUnlocked") ? obj["questsUnlocked"] as List<object> : null), (obj.ContainsKey("charactersUnlocked") ? obj["charactersUnlocked"] as List<object> : null), obj["script"] as List<object>)); } TextAsset minigameFile = Resources.Load("Minigames") as TextAsset; string minigameJSON = System.Text.Encoding.UTF8.GetString(minigameFile.bytes); temp = MiniJSON.Json.Deserialize(minigameJSON) as JSONObject; foreach (var minigame in temp) { JSONObject obj = temp[minigame.Key] as JSONObject; minigames.Add(minigame.Key, new MinigameData((int)(long)obj["highYield"], (int)(long)obj["midYield"], (int)(long)obj["lowYield"], obj["bonuses"] as JSONObject)); } characters.Add("lumberjack", new CharacterData("Araújo, o Lenhador", spriteIndex.lumberjackSprite, spriteIndex.lumberjackMiniSprite)); characters.Add("farmer", new CharacterData("Jorge, o Fazendeiro", spriteIndex.farmerSprite, spriteIndex.farmerMiniSprite)); characters.Add("mayor", new CharacterData("Efigênio, o Prefeito", spriteIndex.mayorSprite, spriteIndex.mayorMiniSprite)); characters.Add("stonemason", new CharacterData("Pietro, o Pedreiro", spriteIndex.stonemasonSprite, spriteIndex.stonemasonMiniSprite)); characters.Add("salesman", new CharacterData("Aurélio, o Comerciante", spriteIndex.salesmanSprite, spriteIndex.salesmanMiniSprite)); characters.Add("blacksmith", new CharacterData("Ademir, o Ferreiro", spriteIndex.blacksmithSprite, spriteIndex.blacksmithMiniSprite)); characters.Add("scholar", new CharacterData("Lúcio, o Estudioso", spriteIndex.scholarSprite, spriteIndex.scholarMiniSprite)); characters.Add("artist", new CharacterData("Cândido, o Artista", spriteIndex.artistSprite, spriteIndex.artistMiniSprite)); resources.Add("Wood" , new ResourceData("Madeira", spriteIndex.woodIcon, spriteIndex.woodIconHighlight)); resources.Add("Stone", new ResourceData("Pedra", spriteIndex.stoneIcon, spriteIndex.stoneIconHighlight)); resources.Add("Metal", new ResourceData("Metal", spriteIndex.metalIcon, spriteIndex.metalIconHighlight)); resources.Add("Wool", new ResourceData("Lã", spriteIndex.woolIcon, spriteIndex.woolIconHighlight)); resources.Add("Food", new ResourceData("Comida", spriteIndex.foodIcon, spriteIndex.foodIconHighlight)); resources.Add("Gold", new ResourceData("Ouro", spriteIndex.goldIcon, spriteIndex.goldIconHighlight)); resources.Add("Paper", new ResourceData("Papel", spriteIndex.paperIcon, spriteIndex.paperIconHighlight)); resources.Add("Fabric", new ResourceData("Tecido", spriteIndex.fabricIcon, spriteIndex.fabricIconHighlight)); resources.Add("Brick", new ResourceData("Tijolo", spriteIndex.brickIcon, spriteIndex.brickIconHighlight)); resources.Add("Marble", new ResourceData("Mármore", spriteIndex.marbleIcon, spriteIndex.marbleIconHighlight)); resources.Add("Coal", new ResourceData("Carvão", spriteIndex.coalIcon, spriteIndex.coalIconHighlight)); }
static bool NextWillReachEnd(SpriteSheetAnimation anim, SpriteIndex sprite) { return(sprite.Value + 1 >= anim.maxSprites); }
public Sprite(SpriteSheet textureSheet, SpriteIndex index, string name, Rectangle bounds, Point center) => (TextureSheet, Index, Name, Bounds, Center) = (textureSheet, index, name, bounds, center);