BattleShip.Ship.IsInThePlatform C# (CSharp) Метод

IsInThePlatform() публичный Метод

check if the boats are in the ally platform and fit him to case
public IsInThePlatform ( int mouseX, int mouseY, GameBoard platform ) : void
mouseX int position x of the mouse cursor
mouseY int position y of the mouse cursor
platform GameBoard
Результат void
        public void IsInThePlatform(int mouseX, int mouseY, GameBoard platform)
        {
            /*int divX = 0, divY = 0;

            divX = mouseX / platform.CASE_SIZE + platform.Location.X;
            divY = mouseY / platform.CASE_SIZE + platform.Location.Y;

            if ((divX >= platform.Location.X) && (divX < platform.Location.X) && (divY >= 1) && (divY < 11))
            {
                this.X = divX * this._size + platform.Location.X;
                this.Y = divY * this._size + platform.Location.Y;
            }*/

            if ((mouseX > platform.Location.X) && (mouseX < platform.Location.X + platform.Size.Width) && (mouseY > platform.Location.Y) && (mouseY < platform.Location.Y + platform.Size.Height))
            {
                // calcul and trunc the position of the mouse on the platform 
                this.X = platform.Location.X + platform.CASE_SIZE + (mouseX - platform.Location.X - platform.CASE_SIZE) / platform.CASE_SIZE * platform.CASE_SIZE;
                this.Y = platform.Location.Y + platform.CASE_SIZE + (mouseY - platform.Location.Y - platform.CASE_SIZE) / platform.CASE_SIZE * platform.CASE_SIZE;
            }
        }