Esempio n. 1
0
    public IEnumerator TakesTest2()
    {
        SceneManager.LoadScene("Game");
        yield return(null);

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player create 2 'Gold'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player puts 2 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen create 2 'Silver'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen puts 2 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player takes 1 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player takes 1 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen takes 1 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen takes 1 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player puts 1 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player puts 1 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen puts 1 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen puts 1 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player takes 2 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen takes 2 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject   barFront = GameObject.Find("Bar Front");
        PixelStorage storage  = barFront.GetComponent <PixelStorage>();

        Assert.False(storage.HasObject("Gold", 1));
        Assert.False(storage.HasObject("Silver", 1));
    }
Esempio n. 2
0
    public IEnumerator TakesTest1()
    {
        yield return(PutTest1());

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "player takes 4 'Gold' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject   barFront = GameObject.Find("Bar Front");
        PixelStorage storage  = barFront.GetComponent <PixelStorage>();

        Assert.False(storage.HasObject("Gold", 4));
    }
Esempio n. 3
0
    public IEnumerator PutTest2()
    {
        SceneManager.LoadScene("Game");
        yield return(null);

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen create 4 'Silver'");
        yield return(new WaitForSeconds(1.0f));

        GameObject.Find("Game Manager").SendMessage("AddGameTask", "hamen puts 4 'Silver' 'Inn Floor 1 Room 1' 'Bar Front'");
        yield return(new WaitForSeconds(10.0f));

        GameObject   barFront = GameObject.Find("Bar Front");
        PixelStorage storage  = barFront.GetComponent <PixelStorage>();

        Assert.True(storage.HasObject("Silver", 4));
    }
Esempio n. 4
0
        public void Takes(int number, string item, PixelStorage pixelStorage)
        {
            CharacterInventory inv = GetComponentInChildren <CharacterInventory>();

            Debug.Assert(inv != null);

            bool hasItem = pixelStorage.HasObject(item, number);

            if (!hasItem)
            {
                Debug.LogWarning(pixelStorage.name + " does not have " + number + " " + item);
                return;
            }

            Debug.Assert(number >= 1 && number <= 24);
            for (int i = 0; i < number; ++i)
            {
                GameObject obj = pixelStorage.TakeObject(item);
                if (obj == null)
                {
                    break;
                }
                PixelItem pixelItem = obj.GetComponent <PixelItem>();
                Debug.Assert(pixelItem != null);

                bool succeed = inv.AddItem(pixelItem);

                if (succeed)
                {
                    //animator.SetTrigger(Animator.StringToHash("IsPickup"));
                    pixelItem.gameObject.SetActive(false);
                    pixelItem.transform.parent = inv.transform;
                }
            }

            animator.SetTrigger(Animator.StringToHash("IsInteract"));
        }