Beispiel #1
0
    public void CraftEffectSpawnTest()
    {
        SetUpScene();

        GameObject obj1  = new GameObject("Object1");
        Item       item1 = obj1.AddComponent <Item>();

        GameObject obj2  = new GameObject("Object2");
        Item       item2 = obj2.AddComponent <Item>();

        obj2.transform.position = new Vector3(10, 10, 10);

        GameObject objToSpawn = new GameObject("objToSpawn");

        objToSpawn.AddComponent <Item>();

        CraftEffect craft = ScriptableObject.CreateInstance <CraftEffect>();

        craft.deleteItem1 = false;
        craft.deleteItem2 = false;
        craft.itemsToSpawn.Add(objToSpawn);

        craft.Execute(item1, item2);

        GameObject newObject = GameObject.Find(objToSpawn.name + "(Clone)");

        Assert.NotNull(newObject);

        ScriptableObject.DestroyImmediate(craft);
        CleanUpScene();
    }
Beispiel #2
0
    public void CraftEffectDestroyOtherOneTest()
    {
        SetUpScene();

        GameObject obj1  = new GameObject("Object1");
        Item       item1 = obj1.AddComponent <Item>();

        GameObject obj2  = new GameObject("Object2");
        Item       item2 = obj2.AddComponent <Item>();

        obj2.transform.position = new Vector3(10, 10, 10);

        GameObject objToSpawn = new GameObject("objToSpawn");

        objToSpawn.AddComponent <Item>();

        CraftEffect craft = ScriptableObject.CreateInstance <CraftEffect>();

        craft.deleteItem1 = false;
        craft.deleteItem2 = true;
        craft.itemsToSpawn.Add(objToSpawn);

        craft.Execute(item1, item2);

        Assert.IsTrue(item1.IsDestroyed() == false);
        Assert.IsTrue(item2.IsDestroyed());

        ScriptableObject.DestroyImmediate(craft);
        CleanUpScene();
    }