Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj is TTTMove)
            {
                return(false);
            }

            TTTMove move = (TTTMove)obj;

            return(Player == move.Player && XPosition == move.XPosition &&
                   YPosition == move.YPosition);
        }
Ejemplo n.º 2
0
		public void AddMove (TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
		{
			if (!CanAddMove (xPosition, yPosition))
				return;

			TTTMove move = new TTTMove (currentPlayer, xPosition, yPosition);
			Moves.Add (move);

			currentPlayer = currentPlayer == TTTMovePlayer.Me ?
				TTTMovePlayer.Enemy : TTTMovePlayer.Me;

			updateGameResult ();
		}
Ejemplo n.º 3
0
        public void AddMove(TTTMoveXPosition xPosition, TTTMoveYPosition yPosition)
        {
            if (!CanAddMove(xPosition, yPosition))
            {
                return;
            }

            TTTMove move = new TTTMove(currentPlayer, xPosition, yPosition);

            Moves.Add(move);

            currentPlayer = currentPlayer == TTTMovePlayer.Me ?
                            TTTMovePlayer.Enemy : TTTMovePlayer.Me;

            updateGameResult();
        }
Ejemplo n.º 4
0
		void setMove (TTTMove move, UIImageView moveView)
		{
			moveView.Image = ImageForPlayer (this, move.Player);
			moveView.Center = pointForPosition (move.XPosition, move.YPosition);
		}
Ejemplo n.º 5
0
        public void UpdateGameState()
        {
            TTTMove[] moves     = Game.Moves.ToArray();
            int       moveCount = moves.Length;

            UIImageView[] moveViews = new UIImageView[moveImageViews.Count];

            moveImageViews.CopyTo(moveViews);

            for (int i = 0; i < moveViews.Length; i++)
            {
                UIImageView moveView = moveViews [i];

                if (i < moveCount)
                {
                    TTTMove move = moves [i];
                    setMove(move, moveView);
                    setVisible(true, moveView);
                }
                else
                {
                    setVisible(false, moveViews [i]);
                    moveImageViewReuseQueue.Add(moveView);
                    moveImageViews.Remove(moveView);
                }
            }

            for (int moveIndex = moveImageViews.Count; moveIndex < moveCount; moveIndex++)
            {
                TTTMove     move     = moves [moveIndex];
                UIImageView moveView = moveImageView();
                UIView.PerformWithoutAnimation(delegate {
                    setMove(move, moveView);
                    setVisible(false, moveView);
                });

                setVisible(true, moveView);
            }

            TTTMovePlayer    winningPlayer;
            TTTMoveXPosition startXPosition, endXPosition;
            TTTMoveYPosition startYPosition, endYPosition;

            bool hasWinner = Game.GetWinningPlayer(out winningPlayer,
                                                   out startXPosition,
                                                   out startYPosition,
                                                   out endXPosition,
                                                   out endYPosition);

            if (hasWinner)
            {
                UIBezierPath path = new UIBezierPath();
                path.LineWidth = LineWidth;
                path.MoveTo(pointForPosition(startXPosition, startYPosition));
                path.AddLineTo(pointForPosition(endXPosition, endYPosition));
                lineView.Path  = path;
                lineView.Color = ColorForPlayer(this, winningPlayer);
                AddSubview(lineView);
            }

            lineView.Alpha = hasWinner ? 1f : 0f;
        }
Ejemplo n.º 6
0
 void setMove(TTTMove move, UIImageView moveView)
 {
     moveView.Image  = ImageForPlayer(this, move.Player);
     moveView.Center = pointForPosition(move.XPosition, move.YPosition);
 }