예제 #1
0
        public void Redraw(CBoardElement[][] oElements)
        {
            int boardSize = oElements.Length;

            int xIndex = mController.GetPosX();

            if (xIndex < 0)
            {
                xIndex = 0;
            }

            int yIndex = mController.GetPosY();

            if (yIndex < 0)
            {
                yIndex = 0;
            }
            int beginY = yIndex;

            int tankPosX = mController.GetPosX();
            int tankEndX = tankPosX + mController.GetSize();

            if (tankEndX > boardSize)
            {
                tankEndX = boardSize;
            }

            int tankPosY = mController.GetPosY();
            int tankEndY = tankPosY + mController.GetSize();

            if (tankEndY > boardSize)
            {
                tankEndY = boardSize;
            }

            while (xIndex < tankEndX)
            {
                yIndex = beginY;
                while (yIndex < tankEndY)
                {
                    oElements[xIndex][yIndex].SetDestroyed(true);
                    oElements[xIndex][yIndex].SetTank(true);

                    if (CanonOnPosition(
                            xIndex,
                            yIndex,
                            tankPosX,
                            tankPosY))
                    {
                        oElements[xIndex][yIndex].SetCanon(true);
                    }
                    yIndex++;
                }
                xIndex++;
            }
        }
예제 #2
0
        public void Prepare()
        {
            mHalfOfSize = mPosition.GetSize() / 2;

            CTank parentTank = mController.ParentTank;

            int halfOfSizeDifference = mHalfOfSize - parentTank.GetSize() / 2;

            mPosition.SetPosX(parentTank.GetPosX() - halfOfSizeDifference);
            mPosition.SetPosY(parentTank.GetPosY() - halfOfSizeDifference);
        }