/// <summary> /// Adds a single AttributePool to the list of known AttributePools. /// </summary> /// <param name="attributePool">The factory.</param> public static void Add(AttributePool attributePool) { AttributePools.Add(attributePool.Name, attributePool); //var type = factory.GetType(); // FactoriesByType[type].Add(factory); OnAttributePoolAdded(attributePool); }
private static void OnAttributePoolRemoved(AttributePool AttributePool) { if (AttributePoolRemoved != null) { AttributePoolRemoved(AttributePool); } }
public void GivenAttributePool_ThenDisplayLimitProperly() { // arrange var actual = new AttributePool(); // act var results = actual.LimitDisplay(LimitType.Physical); // assert Assert.AreEqual("[Physical (0)]", results); }
private void HandleAttributePoolRemoved(AttributePool attributePool) { // Find the corresponding node and remove it. var node = tvData.Nodes.Find(attributePool.Name, true).FirstOrDefault(n => IsAttributePool(n.Parent)); Debug.Assert(node != null); node.Remove(); // See if this causes us any trouble. ScanForIssues(); }
private void HandleAttributePoolAdded(AttributePool pool) { // Find parent node (base type) and insert in it. var node = tvData.Nodes.Find(pool.GetType().AssemblyQualifiedName, true).FirstOrDefault(IsAttributePool); Debug.Assert(node != null); node.Nodes.Add(pool.Name, pool.Name).Tag = pool; // Validate that item pool. ScanForIssues(pool); }
public void GivenTypeNotPresent_ThenThrowIndexOutOfRangeException() { // arrange var actual = new AttributePool(); // act var results = actual.LimitValue(LimitType.None); // assert Assert.Fail("IndexOutOfRangeException should have been thrown."); }
void Start() { //Access attribute point pool, play button, and spin controls pool = GetComponent <AttributePool>(); playButton = transform.FindDeepChild("Play Button").GetComponent <Button>(); HPSpin = transform.Find("HP Spin").GetComponent <SpinControl>(); SpeedSpin = transform.Find("Speed Spin").GetComponent <SpinControl>(); PowerSpin = transform.Find("Power Spin").GetComponent <SpinControl>(); JumpSpin = transform.Find("Jump Spin").GetComponent <SpinControl>(); }
public void GivenAttributePresent_SetAndReturnValue() { // arrange var actual = new AttributePool(); // act actual[AttributeType.Body] = 12; var results = actual[AttributeType.Body]; // assert Assert.AreEqual(12, results); }
public void GivenAttributeValue_DisplayProperly() { // arrange var actual = new AttributePool(); // act actual[AttributeType.Body] = 12; var results = actual.Display(AttributeType.Body); // assert Assert.AreEqual("BOD (12)", results); }
/// <summary> /// Removes the specified item pool. /// </summary> /// <param name="AttributePool">The item pool.</param> public static void Remove(AttributePool AttributePool) { if (AttributePool == null || string.IsNullOrWhiteSpace(AttributePool.Name) || !AttributePools.ContainsKey(AttributePool.Name)) { return; } AttributePools.Remove(AttributePool.Name); AttributePoolFilenames.Remove(AttributePool); OnAttributePoolRemoved(AttributePool); }
/// <summary> /// Selects the attribute pool in our property grid if it exists, else selects /// nothing (clears property grid). /// </summary> /// <param name="pool">The pool.</param> /// <returns></returns> private bool SelectAttributePool(AttributePool pool) { // Deselect object first, to reset property selection in property grid. pgProperties.SelectedObject = null; // See if that item pool is known and select it if possible. if (pool != null) { pgProperties.SelectedObject = pool; tvData.SelectedNode = tvData.Nodes.Find(pool.Name, true).FirstOrDefault(n => IsAttributePool(n.Parent)); return(true); } return(false); }
public void GivenPhysicalAttributesAreNotEvenlyDivisibleByThree_ThenCalcOkAndRoundUp() { // arrange var actual = new AttributePool(); actual[AttributeType.Strength] = 4; actual[AttributeType.Body] = 3; actual[AttributeType.Reaction] = 2; // act var results = actual.LimitValue(LimitType.Physical); // assert Assert.AreEqual(5, results); }
public void GivenSocialAttributesAreNotEvenlyDivisibleByThree_ThenCalcOkAndRoundUp() { // arrange var actual = new AttributePool(); actual[AttributeType.Charisma] = 4; actual[AttributeType.Willpower] = 3; actual[AttributeType.Essence] = 2; // act var results = actual.LimitValue(LimitType.Social); // assert Assert.AreEqual(5, results); }
public void GivenMentalAttributesAreEvenlyDivisibleByThree_ThenCalcOkAndDoNotRoundUp() { // arrange var actual = new AttributePool(); actual[AttributeType.Logic] = 4; actual[AttributeType.Intuition] = 2; actual[AttributeType.Willpower] = 2; // act var results = actual.LimitValue(LimitType.Mental); // assert Assert.AreEqual(4, results); }
private void AddAttributePoolClick(object sender, EventArgs e) { if (_attributePoolDialog.ShowDialog(this) == DialogResult.OK) { var name = _attributePoolDialog.AttributePoolName; try { // Create a new instance. var instance = new AttributePool { Name = name }; // Register it. AttributePoolManager.Add(instance); // And select it. SelectAttributePool(instance); // Add undo command. PushUndo("add attribute pool", () => { if (MessageBox.Show(this, "Are you sure you wish to delete the attribute pool '" + instance.Name + "'?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { AttributePoolManager.Remove(instance); return(true); } return(false); }); } catch (Exception ex) { MessageBox.Show(this, "Failed creating new attribute pool:\n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void GivenEmptyConstructor_ThenInitializeCorrectly() { // arrange & act var results = new AttributePool(); // assert Assert.IsNotNull(results[AttributeType.Body]); Assert.IsNotNull(results[AttributeType.Agility]); Assert.IsNotNull(results[AttributeType.Reaction]); Assert.IsNotNull(results[AttributeType.Strength]); Assert.IsNotNull(results[AttributeType.Willpower]); Assert.IsNotNull(results[AttributeType.Logic]); Assert.IsNotNull(results[AttributeType.Intuition]); Assert.IsNotNull(results[AttributeType.Charisma]); Assert.IsNotNull(results[AttributeType.Edge]); Assert.IsNotNull(results[AttributeType.Essence]); Assert.IsNotNull(results[AttributeType.Magic]); Assert.IsNotNull(results.LimitValue(LimitType.Mental)); Assert.IsNotNull(results.LimitValue(LimitType.Physical)); Assert.IsNotNull(results.LimitValue(LimitType.Social)); }
/// <summary> /// Scans for issues for a specific attribute pool. /// </summary> /// <param name="pool">The pool.</param> public void ScanForIssues(AttributePool pool) { }
protected virtual void Awake() { baseMovement = GetComponent <BaseMovement>(); attributePool = GetComponentInChildren <AttributePool>(); }
private void Awake() { navMeshAgentController = GetComponent <NavMeshAgentController>(); attributePool = GetComponentInChildren <AttributePool>(); }