Ejemplo n.º 1
0
 public void rollDice()
 {
     Debug.Log(playerLogic.currentPlayer().getPlayerName() + " Rolling Dice");
     foreach (Die die in gameLayout.getDiceInZone(playerLogic.currentPlayer().getPlayerName()))
     {
         DieLogic.rollDie(die);
     }
 }
Ejemplo n.º 2
0
    public void rollSimilarDice(Die d)
    {
        Die[]  dice   = d.transform.parent.GetComponentsInChildren <Die>();
        string sAudio = "rollS";

        if (dice.Length > 1)
        {
            sAudio = "rollM_1"; // index of the multiple dice roll sound
        }
        foreach (Die die in dice)
        {
            SoundControl.instance.setAudio("dice", sAudio);
            DieLogic.rollDie(die);
        }
    }
Ejemplo n.º 3
0
    public bool isValidDrag(Draggable drag)
    {
        bool canDrag = false;

        string zoneFrom, areaFrom;

        Die d = drag.GetComponent <Die>();


        try {
            Debug.Log("Area: " + drag.getParentArea().name + " - " + getCurrentAreaS());
            // If draggable not in current player's area or the market, then do not allow to drag.
            //      --- Won't work if want Defender to discard during STRIKE step ---
            if (drag.getParentArea().name != getCurrentAreaS() && drag.getParentArea().name != "areaMarket")
            {
                //return false;
            }
            // Depending on step and zone, allow draggability

            zoneFrom = drag.getParentZone().zoneName;
            areaFrom = drag.getParentArea().name;
            Debug.Log("Zone: " + zoneFrom);
            switch ((int)stepLogic.currentStep)
            {
            case 0:      // SCORE
                // Clicked die in zoneSummoned dice

                if (zoneFrom.Equals("zoneSummoned") && areaFrom.Equals(getCurrentAreaS()))
                {
                    // Know Dice exist in zone...so get them and score them
                    playerLogic.scoreDice();
                    moveDice(getCurrentZoneS("zoneSummoned"),
                             getCurrentZoneS("zoneStored"));


                    if (playerLogic.currentPlayer().score == GameState.winCondition)
                    {
                        Debug.Log(playerLogic.currentPlayer().getPlayerName() + " Wins!");

                        GameMenu[] menus = GameObject.Find("GameMenu").GetComponents <GameMenu>();

                        foreach (GameMenu item in menus)
                        {
                            if (item.menuPanel.name == "GameOver")
                            {
                                item.menuPanel.SetActive(true);
                                break;
                            }
                        }
                        GameObject.Find("txtGameOver").GetComponent <Text>().text = playerLogic.currentPlayer().getPlayerName() + " Wins!";
                        GameState.isPaused = true;
                    }
                    canDrag = false;
                }
                break;

            case 1:      // SCRY
                break;

            case 2:      // SPIN
                // If draggable clicked is in the rolled zone, then move the dice to proper spot.
                if (zoneFrom.Equals("zoneRoll") && areaFrom.Equals(getCurrentAreaS()))
                {
                    moveDice(getCurrentZoneS("zoneRoll"),
                             getCurrentZoneS("zoneServicable"));
                    canDrag = false;
                }
                if (zoneFrom.Equals("zoneSupport") && areaFrom.Equals(getCurrentAreaS()))
                {
                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        rollSimilarDice(drag.GetComponent <Die>());
                    }
                    else
                    {
                        SoundControl.instance.setAudio("dice", "rollS");
                        DieLogic.rollDie(drag.GetComponent <Die>());
                    }
                    canDrag = false;
                }
                break;

            case 3:      // SPEND
                if (drag.getParentArea().name == "areaMarket" &&
                    playerLogic.affordEnergy(d.card.cardInfo.cost) &&
                    !GameState.hasBought)
                {
                    canDrag = true;
                }

                // Will only ever have Dice in this zone during current players turn
                if (zoneFrom.Equals("zoneServicable"))
                {
                    canDrag = true;
                }
                break;

            case 4:      // STRIKE
                //Debug.Log(playerLogic.startAttack());
                if (zoneFrom.Equals("zoneSummoned") && !areaFrom.Equals(getCurrentAreaS()))
                {
                    canDrag = true;
                }
                break;

            case 5:      // SECURE
                if (zoneFrom.Equals("zoneServicable") ||
                    zoneFrom.Equals("zoneSpent"))
                {
                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        moveDice(getCurrentZoneS("zoneServicable"),
                                 getCurrentZoneS("zoneStored"));
                        moveDice(getCurrentZoneS("zoneSpent"),
                                 getCurrentZoneS("zoneStored"));
                        canDrag = false;
                    }
                    else
                    {
                        canDrag = true;
                    }
                }
                break;

            default:
                break;
            }
        }
        catch (Exception e)
        {
            Debug.Log("isValidDrag err:/n" + e);
        }
        finally
        {
            if (canDrag)
            {
                draggedObject = drag;
            }
            //draggedObject = drag.gameObject;
        }

        if (canDrag)
        {
            // HARD: Assume Drag is die?
            SoundControl.instance.playAudio("dice", "pickup");
            return(true);
        }
        return(false);


        switch (drag.tag)
        {
        case "Die":
            break;

        case "Card":
            break;

        case "Token":
            break;

        default:
            // Not a legit dragged item
            break;
        }
    }