示例#1
0
    public void AnswerClick(int i) // 1, 2, or 3
    {
        UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();

        uslb.LogToDatabase("Player selects mayor option --> " + GameObject.Find("AnswerText" + i).GetComponent <Text>().text, UserSessionLoggerBehavior.UserAction.LeftClickButton);

        ct = ct.NextTrees[i - 1];
        if (ct == null || ct.SpeakerText == null)
        {
            SceneManager.LoadScene("city_hall_3");
            return;
        }

        Debug.Log("SpeakerText = " + ct.SpeakerText);
        while (ct.SpeakerText[0] == '/')
        {
            Debug.Log("SpeakerText = " + ct.SpeakerText);
            //SE -- SEND EVENT
            string s = ct.SpeakerText.Substring(4);
            GameObject.Find("CampaignManager").GetComponent <CampaignManager>().CheckEvent(new SpeakEvent(SpeakerType.Mayor, 1, s));
            ct = ct.NextTrees[0];

            if (ct == null || ct.SpeakerText == null)
            {
                SceneManager.LoadScene("city_hall_3");
                return;
            }
        }

        UpdateDialogue();
    }
示例#2
0
    public void Quit()
    {
        UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();

        uslb.LogToDatabase("Player quit game", UserSessionLoggerBehavior.UserAction.SceneChange);
#if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
#else
        Application.Quit();
#endif
    }
示例#3
0
    public void Load(string level)
    {
        string name = SceneManager.GetActiveScene().name;
        UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();
        string newLevel = level;

        if (level == "city_hall_3")
        {
            newLevel = "City Hall";
        }
        uslb.LogToDatabase("Player enters " + ToTitleCase(newLevel), UserSessionLoggerBehavior.UserAction.SceneChange);
        SceneManager.LoadScene(level);
    }
示例#4
0
    public void AnswerClick(int i) // 1, 2, or 3
    {
        UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();

        uslb.LogToDatabase("Player selects shop option --> " + GameObject.Find("AnswerText" + i).GetComponent <Text>().text, UserSessionLoggerBehavior.UserAction.LeftClickButton);
        ct = ct.NextTrees[i - 1];
        if (ct == null || ct.SpeakerText == null)
        {
            SceneManager.LoadScene("city_hall_3");
            return;
        }

        while (ct.SpeakerText[0] == '/')
        {
            if (ct.SpeakerText[1] == 'O' && ct.SpeakerText[2] == 'G')
            {
                //OG -- OPEN GUI
                if (ct.SpeakerText.Substring(4) == "ShopGUI")
                {
                    Transact();
                    return;
                }
            }
            else
            {
                //SE -- SEND EVENT
                Debug.Log("SpeakerText = " + ct.SpeakerText);
                //SE -- SEND EVENT
                string s = ct.SpeakerText.Substring(4);
                GameObject.Find("CampaignManager").GetComponent <CampaignManager>().CheckEvent(new SpeakEvent(SpeakerType.ShopKeeper, 1, s));

                try
                {
                    ct = ct.NextTrees[0];
                }
                catch (System.IndexOutOfRangeException x)
                {
                    //...
                }

                if (ct == null || ct.SpeakerText == null)
                {
                    SceneManager.LoadScene("city_hall_3");
                    return;
                }
            }
        }

        UpdateDialogue();
    }
示例#5
0
    public void CancelTransaction()
    {
        UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();

        uslb.LogToDatabase("Player cancels transaction", UserSessionLoggerBehavior.UserAction.LeftClickButton);
        buyOrSell = false;
        //back1.SetActive(true);
        //back2.SetActive(false);
        shop_dialogue.SetActive(true);
        shop_gui.SetActive(false);

        cost   = 0;
        refund = 0;

        ct = GameObject.Find("CampaignManager").GetComponent <CampaignManager>().GetConversation(SpeakerType.ShopKeeper, 1);
        UpdateDialogue();
    }
示例#6
0
    public void AcceptTransaction()
    {
        int money = ((Item)backpack[4]).quantity;

        Debug.Log("Money = " + money);
        if (cost <= money + refund)
        {
            UserSessionLoggerBehavior uslb = GameObject.Find("UserSessionLogger").GetComponent <UserSessionLoggerBehavior>();

            for (int i = 0; i < len; i++)
            {
                b.Use(i, sellQuantities[i]);
                storeStock[i] += sellQuantities[i];

                if (sellQuantities[i] > 0)
                {
                    //uslb.LogToDatabase("Player sells " + b.LookupItemName(i) + "*" + sellQuantities[i], );
                }
            }

            for (int i = 0; i < len; i++)
            {
                b.Pickup(i, buyQuantities[i]);
                storeStock[i] -= buyQuantities[i];

                if (buyQuantities[i] > 0)
                {
                    //uslb.LogToDatabase("Player buys " + b.LookupItemName(i) + "*" + buyQuantities[i]);
                }
            }

            money += refund;
            money -= cost;
            GameObject.Find("MoneyAmount").GetComponent <Text>().text = money.ToString();
            ((Item)backpack[4]).quantity = money;

            ClearTransaction();
        }
        else
        {
            //CAN'T DO TRANSACTION
        }
    }