示例#1
0
 private void SetInfo(int index)
 {
     nameText.text = RabbitSystem.GetRabbitNameById(index);
     ImageUtils.FittingImg(rabbitRT, rabbitImg, RabbitSystem.GetRabbitSpriteById(index), rabbitImgDefaultSize);
     Debug.Log(RabbitSystem.GetRabbitLoveCount());
     Debug.Log(RabbitSystem.maxLoveCount);
     ImageUtils.FittingImg(loveRT, loveImg, (RabbitSystem.GetRabbitLoveById(index) ? 已設最愛 : ((RabbitSystem.GetRabbitLoveCount() >= RabbitSystem.maxLoveCount) ? 最愛已滿 : 設為最愛)), loveImgDefaultSize);
     loveBtn.onClick.AddListener(delegate() { OnClickLove(index); });
     descText.text = RabbitSystem.GetRabbitDescById(index);
 }
示例#2
0
 static void OnRuntimeMethodLoad()
 {
     SystemVariables.CarrotCount  = 0;
     SystemVariables.waiguanValue = 1;
     SystemVariables.koganValue   = 1;
     SystemVariables.xianchiValue = 1;
     SystemVariables.classicValue = 1;
     //RabbitSystem.Reset();
     RabbitSystem.CalculateRabbitLoveCount();
 }
示例#3
0
 public void ResultConfirm()
 {
     ResultPanel.SetActive(false);
     rabbitChoices[chosenRabbitIndex].instance.transform.GetChild(3).gameObject.SetActive(false);
     CookingButton.interactable = false;
     if (success)
     {
         RabbitSystem.SetRabbitGotOrNot(rabbitChoices[chosenRabbitIndex].name, true);
         RabbitChoice rc = rabbitChoices[chosenRabbitIndex];
         rc.successRate = 100;
         rc.instance.transform.GetChild(1).gameObject.SetActive(true);
         rc.instance.transform.GetChild(2).gameObject.SetActive(false);
         rc.instance.transform.GetChild(1).GetComponent <Image>().sprite = rc.image;
         rabbitChoices[chosenRabbitIndex] = rc;
     }
     PageTransitionCanvas.SetActive(true);
 }
示例#4
0
    private void CheckChoices()
    {
        for (int i = 0; i < rabbitChoices.Count; i++)
        {
            if (rabbitChoices[i].successRate != 100)
            {
                RabbitChoice tempRC = rabbitChoices[i];
                tempRC.successRate = GetSuccessRate(RabbitSystem.GetDemands(rabbitChoices[i].name));
                if (tempRC.successRate != 0)
                {
                    tempRC.instance.transform.GetChild(1).gameObject.SetActive(false);
                    tempRC.instance.transform.GetChild(2).gameObject.SetActive(true);
                    tempRC.instance.transform.GetChild(2).GetComponent <Image>().sprite = 成功率Sprites[GetIndexOfSuccessRateSprite(tempRC.successRate)];
                }

                rabbitChoices[i] = tempRC;
            }
        }
    }
示例#5
0
    private void OnClickLove(int index)
    {
        if (RabbitSystem.GetRabbitLoveCount() >= RabbitSystem.maxLoveCount && !RabbitSystem.GetRabbitLoveById(index))
        {
            return;
        }
        Sprite sprite = null;

        if (RabbitSystem.GetRabbitLoveById(index))
        {
            sprite = 設為最愛;
            RabbitSystem.SetRabbitLoveById(index, false);
        }
        else
        {
            sprite = 已設最愛;
            RabbitSystem.SetRabbitLoveById(index, true);
        }
        ImageUtils.FittingImg(loveRT, loveImg, sprite, loveImgDefaultSize);
    }
示例#6
0
    private void SetPanel()
    {
        //Set RabbitPanel
        Transform Content = RabbitPanel.transform.GetChild(0).GetChild(0);

        for (int i = 0; i < RabbitSystem.GetRabbitListCount(); i++)
        {
            GameObject g   = Instantiate(elementPrefab, Content);
            Transform  img = g.transform.GetChild(0);
            bool       got = RabbitSystem.GetRabbitGotById(i);
            img.GetComponent <RectTransform>().sizeDelta = got ? new Vector2(80, 80) : new Vector2(未知兔子.texture.width, 未知兔子.texture.height);
            img.GetComponent <Image>().sprite            = got ? RabbitSystem.GetRabbitSpriteById(i) : 未知兔子;
            if (!got)
            {
                continue;
            }
            int tmpIndex = i;
            g.GetComponent <Button>().onClick.AddListener(delegate() { ClickRabbit(tmpIndex); });
        }

        //Set KeeperPanel
        Content = KeeperPanel.transform.GetChild(0).GetChild(0);
        for (int i = 0; i < HouseKeeperSystem.GetKeeperCount(); i++)
        {
            GameObject g   = Instantiate(elementPrefab, Content);
            Transform  img = g.transform.GetChild(0);
            bool       got = HouseKeeperSystem.GetGotByIndex(i);
            img.GetComponent <RectTransform>().sizeDelta = got ? new Vector2(80, 80) : new Vector2(未知管家.texture.width, 未知管家.texture.height);
            img.GetComponent <Image>().sprite            = got ? HouseKeeperSystem.GetSpriteByIndex(i) : 未知管家;
            if (!got)
            {
                continue;
            }
            int tmpIndex = i;
            g.GetComponent <Button>().onClick.AddListener(delegate() { ClickKeeper(tmpIndex); });
        }
    }
示例#7
0
    // Start is called before the first frame update
    void Start()
    {
        外觀Button = transform.GetChild(0).GetChild(0).GetChild(0).GetComponent <Button>();
        外觀lv     = 外觀Button.GetComponent <Image>();
        口感Button = transform.GetChild(0).GetChild(0).GetChild(1).GetComponent <Button>();
        口感lv     = 口感Button.GetComponent <Image>();
        香氣Button = transform.GetChild(0).GetChild(0).GetChild(2).GetComponent <Button>();
        香氣lv     = 香氣Button.GetComponent <Image>();
        經典Button = transform.GetChild(0).GetChild(0).GetChild(3).GetComponent <Button>();
        經典lv     = 經典Button.GetComponent <Image>();

        外觀lv.sprite = 外觀Sprites[SystemVariables.waiguanValue - 1].NotPress;
        ChangePressedSprite(ref 外觀Button, 外觀Sprites[SystemVariables.waiguanValue - 1].Pressed);
        口感lv.sprite = 口感Sprites[SystemVariables.koganValue - 1].NotPress;
        ChangePressedSprite(ref 口感Button, 口感Sprites[SystemVariables.koganValue - 1].Pressed);
        香氣lv.sprite = 香氣Sprites[SystemVariables.xianchiValue - 1].NotPress;
        ChangePressedSprite(ref 香氣Button, 香氣Sprites[SystemVariables.xianchiValue - 1].Pressed);
        經典lv.sprite = 經典Sprites[SystemVariables.classicValue - 1].NotPress;
        ChangePressedSprite(ref 經典Button, 經典Sprites[SystemVariables.classicValue - 1].Pressed);

        IncreasePanelAni = transform.GetChild(0).GetChild(4).GetComponent <Animator>();
        IPType           = IncreasePanelAni.transform.GetChild(0).GetComponent <Text>();
        IPCurrentLevel   = IncreasePanelAni.transform.GetChild(2).GetChild(1).GetComponent <Text>();
        IPNextLevel      = IncreasePanelAni.transform.GetChild(2).GetChild(2).GetComponent <Text>();
        IPPrice          = IncreasePanelAni.transform.GetChild(3).GetChild(1).GetComponent <Text>();
        IPPriceButton    = IncreasePanelAni.transform.GetChild(3).GetComponent <Button>();

        CloseDetect = transform.GetChild(0).GetChild(3).gameObject;
        CloseDetect.SetActive(false);
        CheckTypeButton();

        ChoiceContent = transform.GetChild(0).GetChild(2).GetChild(0).GetChild(0).gameObject;

        for (int i = 0; i < RabbitSystem.GetRabbitListCount(); i++)
        {
            RabbitChoice rc;
            GameObject   g = Instantiate(食譜Prefab, ChoiceContent.transform);
            g.transform.GetChild(2).GetComponent <Button>().onClick.AddListener(delegate() { SelectRecipe(g); });
            if (RabbitSystem.GetRabbitGotById(i))
            {
                g.transform.GetChild(2).gameObject.SetActive(false);
                g.transform.GetChild(1).gameObject.SetActive(true);
                g.transform.GetChild(1).GetComponent <Image>().sprite = RabbitSystem.GetRabbitSpriteById(i);
                rc.successRate = 100;
            }
            else
            {
                rc.successRate = GetSuccessRate(RabbitSystem.GetDemandsById(i));
                if (rc.successRate != 0)
                {
                    g.transform.GetChild(2).GetComponent <Image>().sprite = 成功率Sprites[GetIndexOfSuccessRateSprite(rc.successRate)];
                    g.transform.GetChild(1).gameObject.SetActive(false);
                    g.transform.GetChild(2).gameObject.SetActive(true);
                }
                else
                {
                    g.transform.GetChild(1).gameObject.SetActive(true);
                    g.transform.GetChild(2).gameObject.SetActive(false);
                    g.transform.GetChild(1).GetComponent <Image>().sprite = QuestionMark;
                }
            }
            g.transform.GetChild(3).gameObject.SetActive(false);
            rc.instance = g;
            rc.name     = RabbitSystem.GetRabbitNameById(i);
            rc.method   = RabbitSystem.GetRabbitMethodById(i);
            rc.image    = RabbitSystem.GetRabbitSpriteById(i);
            rc.got      = RabbitSystem.GetRabbitGotById(i);
            rabbitChoices.Add(rc);
        }
        CCRT           = ChoiceContent.GetComponent <RectTransform>();
        CCRT.offsetMin = new Vector2(CCRT.offsetMin.x, ((101 * Mathf.Ceil(rabbitChoices.Count / 3.0f) + 15) - 160) * -1);

        ResultPanel = transform.GetChild(1).gameObject;
        ResultPanel.SetActive(false);
        Refrigerator = transform.GetChild(1).GetChild(0).gameObject;
        Oven         = transform.GetChild(1).GetChild(1).gameObject;
        RabbitName   = transform.GetChild(1).GetChild(3).GetComponent <Text>();
        RabbitImage  = transform.GetChild(1).GetChild(4).GetComponent <Image>();

        CookingButton = transform.GetChild(0).GetChild(1).GetComponent <Button>();
        CookingButton.interactable = false;

        PageTransitionCanvas = FindObjectOfType <PageTransition>().gameObject;
        PageTransitionCanvas.SetActive(true);
    }