コード例 #1
0
    private void GenerateHandsAroundWheel()
    {
        GameObject handHolder    = Instantiate(prefebs, handsWheel.transform.position, Quaternion.identity);
        int        handType      = Random.Range(0, 2);// 1 means Bad Hand
        int        goodhandStyle = 100;
        int        badhandStyle  = 100;

        if (handType == 1)
        {
            badhandStyle = Random.Range(0, (int)BadHandStyle.BadHand6 + 1);
        }
        else
        {
            goodhandStyle = Random.Range(0, (int)GoodHandStyle.GoodHand2 + 1);
        }
        SelectionHands selectionHandsScript = handHolder.GetComponent <SelectionHands> ();

        selectionHandsScript.handType      = (HandsType)handType;
        selectionHandsScript.goodHandStyle = (GoodHandStyle)goodhandStyle;
        selectionHandsScript.badHandStyle  = (BadHandStyle)badhandStyle;
        //move up
        handHolder.transform.Translate(Vector3.right * 1.5f);
        //reset to the start positions
        handHolder.transform.RotateAround(handsWheel.transform.position, Vector3.forward, -65f);
        handHolder.transform.parent = handsWheel.transform;
        int degreeMulitplier = Random.Range(0, maximuHands);

        handHolder.transform.RotateAround(handsWheel.transform.position, Vector3.forward, minimunGapBetweenHands * degreeMulitplier);
    }
コード例 #2
0
 public void CheckTheArea(string action)
 {
     if (action == "Slap")
     {
         playerHandScript.Slap();
         // slap the in coming hands
         Collider2D[] colliders = Physics2D.OverlapBoxAll(transform.position, boxCollider.size, 0f, layerMask);
         if (colliders.Length > 1)
         {
             foreach (var item in colliders)
             {
                 if (item.gameObject != gameObject)
                 {
                     SelectionHands selectedHands = item.GetComponent <SelectionHands> ();
                     if (selectedHands.handType == HandsType.Good)
                     {
                         ShowCross();
                         GameManager.instance.MinusLife();
                         selectedHands.minusHeart = false;
                     }
                     else
                     {
                         GameManager.instance.AddScore();
                         GameManager.instance.AddLife();
                         selectedHands.HandDisappear();
                         GameManager.instance.OnDestroyRespawnHands();
                         ShowCheck();
                     }
                 }
             }
         }
         else
         {
             ShowCross();
             GameManager.instance.MinusLife();
         }
     }
     else
     {
         playerHandScript.ShakeHand();
         //action =="shake"
         // slap the in coming hands
         Collider2D[] colliders = Physics2D.OverlapBoxAll(transform.position, boxCollider.size, 0f, layerMask);
         if (colliders.Length > 1)
         {
             foreach (var item in colliders)
             {
                 if (item.gameObject != gameObject)
                 {
                     SelectionHands selectedHands = item.GetComponent <SelectionHands> ();
                     if (selectedHands.handType == HandsType.Good)
                     {
                         // the result is Good
                         GameManager.instance.AddScore();
                         GameManager.instance.AddLife();
                         selectedHands.HandDisappear();
                         GameManager.instance.OnDestroyRespawnHands();
                         ShowCheck();
                     }
                     else
                     {
                         ShowCross();
                         selectedHands.minusHeart = false;
                         GameManager.instance.MinusLife();
                     }
                 }
             }
         }
         else
         {
             ShowCross();
             GameManager.instance.MinusLife();
         }
     }
 }