Exemple #1
0
 void IWallObserver.NotifyWallTypeChanged(IWall wall)
 {
     foreach (IWallObserver observer in wallObservers)
     {
         observer.NotifyWallTypeChanged(wall);
     }
 }
Exemple #2
0
        private void GameStart()
        {
            // fillingPattern = new BasicPattern();
            fillingPattern = new ZigZagPattern();
            wallOfBricks   = new Wall(4, PlaygroundWidth, fillingPattern);

            DrawPaddle();
            wallOfBricks.DrawWall();
            DrawBall();
            Console.Write("\b \b");

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo pressedKey = Console.ReadKey();
                    ChangePaddlePosition(pressedKey);
                }

                DrawPaddle();
                this.ChangeBallPosition();
                DrawBall();
                wallOfBricks.UpdateWall(previousBallPositionX, previousBallPositionY);
                Thread.Sleep(gameSpeed);
            }
        }
        public void FillWall(IWall wall)
        {
            Console.SetCursorPosition(0, 1);
            int counter = 0;

            for (int row = 0; row < wall.Height; row++)
            {
                for (int column = 0; column < wall.Width; column++)
                {
                    if (column <= 1 || column >= wall.Width - 2 || row == 0 || row == wall.Height - 1)
                    {
                        wall.FilledWall[row, column] = new Brick(row, column, false);
                    }
                    else
                    {
                        wall.FilledWall[row, column] = new Brick(row, column, true);
                    }

                    if (counter % 2 == 0 ||
                        (row == wall.Height - 1 && column == 0) ||
                        (row == wall.Height - 1 && column == wall.Width - 1))
                    {
                        wall.FilledWall[row, column].setInvisible();
                    }

                    counter++;
                }
            }
        }
Exemple #4
0
 public User(string userHandle, IWall wall)
 {
     this.wall              = wall;
     this.UserHandle        = userHandle;
     this.internalFollowers = new List <IUser>();
     this.internalFollowees = new List <IUser>();
 }
Exemple #5
0
        private void DrawWall()
        {
            if (this.LastWall == null)
            {
                this.Wall.Draw();
            }
            else
            {
                double a = this.WallChangeNumer * 1.0 / this.WallChangeDenom;

                this.LastWall.Draw();

                using (this.WallScreen.Section())
                {
                    this.Wall.Draw();
                }

                DDDraw.SetAlpha(a);
                DDDraw.DrawSimple(this.WallScreen.ToPicture(), 0, 0);
                DDDraw.Reset();

                this.WallChangeNumer++;

                if (this.WallChangeDenom <= this.WallChangeNumer)
                {
                    this.LastWall        = null;
                    this.WallChangeNumer = -1;
                    this.WallChangeDenom = -1;
                }
            }
        }
Exemple #6
0
 public User(string userHandle, IWall wall)
 {
     this.wall = wall;
     this.UserHandle = userHandle;
     this.internalFollowers = new List<IUser>();
     this.internalFollowees = new List<IUser>();
 }
Exemple #7
0
 public House(IDoor door, IWindow window, IRoof roof, IWall wall)
 {
     _door   = door;
     _window = window;
     _roof   = roof;
     _wall   = wall;
 }
Exemple #8
0
 public Opening(IWall myWall, IDimension dimensions, ILocation location, OpeningType openingType)
 {
     // WallOrSlap = myWall;
     Dimensions  = dimensions;
     Location    = location;
     OpeningType = openingType;
 }
Exemple #9
0
        public override IWorldCommand Excecute()
        {
            IWall wall          = level.GetWallAt(posX, posY, posZ);
            int   previousIndex = wall.Type;

            if (index != WallIndex.Empty)
            {
                // If is building ignore already built walls.
                if (previousIndex != WallIndex.Empty)
                {
                    return(NullCommand.instance);
                }
            }
            else
            {
                // If it's removing ignore empty tiles.
                if (previousIndex == WallIndex.Empty)
                {
                    return(NullCommand.instance);
                }
            }

            wall.Type = index;

            return(new BuildWallCmd(level, posX, posY, posZ, previousIndex));
        }
Exemple #10
0
 public void SetWall(IWall wall, int denom = 180)
 {
     this.LastWall        = this.Wall;
     this.Wall            = wall;
     this.WallChangeNumer = 0;
     this.WallChangeDenom = denom;
 }
Exemple #11
0
        public void Setup()
        {
            this.userWall = Substitute.For <IWall>();
            this.bob      = new User(BobUserHandle, this.userWall);
            this.alice    = new User(AliceUserHandle, this.userWall);

            SystemTime.Now = () => new DateTime(2000, 1, 1);
        }
Exemple #12
0
 public IPoint Create(IMarble marble, IWall wall)
 {
     return(new Point
     {
         Marble = marble,
         Wall = wall
     });
 }
 public CommandHandler(IUserList userList, IPublish publish, IReading reading, IFollow follow, IWall wall)
 {
     _userList = userList;
     _publish = publish;
     _reading = reading;
     _follow = follow;
     _wall = wall;
 }
Exemple #14
0
    public void AddRoomFeature(IWall wallRoomFeature, CardinalDirection orientation)
    {
        IEnumerable <IWall> walls = this.roomFeatures.Where(rf => rf.GetType() == wallRoomFeature.GetType()).Cast <IWall>();

        if (!walls.Where <IWall>(w => w.Orientation == wallRoomFeature.Orientation).Any())
        {
            this.roomFeatures.Add(wallRoomFeature);
        }
    }
Exemple #15
0
        public void SetUp()
        {
            this.repository = Substitute.For <IRepository <IUser> >();
            this.userWall   = Substitute.For <IWall>();

            this.broker = new MessageBroker(this.repository);

            this.bob   = new User("Bob", this.userWall);
            this.alice = new User("Alice", this.userWall);
        }
Exemple #16
0
        public static bool PointInWall(Vector2D point, IWall wall)
        {
            Vector2D topLeft     = new Vector2D(wall.Pos.X, wall.Pos.Y);
            Vector2D bottomRight = new Vector2D(wall.Pos.X + wall.Width, wall.Pos.Y + wall.Height);

            return
                (point.X >= topLeft.X &&
                 point.X <= bottomRight.X &&
                 point.Y >= topLeft.Y &&
                 point.Y <= bottomRight.Y);
        }
        public void FlipSideNeighbors()
        {
            IWall buff = TopLeft;

            TopLeft  = TopRight;
            TopRight = buff;

            buff        = BottomLeft;
            BottomLeft  = BottomRight;
            BottomRight = buff;
        }
Exemple #18
0
        private bool SensorWithinWall(IWall wall, Vector2D sensor)
        {
            Vector2D topLeft     = new Vector2D(wall.Pos.X, wall.Pos.Y);
            Vector2D bottomRight = new Vector2D(wall.Pos.X + wall.Width, wall.Pos.Y + wall.Height);

            return
                (sensor.X >= topLeft.X &&
                 sensor.X <= bottomRight.X &&
                 sensor.Y >= topLeft.Y &&
                 sensor.Y <= bottomRight.Y);
        }
Exemple #19
0
        public Sprite GetSprite(IWall wall, bool isCropped)
        {
            Vector3Int coords        = new Vector3Int(wall.X, wall.Y, wall.Z);
            Vector3Int rotatedCoords = WallTransformer.InverseRotateCoord(coords);

            return(WallCreator.DrawSpriteBorders(
                       sprites[rotatedCoords.z],
                       rotatedCoords.z,
                       new InmediateWallNeighbors(wall, OrientationManager.currentOrientation),
                       isCropped));
        }
Exemple #20
0
        //implementation correct
        public static bool WallCollidesWithPoint(IWall wall, Vector2D point)
        {
            var left   = wall.Pos.X;
            var right  = wall.Pos.X + (wall.Width);
            var top    = wall.Pos.Y;
            var bottom = wall.Pos.Y + (wall.Height);

            return(left < point.X &&
                   right > point.X &&
                   top < point.Y &&
                   bottom > point.Y);
        }
Exemple #21
0
        public void SetWall(IWall wall)
        {
            foreach (GameObject go in disableOnStart)
            {
                go.SetActive(false);
            }

            DisableIncorrectSides(wall);

            UpdateCurrentIndexes(wall);

            EnableSides();
        }
        public void SetUp()
        {
            SystemTime.Now = () => new DateTime(2000, 1, 1);

            this.consoleMock         = Substitute.For <IConsole>();
            this.repositoryMock      = Substitute.For <IRepository <IUser> >();
            this.userWallMock        = Substitute.For <IWall>();
            this.parserMock          = Substitute.For <IInputParser>();
            this.brokerMock          = Substitute.For <IMessageBroker>();
            this.formaterFactoryMock = Substitute.For <IMessageFormaterFactory>();

            this.bob = new User("Bob", this.userWallMock);
        }
        static void Build(IHouseFactory factory)
        {
            IFloor   floor   = factory.CreateFloor();
            IWall    wall    = factory.CreateWall();
            IDoor    door    = factory.CreateDoor();
            IWindow  window  = factory.CreateWindow();
            ICeiling ceiling = factory.CreateCeiling();

            floor.Display();
            wall.Display();
            door.Display();
            window.Display();
            ceiling.Display();
        }
Exemple #24
0
        private void UpdateCurrentIndexes(IWall wall)
        {
            _currentIndexBase  = wall.IndexBase;
            _currentIndexFront = wall.IndexFront;
            _currentIndexRight = wall.IndexRight;
            _currentIndexBack  = wall.IndexBack;
            _currentIndexLeft  = wall.IndexLeft;

            CurrentBase  = bases[wall.IndexBase];
            CurrentFront = fronts[wall.IndexFront];
            CurrentRight = rights[wall.IndexRight];
            CurrentBack  = backs[wall.IndexBack];
            CurrentLeft  = lefts[wall.IndexLeft];
        }
Exemple #25
0
 public MementoDrag(EditorObject transformable)
 {
     Transformable = transformable;
     _polygonCoord = transformable.GetPolygonCoord();
     _transform = null;
     if (_polygonCoord != null)
     {
         _parent = (IWall)transformable.Parent;
     }
     else
     {
         _transform = transformable.GetTransform();
     }
 }
Exemple #26
0
        //public Vector2D Calculate()
        //{
        //    Vector2D force; // My force will be stored here
        //    Vector2D pos = _me.Pos; // Position of the agent

        //    // For each wall
        //    for (int j = 0; j < _me.Walls.Count(); j++)
        //    {
        //        var wall = _me.Walls[j];
        //        var x = (wall.Center.X + _me.Pos.X) / 2;
        //        var y = (wall.Center.Y + _me.Pos.Y) / 2;
        //        Vector2D distance = new Vector2D(x, y);

        //        // If the wall is visible, calculate the force to apply
        //        double dotProduct = distance * partsList[j]->normal();
        //        if (dotProduct < 0)
        //        {
        //            force += partsList[j]->normal() / (distance.length() * distance.length() + 1);
        //        }
        //    }

        //    // Returned the calculated force
        //    return force;
        //}

        public IWall GetClosestWall(IWallAvoider ME)
        {
            IWall mostThreatening = null;

            for (int i = 0; i < ME.Walls.Count(); i++)
            {
                IWall wall      = ME.Walls[i];
                bool  collision = findSensorCollision(wall);
                if (collision && (mostThreatening == null || VectorMath.DistanceBetweenPositions(ME.Pos, wall.Center) < VectorMath.DistanceBetweenPositions(ME.Pos, mostThreatening.Center)))
                {
                    mostThreatening = wall;
                }
            }
            return(mostThreatening);
        }
Exemple #27
0
        public override IWorldCommand Excecute()
        {
            IWall wall          = level.GetWallAt(posX, posY, posZ);
            int   previousIndex = wall.Type;

            if (previousIndex == WallIndex.Empty)
            {
                // Cannot paint an empty wall.
                return(NullCommand.instance);
            }

            wall.Type = index;

            return(new PaintWallCmd(level, posX, posY, posZ, previousIndex));
        }
        public static IWall[,,] GenerateNulls(Level level, int levelWidth, int levelHeight)
        {
            IWall[,,] walls = new IWall[levelWidth + 1, levelHeight + 1, 2];

            for (int x = 0; x < levelWidth + 1; x++)
            {
                for (int y = 0; y < levelHeight + 1; y++)
                {
                    walls[x, y, 0] = new NullWall(level, x, y, 0);
                    walls[x, y, 1] = new NullWall(level, x, y, 0);
                }
            }

            return(walls);
        }
        GameObject CreateSprite(IWall wall)
        {
            GameObject wall_go = new GameObject {
                name = "Wall [" + wall.X.ToString() + "," + wall.Y.ToString() + "," + wall.Z.ToString() + "]"
            };

            wall_go.transform.SetParent(wallHolder.transform, true);

            SpriteRenderer sr = wall_go.AddComponent <SpriteRenderer> ();

            sr.sortingLayerName = "Tiles";

            gameobjects.Add(wall, wall_go);

            UpdateSprite(wall);
            return(wall_go);
        }
        public void NotifyWallTypeChanged(IWall wall)
        {
            // Update wall
            UpdateSprite(wall);

            // Update neighbors
            UpdateSprite(wall.GetNeighbor(0, 0, 0));
            UpdateSprite(wall.GetNeighbor(0, 0, 1));
            UpdateSprite(wall.GetNeighbor(0, 1, 0));
            UpdateSprite(wall.GetNeighbor(0, 1, 1));
            UpdateSprite(wall.GetNeighbor(0, -1, 1));
            UpdateSprite(wall.GetNeighbor(1, 0, 0));
            UpdateSprite(wall.GetNeighbor(1, 0, 1));
            UpdateSprite(wall.GetNeighbor(1, -1, 1));
            UpdateSprite(wall.GetNeighbor(-1, 0, 0));
            UpdateSprite(wall.GetNeighbor(-1, 1, 0));
        }
        void UpdateSprite(IWall wall)
        {
            if (gameobjects.ContainsKey(wall) == false)
            {
                return;
            }

            GameObject wall_go = gameobjects[wall];

            wall_go.transform.position = WallTransformer.CoordToWorld(wall.X, wall.Y, wall.Z);

            SpriteRenderer sr = wall_go.GetComponent <SpriteRenderer> ();

            sr.sprite       = DataManager.wallSpriteData.GetDataById(wall.Type).GetSprite(wall, GetClippingForWall(wall));
            sr.sortingOrder = SortingOrders.WallOrder(wall.X, wall.Y, wall.Z, TileSubLayer.Wall);

            //sr.color = Random.ColorHSV(0, 1, 0, 1, 0.4f, 1);
        }
Exemple #32
0
 private bool findSensorCollision(IWall wall)
 {
     if (SensorWithinWall(wall, centerSensor))
     {
         affectedSensor = centerSensor;
         return(true);
     }
     if (SensorWithinWall(wall, leftSensor))
     {
         affectedSensor = leftSensor;
         return(true);
     }
     if (SensorWithinWall(wall, rightSensor))
     {
         affectedSensor = rightSensor;
         return(true);
     }
     return(false);
 }
Exemple #33
0
        public void FillWall(IWall wall)
        {
            Console.SetCursorPosition(0, 1);

            for (int row = 0; row < wall.Height; row++)
            {
                for (int column = 0; column < wall.Width; column++)
                {
                    if (column <= 1 || column >= wall.Width - 2 || row == 0 || row == wall.Height - 1)
                    {
                        wall.FilledWall[row, column] = new Brick(row, column, false);
                    }
                    else
                    {
                        wall.FilledWall[row, column] = new Brick(row, column, true);
                    }
                }
            }
        }
Exemple #34
0
        public void Must_display_all_messages_in_wall()
        {
            var test = new List<User>()
                       {
                           new User()
                           {
                               Name = "Alice",
                               _messages = new List<Message>()
                                           {
                                               new Message()
                                               {
                                                   UsersMessage = "test1"
                                               }
                                           },
                               _peopleFollowing = new List<User>()
                                                  {
                                                      new User()
                                                      {
                                                          _messages = new List<Message>()
                                                                      {
                                                                          new Message()
                                                                          {
                                                                              UsersMessage = "test"
                                                                          }
                                                                      }
                                                      }
                                                  }
                           }
                       };
            _userList = new UserList();
            _userList.ListOfUsers = test;
            var username = "******";

            _sut = new Wall(_userList);

            var listOfMessages = _sut.DisplayAllMessages(username);

            Assert.AreEqual(listOfMessages.Count, 2);
        }
        public void SetUp()
        {
            this.repository = Substitute.For<IRepository<IUser>>();
            this.userWall = Substitute.For<IWall>();

            this.broker = new MessageBroker(this.repository);

            this.bob = new User("Bob", this.userWall);
            this.alice = new User("Alice", this.userWall);
        }
        public void SetUp()
        {
            SystemTime.Now = () => new DateTime(2000, 1, 1);

            this.consoleMock = Substitute.For<IConsole>();
            this.repositoryMock = Substitute.For<IRepository<IUser>>();
            this.userWallMock = Substitute.For<IWall>();
            this.parserMock = Substitute.For<IInputParser>();
            this.brokerMock = Substitute.For<IMessageBroker>();
            this.formaterFactoryMock = Substitute.For<IMessageFormaterFactory>();

            this.bob = new User("Bob", this.userWallMock);
        }
Exemple #37
0
 public WallCoord(IWall wall, int edgeIndex, float edgeT)
 {
     EdgeIndex = edgeIndex;
     EdgeT = edgeT;
     Wall = wall;
 }
 public void SetSide(Side side, IWall wall)
 {
     // реализация
 }
Exemple #39
0
 public WallCoord(IWall wall, PolygonCoord coord)
     : this(wall, coord.EdgeIndex, coord.EdgeT)
 {
 }
        public void Setup()
        {
            this.userWall = Substitute.For<IWall>();
            this.bob = new User(BobUserHandle, this.userWall);
            this.alice = new User(AliceUserHandle, this.userWall);

            SystemTime.Now = () => new DateTime(2000, 1, 1);
        }