Example #1
0
    private IEnumerator ShowCard(Image img, Card card, decimal money, bool isLow)
    {
        for (int i = 0; i < 10; i++)
        {
            img.transform.localScale = new Vector3(Mathf.Abs(i - 5.0f) / 5.0f, 1, 1);
            if (i == 5)
            {
                img.sprite = GetCardSprite(card);
            }
            yield return(new WaitForSeconds(0.05f));
        }
        SessionData session = new SessionData()
        {
            sessionstart = GrdManager.GetEpochTime(),
            values       = new Dictionary <string, string>()
        };

        if (money > 0)
        {
            messageText.text = "YOU WIN:" + money;
        }
        else if (money < 0)
        {
            messageText.text = "YOU LOSE:" + money;
        }
        else
        {
            messageText.text = "DRAW";
        }
        session.values.Add("result", "[" + (isLow?"1":"0") + "," + currentCard.symbol.ToString() + "," + resultCard.symbol + "," + money.ToString() + "]");
        history.AddHistory(session);
        img.transform.localScale = new Vector3(1, 1, 1);
        AllowUI(true);
    }
Example #2
0
        private void RestoreHistoryPanel(NoahTask task, bool endOfTask = true)
        {
            DebugEvent(string.Format("Restoring {0} History", task.name));
            RhinoApp.InvokeOnUiThread(new Action(() =>
            {
                if (HistoryPanel == null)
                {
                    Panels.OpenPanel(HistoryPanel.PanelId);
                }

                HistoryPanel = Panels.GetPanel <HistoryPanel>(RhinoDoc.ActiveDoc);

                if (restoreHistory)
                {
                    if (task.history.Count > 0)
                    {
                        DebugEvent(string.Format("{0} Has {1} History", task.name, task.history.Count));
                        HistoryPanel.SetHistory(task.name, task.history);
                        restoreHistory = false;
                    }
                }
                else
                {
                    DebugEvent(string.Format("Pushing {0} History", task.name));
                    HistoryPanel.AddHistory(task.name, task.history.Last());
                }

                HistoryPanel.RestoreEvent -= HistoryPanel_RestoreEvent;
                HistoryPanel.RestoreEvent += HistoryPanel_RestoreEvent;

                HistoryPanel.StoreEvent -= HistoryPanel_StoreEvent;
                HistoryPanel.StoreEvent += HistoryPanel_StoreEvent;

                HistoryPanel.DeleteEvent -= HistoryPanel_DeleteEvent;
                HistoryPanel.DeleteEvent += HistoryPanel_DeleteEvent;
            }));
        }
Example #3
0
 private void InitialBoard()
 {
     button.SetActive(false);
     for (int i = 0; i < 9; i++)
     {
         GameObject btn = Instantiate(button, button.transform.parent);
         btn.SetActive(true);
         buttons[i] = btn;
         Text   text = btn.GetComponentInChildren <Text>();
         Button b    = btn.GetComponentInChildren <Button>();
         text.text = (i + 1).ToString();
         int number = i;
         b.onClick.AddListener(() =>
         {
             for (int j = 0; j < 9; j++)
             {
                 if (j != number)
                 {
                     buttons[j].GetComponent <Animator>().SetTrigger("Normal");
                 }
                 else
                 {
                     buttons[j].GetComponent <Animator>().SetTrigger("Select");
                 }
             }
             double bet = 0;
             double.TryParse(betInput.text, out bet);
             GrdManager.CallServerScript("testscript", "random9", new object[] { number + 1, bet }, (error, args) =>
             {
                 if (error == 0)
                 {
                     List <decimal> ls = args.GetData <List <decimal> >(); //random9 function Server return a array of number.
                     if (ls[0].ToString() == "0")
                     {
                         int randNumber      = (int)(ls[1]);
                         int yournumber      = (int)(ls[2]);
                         decimal money       = ls[3];
                         SessionData session = new SessionData()
                         {
                             sessionstart = GrdManager.GetEpochTime(),
                             values       = new Dictionary <string, string>()
                         };
                         session.values.Add("rand", ls[1].ToString() + "," + ls[2].ToString() + "," + ls[3].ToString());
                         if (money > 0)
                         {
                             statusText.text = "CONRATULATIONS! YOU WIN:" + money.ToString() + " GRD";
                             leaderBoard.ReloadLeaderBoard();
                         }
                         else
                         {
                             statusText.text = "NO LUCKY:" + money.ToString() + " GRD";
                         }
                         history.AddHistory(session);
                         buttons[randNumber - 1].GetComponent <Animator>().SetTrigger("Win");
                         UpdateMoney();
                     }
                     else
                     {
                         statusText.text = "Not success:" + ls[1].ToString();
                     }
                 }
                 else
                 {
                     statusText.text = "Errorcode:" + error + ",message:" + args.ErrorMessage;
                 }
             });
         });
     }
 }