public void EffectSpawnItemTest() { SetUpScene(); GameObject interacteeObj = new GameObject("interactee"); Item target = interacteeObj.AddComponent <Item>(); interacteeObj.transform.position = new Vector3(10, 10, 10); GameObject objToClone = new GameObject("ObjectToBeClone"); objToClone.AddComponent <Item>(); EffectSpawnItem spawn = ScriptableObject.CreateInstance <EffectSpawnItem>(); spawn.itemToSpawn = objToClone; spawn.Execute(null, target); GameObject cloned = GameObject.Find("ObjectToBeClone(Clone)"); Assert.NotNull(cloned); Assert.IsTrue(interacteeObj.transform.position == cloned.transform.position); ScriptableObject.DestroyImmediate(spawn); CleanUpScene(); }
public void CombinationTriggersEffect() { SetUpScene(); ItemValidator item1Val = ScriptableObject.CreateInstance <ItemValidator>(); item1Val.name = "Item1"; ItemValidator item2Val = ScriptableObject.CreateInstance <ItemValidator>(); item2Val.name = "Item2"; GameObject obj1 = new GameObject("Item1"); Item item1 = obj1.AddComponent <Item>(); GameObject obj2 = new GameObject("Item2"); Item item2 = obj2.AddComponent <Item>(); GameObject objToSpawn = new GameObject("objToSpawn"); objToSpawn.AddComponent <Item>(); EffectSpawnItem spawn = ScriptableObject.CreateInstance <EffectSpawnItem>(); spawn.itemToSpawn = objToSpawn; Combination comb = ScriptableObject.CreateInstance <Combination>(); comb.itemValidator1 = item1Val; comb.itemValidator2 = item2Val; comb.effect = spawn; comb.Execute(item1, item2); GameObject newObject = GameObject.Find(objToSpawn.name + "(Clone)"); Assert.NotNull(newObject); ScriptableObject.DestroyImmediate(comb); ScriptableObject.DestroyImmediate(spawn); ScriptableObject.DestroyImmediate(item1Val); ScriptableObject.DestroyImmediate(item2Val); CleanUpScene(); }
public void EffectMultipleEffectTest() { SetUpScene(); GameObject objToClone = new GameObject("ObjectToBeClone"); Item item = objToClone.AddComponent <Item>(); EffectSpawnItem spawn = ScriptableObject.CreateInstance <EffectSpawnItem>(); spawn.itemToSpawn = objToClone; EffectMultipleEffects multi = ScriptableObject.CreateInstance <EffectMultipleEffects>(); multi.effects.Add(spawn); multi.effects.Add(spawn); multi.Execute(null, item); Item[] cloned = GameObject.FindObjectsOfType <Item>(); Assert.IsTrue(cloned.Length == multi.effects.Count + 1); ScriptableObject.DestroyImmediate(spawn); ScriptableObject.DestroyImmediate(multi); CleanUpScene(); }