public Hook UnhookWeightBlock(WeightBlock weightBlock) { _mainBalance.RemoveWeight(weightBlock.Mass * _hookCoefficient); _weightBlocks.Remove(weightBlock); UpdateWeightBlocksRotationInHook(); return(null); }
public void CreateDefaultBlock(float weightValue, int unitValue, Vector3 weightBlockPosition) { GameController.Singleton.PlayClickSound(); weightBlockPosition.z = 2.148f; var weightBlockPrefabIndex = 0; if (weightValue > 0) { if (weightValue <= 1) { weightBlockPrefabIndex = 0; } else { weightBlockPrefabIndex = Mathf.Min(3, (int)weightValue - 1); } } else { weightBlockPrefabIndex = 4; } WeightBlock newWeightBlock = Instantiate(_weightBlockPrefab[weightBlockPrefabIndex], weightBlockPosition, Quaternion.Euler(-6.378f, 0, 0)).GetComponent <WeightBlock>(); _blocks.Add(newWeightBlock); newWeightBlock.SetBlock(weightValue, unitValue); }
public Hook HookWeightBlock(WeightBlock weightBlock) { _weightBlocks.Add(weightBlock); _mainBalance.AddWeight(weightBlock.Mass * _hookCoefficient); UpdateWeightBlocksRotationInHook(); return(this); }
public void SumOfAbsoluteWeightsDefaultsToZero() { var reader = new BufferedReader( "= {}" ); var weightBlock = new WeightBlock(reader); Assert.Equal((uint)0, weightBlock.SumOfAbsoluteWeights); }
public void GetMatchingObjectReturnsNullWhenObjectsMapIsEmpty() { var reader = new BufferedReader( "= {}" ); var weightBlock = new WeightBlock(reader); Assert.Null(weightBlock.GetMatchingObject(0.345)); }
public void GetMatchingObjectThrowsErrorOnArgumentGreaterThan1() { var reader = new BufferedReader( "= {\n" + "\t2 = female_hair_greek_2\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Throws <ArgumentOutOfRangeException>(() => weightBlock.GetMatchingObject(1.234)); }
public void GetMatchingObjectThrowsErrorOnNegativeArgument() { var reader = new BufferedReader( "=\n" + "{\n" + "\t2 = female_hair_greek_2\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Throws <ArgumentOutOfRangeException>(() => weightBlock.GetMatchingObject(-0.5)); }
public void ObjectsCanBeAddedByMethod() { var weightBlock = new WeightBlock(); weightBlock.AddObject("new_object", 69); weightBlock.AddObject("new_object2", 5); Assert.Equal((uint)69, weightBlock.GetAbsoluteWeight("new_object")); Assert.Equal((uint)5, weightBlock.GetAbsoluteWeight("new_object2")); Assert.Equal((uint)74, weightBlock.SumOfAbsoluteWeights); Assert.Equal("new_object", weightBlock.GetMatchingObject(0)); Assert.Equal("new_object2", weightBlock.GetMatchingObject(0.95)); }
public void ObjectsCanBeAdded() { var reader = new BufferedReader( "= {\n" + "\t5 = female_hair_greek_1\n" + "\t2 = female_hair_greek_2\n" + "\t6 = female_hair_greek_3\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Equal((uint)5, weightBlock.GetAbsoluteWeight("female_hair_greek_1")); Assert.Equal((uint)2, weightBlock.GetAbsoluteWeight("female_hair_greek_2")); Assert.Equal((uint)6, weightBlock.GetAbsoluteWeight("female_hair_greek_3")); Assert.Equal((uint)13, weightBlock.SumOfAbsoluteWeights); Assert.Equal("female_hair_greek_1", weightBlock.GetMatchingObject(0.37234234)); Assert.Equal("female_hair_greek_2", weightBlock.GetMatchingObject(0.52234234234)); Assert.Equal("female_hair_greek_3", weightBlock.GetMatchingObject(1)); }
public Hook CheckHookCollision(WeightBlock weightBlock) { if (weightBlock.Mass > 0) { for (int i = 0; i < _hooks.Length / 2; i++) { if (Vector3.Distance(_hooks[i].transform.position, weightBlock.transform.position) <= _minDistanceToHookCollision) { return(_hooks[i].HookWeightBlock(weightBlock)); } } } else { for (int i = _hooks.Length / 2; i < _hooks.Length; i++) { if (Vector3.Distance(_hooks[i].transform.position, weightBlock.transform.position) <= _minDistanceToHookCollision) { return(_hooks[i].HookWeightBlock(weightBlock)); } } } return(null); }
public void RemoveWeightBlockReferenceFromGame(WeightBlock weightBlock) { _blocks.Remove(weightBlock); }