private Gorengan GetRandomGorengan(List <Gorengan> gorengans) { float randomValue = Random.value; float sum_of_weight = 0; List <Gorengan> c_gorengan = gorengans; foreach (Gorengan gorengan in c_gorengan) { sum_of_weight += gorengan.RandomWeight; } randomValue = randomValue * sum_of_weight; Gorengan choosenGorengan = null; for (int i = 0; i < c_gorengan.Count; i++) { Gorengan gorengan = c_gorengan[i]; if (randomValue < gorengan.RandomWeight) { choosenGorengan = gorengan; break; } randomValue -= gorengan.RandomWeight; } return(choosenGorengan); }
public static void AddGorenganToWajan(Gorengan gorengan) { bool isAvailable = false; CookingItem item = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.cooking); foreach (Transform obj in GameManagement.ToolObjectParent.transform) { ToolAction tool_a = obj.GetComponent <ToolAction>(); if (item.Level >= tool_a.UnlockLevel && tool_a.UsageFor == Usage.cooking) { Wajan tool = tool_a.tool as Wajan; Debug.Log("wajan level : " + item.Level + ", requirement : " + tool_a.UnlockLevel + ", status empty : " + tool.Status()); if (tool != null && tool.Status() == FryingStatus.empty) { GameManagement.Player.ReduceMoney(gorengan.Cost); tool.Use(gorengan); isAvailable = true; break; } } } if (!isAvailable) { GameManagement.WarningText = "Wajan is Full"; } }
public void Finish() { _FryingStatus = FryingStatus.finish; t_time = 0f; Transform toolA = GameManagement.ToolObjectParent.transform; ToolAction t_empty = null; foreach (Transform t in toolA) { ToolAction ta = t.GetComponent <ToolAction>(); if (ta.UsageFor == Usage.placement) { if (t_empty == null && ta.tool.CheckGorengan() == null) { t_empty = ta; } if (ta.tool.CheckGorengan() != null && ta.tool.CheckGorengan().ids == _friyingGorengan.ids) { t_empty = ta; break; } } } if (t_empty != null) { t_empty.tool.AddGorengan(_friyingGorengan); } _FryingStatus = FryingStatus.empty; _friyingGorengan = null; }
public void SelectRecipe() { //Debug.Log(EventSystem.current.currentSelectedGameObject.name); Gorengan gorengan = GameManagement.Gorengans.Find(x => x.ids == buttonAction); GameManagement.ActiveGorengan = gorengan; }
public override void MinGorengan(int total) { this.total -= total; if (this.total == 0) { MonoBehaviour.Destroy(ChildGorengan); _gorengan = null; } ChildGorengan.transform.GetChild(0).Find("GorenganNumber").GetComponent <Text>().text = this.total.ToString(); }
private void Awake() { _this = this; _listGorengans = Gorengan.GetListGorenganFromCSV(); _cookingItems = CookingItem.GetListToolFromCSV(); foreach (CookingItem c in _cookingItems) { Debug.Log("cooking item : " + c.ids); } }
public override void OnObjectClick() { if (total > 0) { if (_gorengan != null) { _gorengan = null; } MonoBehaviour.Destroy(ChildGorengan); ChildGorengan = null; total = 0; } }
public void SelectRecipe() { //Debug.Log(EventSystem.current.currentSelectedGameObject.name); Gorengan gorengan = GameManagement.Gorengans.Find(x => x.ids == buttonAction); Player player = GameManagement.Player; if (gorengan != null && player.Money > gorengan.Cost) { Wajan.AddGorenganToWajan(gorengan); //GameManagement.Player.ReduceMoney(gorengan.Cost); --moved to wajan.cs supaya kalau wajannya penuh, duit ga kurang. } else if (gorengan != null && player.Money < gorengan.Cost) { GameManagement.WarningText = "Don't Have enough money to cook"; } }
public static List <Gorengan> GetListGorenganFromCSV() { CSVReader reader = new CSVReader("config/Gorengan"); List <Gorengan> gorengs = new List <Gorengan>(); for (int y = 1; y < reader.getTotalRow; y++) { if (reader.getdata[0, y] != null) { Gorengan go = new Gorengan(); go.ids = reader.getdata[0, y]; go._name = reader.getdata[1, y]; float.TryParse(reader.getdata[2, y], out go._cookingTime); Int32.TryParse(reader.getdata[3, y], out go._price); float.TryParse(reader.getdata[4, y], out go._randomWeight); Int32.TryParse(reader.getdata[5, y], out go._totalResult); Int32.TryParse(reader.getdata[8, y], out go._cost); gorengs.Add(go); } } return(gorengs); }
private List <Order> GetRandomOrder(int count) { List <Order> choosenGorengans = new List <Order>(); List <Gorengan> currentGorengans = GameManagement.Gorengans; Gorengan t_last_choosen_gorengan = null; for (int i = 0; i < count; i++) { if (t_last_choosen_gorengan != null) { currentGorengans = currentGorengans.FindAll(x => x.Name != t_last_choosen_gorengan.Name); } t_last_choosen_gorengan = GetRandomGorengan(currentGorengans); Order t_order = new Order(); t_order.item = t_last_choosen_gorengan; choosenGorengans.Add(t_order); } return(choosenGorengans); }
public override void AddGorengan(Gorengan gorengan) { CookingItem item = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.placement); ToolAction t_action = ThisObject.GetComponent <ToolAction>(); if (t_action != null && item != null) { if (item.Level < t_action.UnlockLevel) { // can't use wajan because level return; } if (_gorengan == null) { _gorengan = gorengan; GameObject g_object = GameManagement.GorenganObjectList.Find(x => x.name == gorengan.ids); ChildGorengan = MonoBehaviour.Instantiate(g_object, ThisObject.transform.position, ThisObject.transform.rotation, ThisObject.transform); ChildGorengan.transform.GetChild(0).Find("GorenganName").GetComponent <Text>().text = _gorengan.Name; } this.total += gorengan.TotalResult; ChildGorengan.transform.GetChild(0).Find("GorenganNumber").GetComponent <Text>().text = this.total.ToString(); } }
public Wajan(GameObject ThisObject) : base(ThisObject) { _friyingGorengan = null; }
public override void Use(Gorengan gorengan) { _FryingStatus = FryingStatus.frying; _friyingGorengan = gorengan; }
public static GameObject FindGorengan(Gorengan gorengan) { GameObject result = GameManagement.GorenganObjectList.Find(x => x.name == gorengan.ids); return(result); }
public Meja(GameObject Obj) : base(Obj) { _gorengan = null; total = 0; ChildGorengan = null; }
public virtual void AddGorengan(Gorengan gorengan) { }
public virtual void Use(Gorengan gorengan) { }