Beispiel #1
0
    public override void Addlevel()
    {
        Debug.Log("Add level wajan");
        CookingItem item = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.cooking);

        Debug.Log("Add level Wajan Level : " + item.Level + ", Max Level : " + item.MaxLevel);
        if (GameManagement.Player.Money < item.Price || item.Level >= item.MaxLevel)
        {
            if (GameManagement.Player.Money < item.Price)
            {
                GameManagement.WarningText = "Not Enough Money To Upgrade";
            }
            else if (item.Level >= item.MaxLevel)
            {
                GameManagement.WarningText = "Already MAX Level";
            }
            return;
        }

        item.Level++;
        GameObject obj = GameManagement.ToolObjectParent.gameObject;

        GameManagement.Player.ReduceMoney(item.Price);
        foreach (Transform t in obj.transform)
        {
            ToolAction action = t.GetComponent <ToolAction>();
            if (action.UsageFor == Usage.cooking)
            {
                action.CheckUnlockStatus();
            }
        }
    }
Beispiel #2
0
    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";
        }
    }
Beispiel #3
0
    public static List <CookingItem> GetListToolFromCSV()
    {
        CSVReader          reader  = new CSVReader("config/Upgrade");
        List <CookingItem> gorengs = new List <CookingItem>();

        for (int y = 1; y < reader.getTotalRow; y++)
        {
            if (reader.getdata[0, y] != null)
            {
                CookingItem go = new CookingItem();
                go.ids   = reader.getdata[0, y];
                go._name = reader.getdata[1, y];
                Int32.TryParse(reader.getdata[2, y], out go._price);
                switch (reader.getdata[3, y])
                {
                case "cooking":
                    go._usage = Usage.cooking;
                    break;

                case "placement":
                    go._usage = Usage.placement;
                    break;

                default:
                    break;
                }
                Int32.TryParse(reader.getdata[4, y], out go._maxLevel);
                gorengs.Add(go);
            }
        }
        return(gorengs);
    }
    private void Awake()
    {
        _this          = this;
        _listGorengans = Gorengan.GetListGorenganFromCSV();
        _cookingItems  = CookingItem.GetListToolFromCSV();

        foreach (CookingItem c in _cookingItems)
        {
            Debug.Log("cooking item : " + c.ids);
        }
    }
Beispiel #5
0
    public void CheckUnlockStatus()
    {
        CookingItem item = GameManagement.CookingItems.Find(x => x.UsageTool == UsageFor);

        Debug.Log("check unlock name : " + name);
        if (item != null)
        {
            if (UnlockLevel > item.Level)
            {
                GetComponent <SpriteRenderer>().color = Color.black;
                //this.gameObject.SetActive(false);
            }
            else
            {
                GetComponent <SpriteRenderer>().color = Color.white;
                //this.gameObject.SetActive(true);
            }
        }
    }
Beispiel #6
0
    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();
        }
    }