/// <summary> /// Load existing nflavor water /// </summary> /// <param name="buffer"></param> public void Load(byte[] buffer) { try { using (BinaryReader b = new BinaryReader(new MemoryStream(buffer))) { var WaterCount = b.ReadInt32(); for (int i = 0; i < WaterCount; i++) { var water = new Water(); water.PointA.X = b.ReadSingle(); water.PointA.Y = b.ReadSingle(); water.PointA.Z = b.ReadSingle(); water.PointB.X = b.ReadSingle(); water.PointB.Y = b.ReadSingle(); water.PointB.Z = b.ReadSingle(); water.Center.X = b.ReadSingle(); water.Center.Y = b.ReadSingle(); water.Center.Z = b.ReadSingle(); water.UseReflect = b.ReadInt32(); water.WaterId = b.ReadInt32(); Waters.Add(water); } } XLog.WriteLine(Levels.Good, "Ok"); } catch (Exception exception) { Blank(); XLog.WriteLine(Levels.Error, "Failed"); XLog.WriteLine(Levels.Fatal, "NfwManager::Load<Exception> -> {0}", exception); } }
/// <summary> /// Add new prop /// </summary> /// <param name="location"></param> public void Add(PointF first, PointF last) { var water = new Water(); var center = _2DUtils.GetCenterPoint(first, last); water.PointA = new K3DPosition(first.X, first.Y, 0f); water.Center = new K3DPosition(center.X, center.Y, 0f); water.PointB = new K3DPosition(last.X, last.Y, 0f); Waters.Add(water); Added?.Invoke(this, water); }
public void Waters_Valid_NonEmpty() { Waters waters = new Waters(); Mock <Water> water = GetMockWater(); water.Setup(s => s.IsValid(ref It.Ref <ValidationCode> .IsAny)).Returns(true); waters.Add(water.Object); ValidationCode errorCode = ValidationCode.SUCCESS; // need to suppress the type check because moq uses a different type Assert.IsTrue(waters.IsValidRecordSet(ref errorCode, suppressTypeCheck: true)); }
public void Waters_Invalid_BadType() { Waters waters = new Waters(); Mock <Water> water = GetMockWater(); water.Setup(s => s.IsValid(ref It.Ref <ValidationCode> .IsAny)).Returns(true); waters.Add(water.Object); ValidationCode errorCode = ValidationCode.SUCCESS; // do not suppress type check. Since moq uses a different type anyway, // there is no need to test with a different IRecord type Assert.IsFalse(waters.IsValidRecordSet(ref errorCode, suppressTypeCheck: false)); }
private void Initialize(int[,] matrix) { Barriers = new List <Barrier>(); DammageableBarriers = new List <DammageableBarrier>(); EnemySpawns = new List <EnemySpawn>(); Configuration.Width = matrix.GetLength(1); Configuration.Height = matrix.GetLength(0); for (int i = 0; i < Configuration.Height; i++) { for (int j = 0; j < Configuration.Width; j++) { var item = DefineItem(matrix[i, j], i, j); if (item.Type == ItemType.Wall) { Barriers.Add((Barrier)item); } else if (item.Type == ItemType.DammageableWall) { DammageableBarriers.Add((DammageableBarrier)item); } else if (item.Type == ItemType.EnemySpawn) { EnemySpawns.Add((EnemySpawn)item); } else if (item.Type == ItemType.Enemy) { Enemies.Add((Enemy)item); } else if (item.Type == ItemType.Bonus) { Bonuses.Add((Bonus)item); } else if (item.Type == ItemType.Empty) { Empties.Add((Empty)item); } else if (item.Type == ItemType.Water) { Waters.Add((Water)item); } } } GenerateEnemies(); GenerateBonuses(); }