Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        private bool CheckCell(ItemType itemType, Point currentPoint)
        {
            var result = Barriers.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y));

            if (itemType != ItemType.Bullet)
            {
                var result2 = DammageableBarriers.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y));
                var result3 = Waters.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y));
                return(result == null && result2 == null && result3 == null);
            }
            return(result == null);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        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));
        }
Пример #5
0
        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));
        }
Пример #6
0
 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();
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Recipe"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="style">The style.</param>
        /// <param name="brewer">The brewer.</param>
        /// <param name="batchSize">Size of the batch.</param>
        /// <param name="boilSize">Size of the boil.</param>
        /// <param name="boilTime">The boil time.</param>
        /// <param name="hops">The hops.</param>
        /// <param name="fermentables">The fermentables.</param>
        /// <param name="miscs">The miscs.</param>
        /// <param name="yeasts">The yeasts.</param>
        /// <param name="waters">The waters.</param>
        /// <param name="mash">The mash.</param>
        /// <param name="name">The name.</param>
        /// <param name="version">The version.</param>
        public Recipe(
            RecipeType type,
            Style style,
            string brewer,
            double batchSize,
            double boilSize,
            double boilTime,
            Hops hops,
            Fermentables fermentables,
            Miscs miscs,
            Yeasts yeasts,
            Waters waters,
            Mash mash,
            string name,
            int version = Constants.DEFAULT_BEER_XML_VERSION) : base(name, version)
        {
            Validation.ValidateGreaterThanZero(batchSize);
            Validation.ValidateGreaterThanZero(boilSize);
            Validation.ValidateGreaterThanZero(boilTime);
            Validation.ValidateNotNull(style);
            Validation.ValidateNotNull(hops);
            Validation.ValidateNotNull(fermentables);
            Validation.ValidateNotNull(miscs);
            Validation.ValidateNotNull(yeasts);
            Validation.ValidateNotNull(waters);
            Validation.ValidateNotNull(mash);

            this.Type         = type;
            this.Style        = style;
            this.Brewer       = brewer;
            this.Batch_Size   = batchSize;
            this.Boil_Size    = boilSize;
            this.Boil_Time    = boilTime;
            this.Hops         = hops;
            this.Fermentables = fermentables;
            this.Miscs        = miscs;
            this.Yeasts       = yeasts;
            this.Waters       = waters;
            this.Mash         = mash;
        }
Пример #8
0
        /// <summary>
        /// Remove entry by index
        /// </summary>
        /// <param name="index"></param>
        public void Remove(int index)
        {
            Waters.RemoveAt(index);

            Removed?.Invoke(this, new EventArgs());
        }
Пример #9
0
        public void Waters_Valid_Empty()
        {
            Waters waters = new Waters();

            Assert.IsTrue(waters.IsValid());
        }
Пример #10
0
 // Adding, accessing of waters
 public void addWaters(Waters w)
 {
     waters.Add(w.Location, w);
 }