public void CreateGatherable(TmxObject thing, Vector2 pos) { if (thing.Type.Equals("tree")) { Tree anotherTree = new Tree(Tree.TreeType.kNormalTree); anotherTree.LoadContent("Art/tree", Content); anotherTree._Position = _TilemapManager.findTile(pos).tileCenter; anotherTree.Name = thing.Name; _GatherableListActive.Add(anotherTree); _GatherableListActive.Add(anotherTree); } else if (thing.Type.Equals("rock")) { Rock anotherRock = new Rock(Rock.RockType.kNormalRock); anotherRock.LoadContent("Art/" + thing.Type, Content); anotherRock._Position = _TilemapManager.findTile(pos).tileCenter; anotherRock.Name = thing.Name; _GatherableListActive.Add(anotherRock); _GatherableListActive.Add(anotherRock); } else if (thing.Type.Equals("FishingHole")) { FishingHole anotherFish = new FishingHole(FishingHole.FishingType.kNetType); anotherFish.LoadContent("Art/" + thing.Type, Content); anotherFish._Position = _TilemapManager.findTile(pos).tileCenter; anotherFish.Name = thing.Name; _GatherableListActive.Add(anotherFish); _GatherableListActive.Add(anotherFish); } }
private static void UpdateOtherLakeHolesPop(FishingHole myhole) { for (int i = 0; i < myholes.Count; i++) { if (myholes[i].reg == GameRegion.LakeRegion && myholes[i].GUID != myhole.GUID) { //we have a match myholes[i].curPop = myhole.curPop; myholes[i].lastupdated = myhole.lastupdated; } } }
private static void DecreaseFishPop(string GUID, GameRegion regionID, float curTime) { if (regionID == GameRegion.CoastalRegion) { return; } FishingHole hole = GetFishingHole(GUID, regionID, curTime); hole.curPop = Mathf.Max(0f, hole.curPop - 1); Debug.Log(Enum.GetName(typeof(GameRegion), regionID) + " pop update to" + hole.curPop); if (regionID == GameRegion.LakeRegion) { UpdateOtherLakeHolesPop(hole); } }
private static void SetupNewLakeHole(FishingHole myhole, float curTime) { //here we set up population and quality bool noOtherHoles = true; List <int> remainingholeQuals = new List <int> { 0, 1, 2, 3 }; List <int> foundholeQuals = new List <int>(); for (int i = 0; i < myholes.Count; i++) { if (myholes[i].reg == GameRegion.LakeRegion && myholes[i].GUID != myhole.GUID) { //we have a match myhole.curPop = myholes[i].curPop; myhole.lastupdated = myholes[i].lastupdated; foundholeQuals.Add((int)myholes[i].holeQual); noOtherHoles = false; } } Debug.Log("foundholeQuals" + Utils.SerializeObject(foundholeQuals)); for (int i = 0; i < foundholeQuals.Count; i++) { remainingholeQuals.Remove(foundholeQuals[i]); } Debug.Log("remainingholes" + Utils.SerializeObject(remainingholeQuals)); // if (noOtherHoles) { //first ever lake hole. myhole.curPop = settings.maxPops[mylookups[(int)GameRegion.LakeRegion]]; myhole.lastupdated = curTime; } int lookup = Mathf.FloorToInt(UnityEngine.Random.Range(0.0f, 0.99999999f) * ((float)remainingholeQuals.Count)); Debug.Log(" returning index:" + lookup + "which is :" + remainingholeQuals[lookup]); myhole.holeQual = remainingholeQuals[lookup]; }
private static FishingHole GetFishingHole(string GUID, GameRegion regionID, float curTime) { //if its in the list return it otherwise create a new one //Debug.Log("Locating hole: " + GUID); for (int i = 0; i < myholes.Count; i++) { // Debug.Log("Locating hole: " + GUID + " found hole:" + myholes[i].GUID); if (myholes[i].GUID == GUID) { //we have a match return(myholes[i]); } } //Create a new hole FishingHole newhole = new FishingHole(); newhole.baseChance = settings.baseCatchesPerHour[mylookups[(int)regionID]]; newhole.maxPop = settings.maxPops[mylookups[(int)regionID]]; newhole.repop = settings.repopRates[mylookups[(int)regionID]]; newhole.curPop = newhole.maxPop; newhole.GUID = GUID; newhole.lastupdated = -1; newhole.reg = regionID; newhole.holeQual = 1; if (regionID == GameRegion.LakeRegion) { //need a new holeQual SetupNewLakeHole(newhole, curTime); } myholes.Add(newhole); return(newhole); }
public static float getFishingFactor(GameRegion currentRegion, string GUID) { float curTime = GameManager.GetUniStorm().GetElapsedHours() / 24; float answer; //before fish factor look to reshuffle holes if (curTime > nextShuffle) { ShuffleLakeHoles(); float t = settings.daysBetweenLakeHoleQualityReshuffle; nextShuffle = curTime + UnityEngine.Random.Range((t - 0.33f * t), (t + 0.33f * t));; } FishingHole hole = GetFishingHole(GUID, currentRegion, curTime); if (currentRegion == GameRegion.CoastalRegion) { // any shoal is a goal treat hole.lastupdated as the next forecast, maxPop as shoalProb holeQual as ShoalQual if (curTime > hole.lastupdated) { float shoal = UnityEngine.Random.Range(0f, 1.0f); hole.curPop = (shoal < hole.maxPop) ? (1 / hole.maxPop) : 0; //this preserves a mean value of answer of 1. hole.lastupdated = curTime + UnityEngine.Random.Range((hole.repop - 0.33f * hole.repop) / 24f, (hole.repop + 0.33f * hole.repop) / 24f); //periods between 2 hours and 4 Debug.Log("rolled for new shoal:" + shoal + " shoal_thresh:" + hole.maxPop + " next roll in :" + ((hole.lastupdated - curTime) * 24f) + " hours"); } answer = hole.baseChance * glBaseCatchChanceMod * hole.curPop; Debug.Log(ggtime(curTime) + " coastal FISH factor:" + answer + " baseChance:" + hole.baseChance + ", shoal factor:" + hole.curPop + " globfactor:" + glBaseCatchChanceMod + " hours to next forecast:" + ggtime(hole.lastupdated) + ", GUID:" + hole.GUID); } else if (currentRegion == GameRegion.LakeRegion) { float r = hole.repop / 25f; //float oldpop = hole.curPop; hole.curPop = verhulstpopmodel(r, hole.maxPop, hole.curPop, curTime - hole.lastupdated); hole.lastupdated = curTime; float holeQual = settings.lakeHoleQuals[(int)hole.holeQual]; UpdateOtherLakeHolesPop(hole); answer = hole.baseChance * holeQual * glBaseCatchChanceMod * Mathf.Pow((hole.curPop / hole.maxPop), 0.5f); if (hole.curPop < 1) { answer = 0; } Debug.Log(ggtime(curTime) + " Lake FISH factor:" + answer + " baseChance:" + hole.baseChance + ", HoleQual factor:" + holeQual + " Pop Factor:" + Mathf.Pow((hole.curPop / hole.maxPop), 0.5f) + " globfactor:" + glBaseCatchChanceMod + " lastupdate:" + ggtime(hole.lastupdated) + ", GUID:" + hole.GUID); } else { float r = hole.repop / 25f; hole.curPop = verhulstpopmodel(r, hole.maxPop, hole.curPop, curTime - hole.lastupdated); hole.lastupdated = curTime; answer = hole.baseChance * Mathf.Pow((hole.curPop / hole.maxPop), 0.5f); if (hole.curPop < 1) { answer = 0; } Debug.Log(ggtime(curTime) + " Lake FISH factor:" + answer + " baseChance:" + hole.baseChance + " Pop Factor:" + Mathf.Pow((hole.curPop / hole.maxPop), 0.5f) + " globfactor:" + glBaseCatchChanceMod + " lastupdate:" + ggtime(hole.lastupdated) + ", GUID:" + hole.GUID); } return(answer); }
// Update is called once per frame void Update() { switch (fishingPhase) { //Put the hole in the world case FishingPhase.Placement: if (!placementIndicator.transform.gameObject.activeInHierarchy && !objectSpawner.transform.gameObject.activeInHierarchy) { fishingUI.PutMessage("Wait a few seconds until see the image on the ground and tap the screen to set the fishing hole"); placementIndicator.transform.gameObject.SetActive(true); objectSpawner.transform.gameObject.SetActive(true); } if (objectSpawner.isOnScene) { fishingHole = Setter.transform.GetChild(2).GetComponent <FishingHole>(); placementIndicator.transform.gameObject.SetActive(false); objectSpawner.transform.gameObject.SetActive(false); fishingUI.clearNotification(); fishingPhase = FishingPhase.Casting; } break; //Launch the hook case FishingPhase.Casting: if (!castingManager.gameObject.activeInHierarchy) { fishingUI.PutMessage("Throw the hook into the fishing hole, swipe the screen to cast"); castingManager.gameObject.SetActive(true); castingManager.Start(); } else if (castingManager.isOnTheHole) { activeHook = castingManager.activeHook; activeHook.GetComponent <SwipeDetector>().enabled = false; castingManager.gameObject.SetActive(false); fishingPhase = FishingPhase.Waiting; } break; //Wait case FishingPhase.Waiting: if (!waitingManager.gameObject.activeInHierarchy) { fishingUI.PutMessage("Wait a bit until the fish bites the hook"); waitingManager.gameObject.SetActive(true); waitingManager.Start(); } else if (waitingManager.fishOntheHook) { waitingManager.gameObject.SetActive(false); fishingPhase = FishingPhase.Reeling; } break; //Reeling case FishingPhase.Reeling: if (!reelingManager.gameObject.activeInHierarchy) { fishingUI.PutMessage("A FISH HAS BITTEN THE HOOK!!!!!"); reelingManager.gameObject.SetActive(true); reelingManager.Start(); fishingUI.LoadReelingElements(); } else { if (reelingManager.reelingState == ReelingState.Captured) { hookedFish = reelingManager.HookedFish; caugthFish = reelingManager.HookedFish; fishingUI.PutMessage("You have caugth a " + caugthFish.name); fishingUI.HideReelingElements(); reelingManager.gameObject.SetActive(false); fishingPhase = FishingPhase.Visualazing; } if (reelingManager.reelingState == ReelingState.FishHasGone) { fishingUI.PutMessage("Ups, your fish has escaped"); fishingUI.HideReelingElements(); fishingPhase = FishingPhase.Casting; reelingManager.gameObject.SetActive(false); } if (reelingManager.reelingState == ReelingState.BrokenLine) { fishingUI.PutMessage("Ups, the line is broken :c, waht a strong fish"); fishingUI.HideReelingElements(); fishingPhase = FishingPhase.Casting; reelingManager.gameObject.SetActive(false); } } break; //Visualazing case FishingPhase.Visualazing: if (!visualizingManager.gameObject.activeInHierarchy) { fishingUI.PutMessage("Stats"); visualizingManager.gameObject.SetActive(true); visualizingManager.Start(); fishingUI.LoadVisualizingElements(hookedFish); } if (visualizingManager.clicOnClose) { fishingUI.HideVisualizingElements(); Destroy(activeHook.gameObject); visualizingManager.gameObject.SetActive(false); fishingPhase = FishingPhase.Casting; } break; default: Debug.Log("No phase"); break; } }