private Field MapWalls(int column, int row, Field currentValue)
        {
            double distanceToMid = Math.Abs(column - ((Map.ColumnCount - 1) / 2f));
            double relativeMidDistance = 2 * distanceToMid / Map.ColumnCount;
            double wallProbability = (0.5 + Math.Cos(relativeMidDistance * Math.PI) / 2);
            if (Random.NextDouble() < wallProbability)
                return new DestructibleField(column, row);

            return currentValue;
        }
        private Field MapWallsToRare(int column, int row, Field currentValue)
        {
            if (currentValue.IsAccessible)
                return currentValue;

            double probabilityOfSpecialThing = 0.06;
            if (Random.NextDouble() < probabilityOfSpecialThing)
                return new SolidField(column, row); //just for demo - should be something rare / useful / cool instead

            return currentValue;
        }
Пример #3
0
 public PlainField(Field field)
     : base(field)
 {
 }
Пример #4
0
 public SolidField(Field field)
     : base(field)
 {
     IsAccessible = false;
 }
Пример #5
0
 public Field(Field field)
 {
     this.Position = field.Position;
     IsAccessible = true;
     IsDestructible = false;
 }
 private void WriteField(Field field)
 {
     if (field is PlainField)
         Writer.Write((byte)FieldType.Plain);
     else if (field is SolidField)
         Writer.Write((byte)FieldType.Solid);
     else if (field is DestructibleField)
         Writer.Write((byte)FieldType.Destructible);
 }
Пример #7
0
 public void replaceFieldAt(int column, int row, Field field)
 {
     Map.Fields[column, row] = field;
 }