public static BugModel createPlainBugModel(string bugName, int tileIndex) { string plainBugDescription = "Just a plain old " + bugName; int plainBugPrice = 100; string plainBugQuickItemString = bugName + "/100/-50/Bug/Just a Plain " + bugName + "/true/true/0/" + bugName; string plainBugTextureAsset = "Assets/critters.png"; string[] plainBugIdList = { "Plain", bugName, tileIndex.ToString() }; string plainBugId = String.Join(".", plainBugIdList); SpriteData plainBugSpriteData = new SpriteData() { TileIndex = tileIndex, TextureAsset = plainBugTextureAsset, FrameHeight = 16, FrameWidth = 16 }; BugModel plainBugModel = new BugModel() { Name = bugName, Id = plainBugId, Description = plainBugDescription, Price = plainBugPrice, QuickItemDataString = plainBugQuickItemString, SpriteData = plainBugSpriteData }; if (BugCatchingMod.AllBugs.Find(b => b.FullId == plainBugModel.FullId) != null) { Log.debug("Found bug in AllBugs"); return(plainBugModel); } else { Log.debug("Adding bug to AllBugs"); BugCatchingMod.AllBugs.AddOrReplace(plainBugModel); return(plainBugModel); } }
public static Bug getBugFromCritterType(Critter critter) { var bug = new Bug(); BugModel data = createBugModelFromCritter(critter); bug = new Bug(data); return(bug); }
public bool checkCatch(Critter critter, Rectangle catchZone) { caughtBug = false; Log.info($"checking the critter {critter.GetHashCode().ToString()}"); if (critter.getBoundingBox(0, 0).Intersects(catchZone)) { BugModel bug = BugApi.createBugModelFromCritter(critter); if (bug.Rarity < netModel.maxRarity) { CaughtCritter = critter; caughtBug = true; Log.info($"Caught a bug {bug.Name}"); } else { Game1.addHUDMessage(new HUDMessage($"The {bug.Name} escaped your {this.Name}")); //check for bugHasItem } } return(caughtBug); }
public static BugModel findOrCreateBugModelFromId(string bugId) { BugModel bugModel = new BugModel(); try { bugModel = AllBugs.Find(bm => bugId == bm.FullId); Log.info("bugname _indb" + bugModel.Name.ToString()); return(bugModel); } catch { Log.info("Parsing Name to Create Bug: " + bugId); List <string> i = bugId.Split('.').ToList(); string tileIndex = i.Last(); string bugName = i[(i.IndexOf(tileIndex) - 1)]; Log.info("Parsed name: " + bugName + " tileIndex: " + tileIndex); bugModel = createPlainBugModel(bugName, tileIndex.toInt()); return(bugModel); } }
public void LoadCritters(object sender, UpdateTickedEventArgs e) { BugNetData data = _helper.Data.ReadJsonFile <BugNetData>("Assets/critters.json"); int Id = -666; AllCritters = new List <CritterEntry>(); Dictionary <int, string> AssetData = new Dictionary <int, string>(); foreach (CritterEntry critter in data.AllCritters) { AllCritters.AddOrReplace(critter); CritterEntry.Register(critter); var bugModel = new BugModel(); bugModel = critter.BugModel; //is this V necessary ? bugModel.ParentSheetIndex = Id; AllBugs.AddOrReplace(bugModel); CustomObjectData.newObject(bugModel.FullId, bugModel.SpriteData.getTexture(), Color.White, bugModel.Name, bugModel.Description, bugModel.SpriteData.TileIndex, price: bugModel.Price, customType: typeof(Bug)); //AssetData[bugData.sdvId] = bugModel.QuickItemDataString; Monitor.Log("Added: " + bugModel.Name + " id " + bugModel.FullId.ToString()); Id--; } foreach (NetModel netModel in data.AllNets) { AllNets.AddOrReplace(netModel); //net.ParentSheetIndex = Id; CustomObjectData.newBigObject(netModel.FullId, netModel.getTexture(), Color.White, netModel.Name, netModel.Description, netModel.TileIndex, netModel.Name, false, 0, false, false, "Crafting -9", 0, -300, new CraftingData(netModel.Name, netModel.Recipe), typeof(BugNetTool)); Log.info($"adding {netModel.FullId} with recipe {netModel.Recipe}"); //CustomObjectData.newObject($"{netModel.FullId}.Tool", new BugNetTool(netModel).loadTexture(), Color.White, netModel.Name, netModel.Description, netModel.TileIndex, "", "Net", 1, -300, craftingData: new CraftingData($"{netModel.FullId}.Tool", netModel.Recipe), customType: typeof(BugNetTool)); } //_helper.Data.WriteJsonFile("data\\bugs.json", AssetData); _helper.Events.GameLoop.UpdateTicked -= LoadCritters; }
public static BugModel createBugModelFromCritter(Critter critter) { string bugName = critter.GetType().ToString().Split('.').Last(); if (AllKnownClassifications.Contains(bugName)) { BugModel bugModel = new BugModel(); if (bugName == "Floater") { Floater f = (Floater)critter; bugModel = AllBugs.Find(b => b.FullId == f.data.BugModel.FullId); } else { CustomCritter c = (CustomCritter)critter; bugModel = AllBugs.Find(b => b.FullId == c.data.BugModel.FullId); } return(bugModel); } int TileIndex = Helper.Reflection.GetField <int>(critter, "baseFrame").GetValue(); return(createPlainBugModel(bugName, TileIndex)); }
public Bug(BugModel bugModel) { build(bugModel); }