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 static Transform GetInteractable(Departments dept) { if (dept == Departments.Start) { return(MathRand.Pick(instance.startPos)); } if (!IsDepartmentFunctional(dept)) { return(null); } if (!instance.intr.ContainsKey(dept)) { instance.intr.Add(dept, new List <Transform>()); } if (instance.intr[dept].Count == 0) { instance.intr[dept].AddRange(MathRand.ChooseSetDependent(depts[dept].interactablePosition.ToArray(), depts[dept].interactablePosition.Count)); } var interact = instance.intr[dept][0]; instance.intr[dept].RemoveAt(0); return(interact); }
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 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(); } }
// Use this for initialization void Start() { ao = SceneManager.LoadSceneAsync(nextSceneName); ao.allowSceneActivation = false; chosenTxt = MathRand.Pick(tips); StartCoroutine(LoadSceneActive()); }
void CustomerReturn(GameObject custObj) { Transform start = MathRand.Pick(startPos); instance.recurringCust.Remove(custObj); custObj.transform.position = start.position; custObj.transform.rotation = start.rotation; custObj.SetActive(true); custObj.GetComponent <Customer>().ChooseAction(); }
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); }
private string AssignCustomerName() { if (custNames == null) { TextAsset text; text = Resources.Load <TextAsset>(customerNameFile); if (text == null) { return("Customer " + RequestID()); } custNames = text.text.Split('\n'); MathRand.Shuffle(ref custNames); return(AssignCustomerName()); } else { return(custNames[nameCount++]); } }