internal static GameEventSystems.Event RollEvent() { foreach (var ev in instance.events) { if (ev.guaranteed && ev.guaranteeOnDay == GameManager.Days) { ev.guaranteed = false; instance.eventToRun = ev; instance.clearEvent = false; Debug.Log("EventManager - Guaranteed Event " + ev.eventName + " on Day " + GameManager.Days); return(ev); } } foreach (var ev in instance.events) { print("EventManager: Rolling " + ev.eventName + ", Rollable:" + ev.rollable); if (!ev.rollable) { continue; } if (MathRand.WeightedPick(new float[] { ev.chance, 1 - ev.chance }) == 0) { instance.eventToRun = ev; instance.clearEvent = false; Debug.Log("EventManager - Rolled " + ev.eventName); return(ev); } } instance.clearEvent = true; Debug.Log("EventManager - Rolled Clear event"); return(null); }
public void ChooseAction() { Visits++; agent.speed = origSpd; GetComponent <MeshRenderer>().material.color = Color.white; finished = false; startPos = transform.position; float[] weight = new float[] { GameManager.IsDepartmentFunctional(Departments.Cashier) ? actionWeight[0] : 0, GameManager.IsDepartmentFunctional(Departments.CustService) ? actionWeight[1] : 0, actionWeight[2] }; if (MathRand.WeightedPick(weight) == 0) { GameDemand = (GameType)MarketManager.GetDemands(); StartCoroutine(GoShopping()); //Shopping } else if (MathRand.WeightedPick(weight) == 1) { StartCoroutine(GoWander()); //Wander } else if (MathRand.WeightedPick(weight) == 2 && GameManager.IsDepartmentFunctional(Departments.CustService)) { StartCoroutine(GoComplain()); //Complain } else { ChooseAction(); } }
IEnumerator SpawnTime() { while (true) { yield return(new WaitForSeconds(NetCustomerSpawnTime + Random.Range(NetCustomerSpawnTime * -0.1f, NetCustomerSpawnTime * 0.1f))); Transform start = MathRand.Pick(startPos); int choice = MathRand.WeightedPick(new float[] { recurringCust.Count, newCustomerRatio }); if (choice == 1) { Customer c = Instantiate(MathRand.Pick(customerObjects), start.position, start.rotation).GetComponent <Customer>(); if (mainMenuMode) { c.actionWeight = new float[] { 3, 6, 1 } } ; c.custName = AssignCustomerName(); } else { CustomerReturn(MathRand.Pick(recurringCust)); //else we return it } isSpawning = false; custCount++; break; } }
public static int GetDemands() { if (GameManager.isInDemoMode) { return(MathRand.WeightedPick(new float[] { 1, 1, 1 })); } List <float> demandList = new List <float>(); for (int i = 0; i < instance.gameNames.Count; i++) { demandList.Add(instance.demands[i].Evaluate(GameManager.Days)); } return(MathRand.WeightedPick(demandList)); //return MathRand.WeightedPick(instance.demandArr); }