override protected void CreateWheel() { wheel = Wheel.Create(name: "Wheel of Fate"); WheelBase weapons = Wheel.Create(name: "Weapons"); weapons.AddSlot(Wheel.Create(1, "Sword")); weapons.AddSubslot("Sword", Wheel.Create(1, "Epic Sword")); weapons.AddSubslot("Sword", Wheel.Create(5, "Rare Sword")); weapons.AddSubslot("Sword", Wheel.Create(15, "Common Sword")); weapons.AddSlot(Wheel.Create(1, "Halberd")); weapons.AddSubslot("Halberd", Wheel.Create(1, "Epic Halberd")); weapons.AddSubslot("Halberd", Wheel.Create(5, "Rare Halberd")); weapons.AddSubslot("Halberd", Wheel.Create(15, "Common Halberd")); weapons.AddSlot(Wheel.Create(1, "Bow")); weapons.AddSubslot("Bow", Wheel.Create(1, "Epic Bow")); weapons.AddSubslot("Bow", Wheel.Create(5, "Rare Bow")); weapons.AddSubslot("Bow", Wheel.Create(15, "Common Bow")); weapons.AddSlot(Wheel.Create(1, "Mace")); weapons.AddSubslot("Mace", Wheel.Create(1, "Epic Mace")); weapons.AddSubslot("Mace", Wheel.Create(5, "Rare Mace")); weapons.AddSubslot("Mace", Wheel.Create(15, "Common Mace")); WheelBase armors = Wheel.Create(name: "Armors"); armors.AddSlot(Wheel.Create(2, "Leggings")); armors.AddSlot(Wheel.Create(4, "Chestplate")); armors.AddSlot(Wheel.Create(1, "Shield")); armors.AddSlot(Wheel.Create(10, "Boots")); WheelBase powerups = Wheel.Create(name: "Powerups"); powerups.AddSlot(Wheel.Create(1, "Increased HP")); powerups.AddSubslot(0, Wheel.Create(1, "HP +100")); powerups.AddSubslot(0, Wheel.Create(9, "HP +25")); powerups.AddSubslot(0, Wheel.Create(40, "HP +10")); powerups.AddSlot(Wheel.Create(1, "Increased ATK")); powerups.AddSubslot(1, Wheel.Create(1, "ATK +1000")); powerups.AddSubslot(1, Wheel.Create(9, "ATK +400")); powerups.AddSubslot(1, Wheel.Create(40, "ATK +100")); powerups.AddSlot(Wheel.Create(1, "Increased DEX")); powerups.AddSubslot(2, Wheel.Create(1, "DEX +20")); powerups.AddSubslot(2, Wheel.Create(9, "DEX +6")); powerups.AddSubslot(2, Wheel.Create(40, "DEX +2")); wheel.AddSlot(weapons); wheel.AddSlot(armors); wheel.AddSlot(powerups); foreach (WheelRenderer renderer in wheelRenderers) { if (renderer) { renderer.SetWheel(wheel); } } }
public void AddSlot_NewSubslotOnMaxedOutWheelRoot_ShouldWorkFine() { WheelBase parentWheel = CreateDummyWheelWithDepth((int)Wheel.DEPTH_MAX); WheelBase childWheel = Wheel.Create(); Assert.IsTrue(parentWheel.AddSlot(childWheel)); }
public void AddSlot_AddMoreThanMaxDepth_ShouldThrowException() { int depth1 = UnityEngine.Random.Range(0, (int)Wheel.DEPTH_MAX); int depth2 = 1 + (int)Wheel.DEPTH_MAX - depth1; WheelBase parentWheel = CreateDummyWheelWithDepth(depth1, getLeaf: true); WheelBase childWheel = CreateDummyWheelWithDepth(depth2); Assert.Throws <Exceptions.MaxDepthReachedException>(() => parentWheel.AddSlot(childWheel)); }
public void AddSubslot_AddToSameTree_ShouldThrowException() { WheelBase wheel = Wheel.Create(); WheelBase subwheel1 = Wheel.Create(); WheelBase subwheel2 = Wheel.Create(); wheel.AddSlot(subwheel1); subwheel1.AddSlot(subwheel2); Assert.Throws <Exceptions.SameWheelException>(() => subwheel1.AddSubslot(0, wheel)); }
public void LeafSlots_ShouldOnlyContainLeafSlots() { WheelBase wheel = Wheel.Create(); wheel.AddSlot(Wheel.Create(name: "A")); wheel.AddSlot(Wheel.Create(name: "B")); wheel.AddSlot(Wheel.Create(name: "C")); wheel.AddSubslot("B", Wheel.Create(name: "D")); WheelBase eWheel = Wheel.Create(name: "E"); eWheel.AddSlot(Wheel.Create(name: "F")); eWheel.AddSlot(Wheel.Create(name: "G")); eWheel.AddSubslot("F", Wheel.Create(name: "H")); eWheel.AddSubslot("F", Wheel.Create(name: "I")); wheel.AddSlot(eWheel); string[] givenLeaves = { "A", "C", "D", "G", "H", "I" }; CollectionAssert.AreEquivalent(wheel.LeafNames, givenLeaves); }
private WheelBase CreateDummyWheelWithDepth(int depth, bool getLeaf = false) { WheelBase wheel = Wheel.Create(); WheelBase lastChild = wheel; for (int i = 0; i < depth; i++) { WheelBase newChild = Wheel.Create(); lastChild.AddSlot(newChild); lastChild = newChild; } if (getLeaf) { return(lastChild); } else { return(wheel); } }
override protected void CreateWheel() { wheel = Wheel.Create(name: "Lab Upgrade"); WheelBase telepod = Wheel.Create(name: "Telepod"); telepod.AddSlot(Wheel.Create(5, "Safety Locks")); telepod.AddSlot(Wheel.Create(3, "+1 Atomic Decimator")); telepod.AddSlot(Wheel.Create(3, "+1 Atomic Regenerator")); telepod.AddSlot(Wheel.Create(1, "+1 Telepod")); telepod.AddSlot(Wheel.Create(10, "Cabling")); telepod.AddSubslot("Cabling", Wheel.Create(50, "+1 Copper Cable")); telepod.AddSubslot("Cabling", Wheel.Create(10, "+1 Gold Cable")); telepod.AddSubslot("Cabling", Wheel.Create(1, "+1 Carbon Cable")); telepod.AddSlot(Wheel.Create(20, "Upgrades")); telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% UV Blocking")); telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% Insulation")); telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% Regen Speed")); WheelBase computer = Wheel.Create(name: "Computer"); computer.AddSlot(Wheel.Create(1, "Turbo CPU Add-on")); computer.AddSlot(Wheel.Create(5, "+64K Memory")); computer.AddSlot(Wheel.Create(3, "DNA Validator")); computer.AddSlot(Wheel.Create(10, "Insectoid DNA Filter")); computer.AddSlot(Wheel.Create(10, "Tissue Translator")); computer.AddSlot(Wheel.Create(10, "+1 Teleport Subject")); computer.AddSlot(Wheel.Create(10, "Voice Activation")); wheel.AddSlot(telepod); wheel.AddSlot(computer); foreach (WheelRenderer renderer in wheelRenderers) { if (renderer) { renderer.SetWheel(wheel); } } }
public void AddSubslot_ShouldNotAcceptItselfAsSubslot_ShouldThrowException() { WheelBase wheel = Wheel.Create(); Assert.Throws <Exceptions.SameWheelException>(() => wheel.AddSlot(wheel)); }