Example #1
0
 public void SetUIMessage(csMessage message)
 {
     if(message.Enable)
         message.Status = csMessageStatusEnum.Visible;
     
     messageQueue.Add(message);
 }
Example #2
0
    private IEnumerator Message(csMessage message)
    {
        float r = 0;
        float g = 0;
        float b = 0;

        if (enabled)
        {
            var messageTxt = messageUI.GetComponentInChildren<Text>();
            messageTxt.text = message.Message;

            if (message.Type == csMessageTypeEnum.Success)
            {
                r = 21.0f / 255.0f;
                g = 182.0f / 255.0f;
                b = 42.0f / 255.0f;
            }
            else if (message.Type == csMessageTypeEnum.Failure)
            {
                r = 255.0f / 255.0f;
                g = 0;
                b = 0;
            }

            messageTxt.color = new Color(r, g, b);

            if (message.Timeout > 0.0f)
            {
                yield return new WaitForSeconds(message.Timeout);
                if (message.Status == csMessageStatusEnum.Visible)
                {
                    message.Status = csMessageStatusEnum.Hidden;
                }
            }
        }
        else
        {
            messageUICanvas.alpha = 0;
        }
        messageUICanvas.interactable = false;
        messageUICanvas.blocksRaycasts = false;
    }
Example #3
0
	// Update is called once per frame
	void Update () 
    {
        if (messageQueue.Count > 0)
        {
            msg = (csMessage)messageQueue[0];

            if (msg.Status == csMessageStatusEnum.Visible)
                StartCoroutine(Message(msg));

            if (msg.Status == csMessageStatusEnum.Hidden && messageUICanvas.alpha > 0)
                messageUICanvas.alpha -= Time.deltaTime;

            if (msg.Status == csMessageStatusEnum.Hidden && messageUICanvas.alpha <= 0)
            {
                messageQueue.RemoveAt(0);
            }

            if (msg.Status == csMessageStatusEnum.Visible && messageUICanvas.alpha <= 1)
                messageUICanvas.alpha += Time.deltaTime;
        }
	}
Example #4
0
    public void FinalizeRecipe()
    {
        var inventory = sceneManager.FoodInventoryManager.Inventory;
        var foodRectTransform = new csRectTransformData()
        {
            AnchorMin = new Vector2(1, 1),
            AnchorMax = new Vector2(1, 1),
            Pivot = new Vector2(0.5f, 0.5f),
            AnchoredPosition = new Vector2(-400, -89),
            SizeDelta = new Vector2(120, 114)
        };
        inventory.Add(sceneManager.LoadItemInSelector(sceneManager.FoodSelectorUI, recipe.FinalResult, foodRectTransform));

        var msg = new csMessage()
        {
            Enable = true,
            Message = "YOU CREATED THE RECIPE!!",
            Status = csMessageStatusEnum.None,
            Timeout = 3.0f,
            Type = csMessageTypeEnum.Success
        };
        message.SetUIMessage(msg);

        sceneManager.ToggleStopCookingButton(false);
        sceneManager.CurrentRecipe.State = csRecipeStateEnum.Finished;
        sceneManager.ShowRecipeSelector();

        Reset();
    }
Example #5
0
    public void SetStepAsSucceded()
    {
        var step = steps[CurrentStep - 1];
        step.Succeded = true;

        var msg = new csMessage()
        {
            Enable = true,
            Message = "FASE " + CurrentStep + " COMPLETED!",
            Status = csMessageStatusEnum.Visible,
            Timeout = 3.0f,
            Type = csMessageTypeEnum.Success
        };
        message.SetUIMessage(msg);

        kagotchi.IncreaseSkill(csSkillEnum.Cooking);
    }
Example #6
0
    private void CookingTimeManagment()
    {

        CookingTime += MaxCooking / sceneManager.CurrentRecipe.Time;

        if (CookingTime < 0)
            CookingTime = 0;

        if (CookingTime >= MaxCooking)
            CookingTime = MaxCooking;

        if (CookingTime >= MaxCooking && sceneManager.CurrentRecipe.State != csRecipeStateEnum.Finished)
        {
            recipe.State = csRecipeStateEnum.Finished;
            var msg = new csMessage()
            {
                Enable = true,
                Message = "YOU BURNED THE FOOD!",
                Status = csMessageStatusEnum.Visible,
                Timeout = 3.0f,
                Type = csMessageTypeEnum.Failure
            };
            message.SetUIMessage(msg);
            sceneManager.ToggleStopCookingButton(false);
            sceneManager.ShowRecipeSelector();
            Reset();
        }

        if (CookingTime >= 90 && sceneManager.CurrentRecipe.State != csRecipeStateEnum.Finished)
        {
            sceneManager.HideCuttingBoard();
            sceneManager.ToggleStopCookingButton(true);
        }

        txtCookingTime.text = Mathf.Round(CookingTime).ToString() + "%";
        cookingTimeSlider.value = CookingTime;
    }
Example #7
0
    public void IncreaseSkill(csSkillEnum skillEnum)
    {
        var skill = GetSkill(skillEnum);

        var goal = skill.Max - skill.Value;

        var rand = UnityEngine.Random.Range(skill.Min, skill.Max);

        if (rand <= goal)
            skill.Value += skill.Factor;


        var msg = new csMessage()
        {
            Enable = true,
            Message = "The " + skill.Name + " skill increased " + skill.Factor + "% it's now " + skill.Value + "%!",
            Status = csMessageStatusEnum.Visible,
            Timeout = 3.0f,
            Type = csMessageTypeEnum.Success
        };
        message.SetUIMessage(msg);
    }