Ejemplo n.º 1
0
 public override void update(float delta, ColorGame game)
 {
     KeyboardState keyboard = Keyboard.GetState();
     Keys[] pressed = keyboard.GetPressedKeys();
     foreach (Keys key in pressed)
         if (key == Keys.Space)
             game.enterState(GameType.Game);
 }
Ejemplo n.º 2
0
 public bool CanPlay()
 {
     foreach (ColorCard c in MyCards)
     {
         if (ColorGame.CheckCardMatch(topCard, c))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 public override void init(ColorGame game)
 {
     back = game.Content.Load<Texture2D>("texture/menu/back");
 }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (player.isGameOver || isStatic)
        {
            return;
        }

        if (Input.touchCount == 1)
        {
            Touch t = Input.GetTouch(0);


            // Handle finger movements based on TouchPhase
            switch (t.phase)
            {
            //When a touch has first been detected, change the message and record the starting position
            case TouchPhase.Began:
                // Record initial touch position.
                startPos = t.position;
                break;

            //Determine if the touch is a moving touch
            case TouchPhase.Moved:
                // SWIPE FOR SCROLLING WHEEL
                // Determine direction by comparing the current touch position with the initial one
                direction = t.position - startPos;

                gameObject.transform.Rotate(0f, 0f, -t.deltaPosition.x / 10);

                if (gameObject.transform.rotation.z < 0f)
                {
                    gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
                }

                if (gameObject.transform.rotation.eulerAngles.z > (cardUIObjects.Count - 1) * CARD_ANGLE_INCREMENT)
                {
                    gameObject.transform.rotation = Quaternion.Euler(0, 0, (cardUIObjects.Count - 1) * CARD_ANGLE_INCREMENT);
                }

                currentRotationAngle = gameObject.transform.rotation.eulerAngles.z;
                MoveCardWheelZ();

                wasMoved = true;
                break;

            case TouchPhase.Ended:

                TapCount += 1;

                if (TapCount == 1)
                {
                    NewTime = Time.time + MaxDoubleTapTime;
                }
                else if (TapCount == 2 && Time.time <= NewTime)
                {
                    // Double tap detected
                    // Get current selected card object
                    ColorCard currentSelectedCard = addedCards[currentHighlightIndex];

                    // Check match with game rules
                    bool cardsMatch = ColorGame.CheckCardMatch(player.GetTopCard(), currentSelectedCard);

                    if (cardsMatch && player.HasTurn() && !player.MustDrawBeforePlaying())
                    {
                        // Send played card to server
                        player.PlayCard(currentSelectedCard);

                        // Remove the card from the wheel
                        RemoveCard(currentSelectedCard);

                        // Remove playing permission
                        player.SetTurn(false);
                    }
                    TapCount = 0;
                }

                else
                {
                    TapCount = 0;
                }

                wasMoved = false;
                break;
            }



            if (Time.time > NewTime)
            {
                TapCount = 0;
            }
        }


        if (Input.GetKeyDown(KeyCode.F))
        {
            // Double tap detected
            // Get current selected card object
            ColorCard currentSelectedCard = addedCards[currentHighlightIndex];

            // Check match with game rules
            bool cardsMatch = ColorGame.CheckCardMatch(player.GetTopCard(), currentSelectedCard);

            if (cardsMatch && player.HasTurn() && !player.MustDrawBeforePlaying())
            {
                // Send played card to server
                player.PlayCard(currentSelectedCard);

                // Remove the card from the wheel
                RemoveCard(currentSelectedCard);

                // Remove playing permission
                player.SetTurn(false);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            currentRotationAngle -= CARD_ANGLE_INCREMENT;
            MoveCardWheelZ();
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            currentRotationAngle += CARD_ANGLE_INCREMENT;
            MoveCardWheelZ();
        }
        else if (Input.GetKeyDown(KeyCode.D) && player.MustDrawBeforePlaying() && player.HasTurn())
        {
            player.DrawCards();
            MoveCardWheelZ();
        }

        if (cardUIObjects.Count != 0)
        {
            // Check card to highlight
            HighlightActiveCard();
        }
    }
Ejemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     checker = FindObjectOfType<ColorGame>();
 }