public override TaskResult Run(ITaskNode node) { Debug.LogFormat("LevelControl: {0}", this.Action); var level = Indexed.GetSingle <ILevelSystem>(); switch (this.Action) { case ControlKind.Pause: level.PauseLevel(); break; case ControlKind.Resume: level.ResumeLevel(); break; case ControlKind.Start: level.StartLevel(); break; case ControlKind.Stop: level.StopLevel(); break; case ControlKind.ResetState: level.ResetState(); break; default: throw new InvalidOperationException(string.Format("Unsupported {0} value {1}", typeof(ControlKind), this.Action)); } return(TaskResult.Success); }
public bool Set(Indexed X, object Value) { // First we need to figure out the key value in case of Option field type if (Options != null && Options.Length > 0) { bool done = false; foreach (var x in Options) { if (x.Item2 == (string)Value) { Value = x.Item1; done = true; break; } } if (!done) { return(false); } } if (Type == "int") { int t = 0; if (!int.TryParse((string)Value, out t)) { return(false); } // else Value = t; -- uncomment this to convert value to int type } X[Name] = Value; return(true); }
public void Return_TrueAndGetCorrectValue_WhenKeyDoesExist() { // Arrange object result; TestPerson person = this.fixture.Create <TestPerson>(); Mock <IFunkyFactory> factory = TestHelper.GetMockedFunkyFactory(); Indexed sut = new Indexed(person, true, factory.Object); // Act & Assert bool returnValue = sut.TryGetValue(nameof(TestPerson.Name), out result); Assert.IsTrue(returnValue); Assert.NotNull(result); string actualName = result as string; Assert.AreSame(person.Name, actualName); sut.TryGetValue(nameof(TestPerson.Age), out result); Assert.NotNull(result); int actualAge = (int)result; Assert.AreEqual(person.Age, actualAge); }
void Start() { if (this.system == null) { this.system = Indexed.GetSingle <IPotentialFieldSystem>(); } this.nodeSources = new PotentialFieldNodeSource[sourceConfigs.Length]; var maxAge = 0; for (int i = 0; i < this.sourceConfigs.Length; i++) { var conf = sourceConfigs[i]; this.nodeSources[i] = this.source.AddNodeSource(conf.sourceKey, conf.layers, conf.potential); this.nodeSources[i].Calculator = conf.calculator as IPotentialCalculator; this.nodeSources[i].Flow = conf.flow; this.nodeSources[i].Enabled = conf.enabled; maxAge = Mathf.Max(conf.age, maxAge); } this.nodeHistory = new IFieldNodeRef[maxAge + 1]; this.Spawned(); }
void Spawned() { if (this.system == null) { this.system = Indexed.GetSingle <IPotentialFieldSystem>(); } }
public override TaskResult Run(ITaskNode node) { var level = Indexed.GetSingle <ILevelSystem>(); level.Configure(level.LevelNumber + 1); return(TaskResult.Success); }
public override TaskResult Run(ITaskNode node) { var levelRating = Indexed.GetSingle <LevelRating>(); levelRating.Calculate(); return(TaskResult.Success); }
public void Indexed_ToString() { var i1 = new Indexed <string>("bar", 0); var i2 = new Indexed <string>("foo", 1); Assert.AreEqual("[0] bar", i1.ToString()); Assert.AreEqual("[1] foo", i2.ToString()); }
void OnDestroy() { var mindSys = Indexed.GetSingleOrDefault <IMindSystem>(); if (mindSys != null) { mindSys.Remove(this); } }
public override TaskResult Run(ITaskNode node) { var levelSchemaSys = Indexed.GetSingle <ILevelSchemaSystem>(); var builder = levelSchemaSys.Builders[Random.Range(0, levelSchemaSys.Builders.Length)]; var schema = builder.BuildSchema(0f); levelSchemaSys.AddSchema(schema); return(TaskResult.Success); }
public void Return_False_WhenDoesNotContainKey(string key) { // Arrange Indexed sut = new Indexed(new TestPerson(), true, TestHelper.GetMockedFunkyFactory().Object); // Act bool result = sut.ContainsKey(key); // Assert Assert.IsFalse(result); }
public bool GreaterThan(ref Indexed <T?> x, ref Indexed <T?> y) { int c = Compare(ref x, ref y); bool result = c > 0; if (c == 0) { result = x.Index > y.Index; } return(result); }
public bool LessThan(ref Indexed <T?> x, ref Indexed <T?> y) { int c = Compare(ref x, ref y); bool result = c < 0; if (c == 0) { result = x.Index < y.Index; } return(result); }
public override int GetHashCode() { var hashCode = -331517974; hashCode = hashCode * -1521134295 + ColorType.GetHashCode(); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Indexed ? Indexed.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Theme ? ThemeColor.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Theme ? ThemeTint.GetHashCode() : 0); hashCode = hashCode * -1521134295 + (ColorType == XLColorType.Color ? Color.ToArgb().GetHashCode() : 0); return(hashCode); }
public override TaskResult Run(ITaskNode node) { var levelSchemaSys = Indexed.GetSingle <ILevelSchemaSystem>(); var schema = levelSchemaSys.Schemas[levelSchemaSys.Schemas.Count - 1]; levelSchemaSys.SelectSchema(schema); levelSchemaSys.BuildLevel(); return(TaskResult.Success); }
public bool GreaterThan(ref Indexed <T> x, ref Indexed <T> y) { int c = impl.Compare(x.Value, y.Value); bool result = c > 0; if (c == 0) { result = x.Index > y.Index; } return(result); }
public void Return_CorrectValueFromFunc_WhenGenericMethod() { // Arrange TestPerson instance = this.fixture.Create <TestPerson>(); Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory(); Indexed sut = new Indexed(instance, true, factoryMock.Object); // Act & Assert Assert.AreSame(instance.Name, sut.Get <string>(nameof(TestPerson.Name))); Assert.AreEqual(instance.Age, sut.Get <int>(nameof(TestPerson.Age))); }
public bool LessThan(ref Indexed <T> x, ref Indexed <T> y) { int c = impl.Compare(x.Value, y.Value); bool result = c < 0; if (c == 0) { result = x.Index < y.Index; } return(result); }
private static void AssertNotEqual <T>(Indexed <T> first, Indexed <T> second) { Assert.IsFalse(first == second); Assert.IsFalse(second == first); Assert.IsTrue(first != second); Assert.IsTrue(second != first); Assert.IsFalse(first.Equals(second)); Assert.IsFalse(second.Equals(first)); Assert.IsFalse(object.Equals(first, second)); Assert.IsFalse(object.Equals(second, first)); Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode()); }
public object GetValue(TableDataBuilder builder, Indexed <Field> field, object[] row) { var fields = _scope._uniqueChildFields .GetOrAdd(builder, () => new Dictionary <object[], bool[]>(builder.RowMap.Comparer)) .GetOrAdd(row, () => new bool[row.Length]); var firstTimeInScope = !fields[field.Index]; fields[field.Index] = true; return(firstTimeInScope ? _value : null); }
public void Throw_MissingMethodException_WhenShouldThrowOnMissingIsTrueAndMethodNotFound_WhenMethod() { // Arrange TestPerson instance = this.fixture.Create <TestPerson>(); Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory(); Indexed sut = new Indexed(instance, true, factoryMock.Object); // Act & Assert MissingMethodException ex = Assert.Throws <MissingMethodException>(() => sut.Get(TestConst.InvalidPropertyName)); StringAssert.Contains(TestConst.InvalidPropertyName, ex.Message); }
public void Call_FactoryBuildGetSetFuncsMethodWithCorrectparamsOnce() { // Arrange TestPerson instance = this.fixture.Create <TestPerson>(); Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory(); // Act Indexed _ = new Indexed(instance, true, factoryMock.Object); // Assert factoryMock.Verify(x => x.GetPropertyAccessorFuncs(It.Is <Type>(t => t.FullName == typeof(TestPerson).FullName)), Times.Once); }
public void Cast_From_Indexed() { // Arrange TestPerson expected = TestHelper.GetTestPerson(); var sut = new Indexed <TestPerson>(expected, true, TestHelper.GetMockedFunkyFactory().Object); // Act var actual = (TestPerson)sut; // Assert Assert.AreSame(expected, actual); }
void Spawned() { if (this.PotentialField == null) { this.PotentialField = Indexed.GetSingle <IPotentialFieldSystem>(); } if (this.navigateOnStart && this.PotentialField != null) { // TODO: Consider moving this into Update() to handle the transform position being set after spawning. this.StartNavigating(); } }
public void Return_CorrectPublicInstancePropertyCount_() { // Arrange TestPerson testPerson = TestHelper.GetTestPerson(); int expected = typeof(TestPerson).GetProperties(BindingFlags.Public | BindingFlags.Instance).Length; var sut = new Indexed(testPerson, true, TestHelper.GetMockedFunkyFactory().Object); // Act int actual = sut.Count; // Assert Assert.AreEqual(expected, actual); }
public void NotThrow_MissingMethodException_WhenPropertyNotFoundAndThrowOnMissingIsFalse() { // Arrange TestPerson instance = new TestPerson(); string expectedName = this.fixture.Create <string>(); int expectedAge = this.fixture.Create <int>(); Mock <IFunkyFactory> factoryMock = TestHelper.GetMockedFunkyFactory(); Indexed sut = new Indexed(instance, false, factoryMock.Object); // Act & Assert Assert.DoesNotThrow(() => sut.Set <string>(TestConst.InvalidPropertyName, expectedName)); Assert.DoesNotThrow(() => sut.Set <int>(TestConst.InvalidPropertyName, expectedAge)); }
public void Return_CorrectValues() { // Arrange TestPerson testPerson = TestHelper.GetTestPerson(); var expected = typeof(TestPerson).GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(p => p.GetValue(testPerson)).ToList(); var sut = new Indexed(testPerson, true, TestHelper.GetMockedFunkyFactory().Object); // Act var actual = sut.Values; // Assert CollectionAssert.AreEquivalent(expected, actual); }
public override TaskResult Run(ITaskNode node) { var levelRating = Indexed.GetSingle <LevelRating>(); var unit = node.Context.GetGameObject().GetComponent <Unit>(); unit.strength.Configure(1f, levelRating.CalculateLinear(unit.strengthRating)); unit.strength.Value = unit.strength.Max; unit.health.Configure(0f, levelRating.CalculateLinear(unit.healthRating)); unit.health.Value = unit.health.Max; return(TaskResult.Success); }
public void Return_CorrectValueFromFunc_WhenAnonymousAndDynamic() { // Arrange dynamic instance = new { Name = this.fixture.Create <string>(), Age = this.fixture.Create <int>() }; Indexed sut = new Indexed(instance, true); // Act & Assert Assert.AreSame(instance.Name, sut.Get(nameof(instance.Name))); Assert.AreEqual(instance.Age, sut.Get(nameof(instance.Age))); }
public void Return_NotNullEnumerator() { // Arrange TestPerson person = this.fixture.Create <TestPerson>(); Mock <IFunkyFactory> funkyFactory = TestHelper.GetMockedFunkyFactory(); Indexed sut = new Indexed(person, true, funkyFactory.Object); // Act IEnumerator <KeyValuePair <string, object> > result = sut.GetEnumerator(); // Assert Assert.NotNull(result); }