Esempio n. 1
0
    public void defend(int attackValue)
    {
        int dDefense;

        defenseLeft      = attackValue;
        defendSuccessful = false;
        //defenseValue = getDiceValue(getDice(), Side.valueTypes.DEFENSE); Die[] sDice = getDice(); Array.Sort(sDice);
        //defenseValue = DieLogic.getDiceValue(GameLogic.instance.gameLayout.getDiceInZoneNext("zoneSummoned"), Side.eValueTypes.DEFENSE);

        Die[] dice = GameLogic.instance.gameLayout.getDiceInZoneNext("zoneSummoned");

        if (dice.Length > 0)
        {
            foreach (Die die in dice)
            {
                dDefense = DieLogic.getDieValue(die, Side.eValueTypes.DEFENSE);
                if (dDefense > attackValue)
                {
                    //defenseLeft = 0;
                    defendSuccessful = true;
                    break;
                }
            }

            if (defendSuccessful)
            {
                Debug.Log(nextPlayer().getPlayerName() + " can fully defend against " + attackValue + " damage!");
            }
        }
        else
        {
            defendSuccessful = true;
            Debug.Log(nextPlayer().getPlayerName() + " has noone to use to defend");
        }
    }
Esempio n. 2
0
    public void moveDice(string f, string t, int amt, bool b)
    {
        Die[] dice = gameLayout.getDiceInZone(f);

        int count = amt;

        if (count <= 0 || count > dice.Length)
        {
            count = dice.Length;
        }
        Debug.Log("Moving " + count + " dice from " + f + " to " + t);
        for (int i = 0; i < count; i++)
        {
            //dice[i].moveDie(gameLayout.getZoneDiceParent(t).transform);
            DieLogic.moveDie(dice[i], gameLayout.getZone(t));
            dice[i].toggleVisibility(b);

            if (b)
            {
                SoundControl.instance.playAudio("dice", "slide");
            }
            else
            {
                SoundControl.instance.playAudio("dice", "drop_cup");
            }
        }
    }
Esempio n. 3
0
 public void rollDice()
 {
     Debug.Log(playerLogic.currentPlayer().getPlayerName() + " Rolling Dice");
     foreach (Die die in gameLayout.getDiceInZone(playerLogic.currentPlayer().getPlayerName()))
     {
         DieLogic.rollDie(die);
     }
 }
Esempio n. 4
0
    //     IEnumerator
    public void drawDice(int amount)
    {
        if (GameState.hasDrawn)
        {
            return;
        }
        int count = amount;

        Zone   supportT = gameLayout.getZone(getCurrentZoneS("zoneSupport"));
        string support  = getCurrentZoneS("zoneSupport");
        string supply   = getCurrentZoneS("zoneSupply");
        string stored   = getCurrentZoneS("zoneStored");

        Die[] h = gameLayout.getDiceInZone(supply);
        Die[] d = gameLayout.getDiceInZone(stored);

        int iDraw;


        if (h != null && h.Length == 0 && d.Length != 0)
        {
            moveDice(stored, supply, false);
            h = gameLayout.getDiceInZone(supply);
            d = new Die[0];
        }

        //moveDice(supply, support, amount);

        /*
         *  What to do if can't move the asked amount?
         *      If 'from' is "supply" then
         *          moveDice(stored, supply, false)
         *          continue
         */
        while (count != 0 && h.Length != 0 && h != null)
        {
            iDraw = UnityEngine.Random.Range(0, h.Length);

            DieLogic.moveDie(h[iDraw], supportT);
            h[iDraw].toggleVisibility(true);

            SoundControl.instance.playAudio("dice", "slide");

            count--;
            h = gameLayout.getDiceInZone(supply);

            if (count > 0 && h.Length == 0 && d.Length > 0)
            {
                //yield return new WaitForSeconds(h[iDraw].GetComponent<AudioSource>().clip.length);
                moveDice(stored, supply, false);
                h = gameLayout.getDiceInZone(supply);
                d = new Die[0];
            }
        }

        Debug.Log("Moved " + (amount - count) + " dice !");
        GameState.hasDrawn = true;
    }
Esempio n. 5
0
    public void defendAttack(Die die)
    {
        int dDefense = DieLogic.getDieValue(die, Side.eValueTypes.DEFENSE);

        defenseLeft -= dDefense;

        if (defenseLeft <= 0 || GameLogic.instance.gameLayout.getDiceInZoneNext("zoneSummoned").Length == 0)
        {
            defendSuccessful = true;
        }
    }
Esempio n. 6
0
    public void adminMoveDie()
    {
        //Transform dT;
        Transform zT = GameObject.Find("areaPlayer1/zoneSupport").transform;
        Transform dT = GameObject.Find("areaPlayer1/zoneSupport").transform;

        switch (stepLogic.cStep)
        {
        case 0:
            dT = GameObject.Find("areaPlayer1/zoneSupport").transform;
            zT = GameObject.Find("areaPlayer1/zoneServicable").transform;
            break;

        case 1:
            dT = GameObject.Find("areaPlayer1/zoneServicable").transform;
            zT = GameObject.Find("areaPlayer1/zoneSummoned").transform;
            break;

        case 2:
            dT = GameObject.Find("areaPlayer1/zoneSummoned").transform;
            zT = GameObject.Find("areaPlayer1/zoneSpent").transform;
            break;

        case 3:
            dT = GameObject.Find("areaPlayer1/zoneSpent").transform;
            zT = GameObject.Find("areaPlayer1/zoneStored").transform;
            break;

        case 4:
            dT = GameObject.Find("areaPlayer1/zoneStored").transform;
            zT = GameObject.Find("areaPlayer1/zoneSupport").transform;
            break;

        case 5:
            dT = GameObject.Find("areaPlayer1/zoneSupport").transform;
            zT = GameObject.Find("areaPlayer1/zoneSupport").transform;
            break;
        }

        foreach (Die die in dT.GetComponentsInChildren <Die>())
        {
            /*
             * item.GetComponent<Draggable3D_Plane>().transform.SetParent(zT.Find("Dice"));
             * float offsetX = UnityEngine.Random.Range(-.05f, .05f);
             * float offsetY = UnityEngine.Random.Range(-.05f, .05f);
             * item.transform.localPosition = new Vector3(offsetX, offsetY, -.01f);
             */
            DieLogic.moveDie(die, zT.GetComponentInChildren <Zone>());
        }

        adminIncStep();
    }
Esempio n. 7
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);
        }
    }
Esempio n. 8
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;
        }
    }
Esempio n. 9
0
    void Update()
    {
        if (GameState.isPaused)
        {
            return;
        }


        if (Input.GetKeyUp("t"))
        {
            playerLogic.cyclePlayer();
        }
        else if (Input.GetKeyUp("m"))
        {
            adminMoveDie();
        }
        else if (Input.GetKeyUp("i"))
        {
            adminIncScore();
        }
        else if (Input.GetKey("d"))
        {
            DieLogic.drawRollLine();
        }
        else if (Input.GetKeyDown(KeyCode.Space))
        {
            if (stepLogic.canStep())
            {
                updateTurn();
            }
        }

        else if (Input.GetMouseButtonDown(0))
        {
            // CHECK IF ZONE CLICKED
            Zone cZone = gameLayout.clickedZone();


            if (cZone != null)
            {
                string z = cZone.zoneName;
                switch (z)
                {
                case "zoneSupply":
                    Debug.Log("checking if can draw");
                    if (getCurrentAreaS() == gameLayout.checkAreaClick(cZone) &&
                        stepLogic.currentStep == StepLogic.eSteps.SCRY)
                    {
                        drawDice(GameState.handSize);
                    }
                    break;

                case "zoneRoll":
                    moveDice(getCurrentZoneS(z), getCurrentZoneS("zoneServicable"));
                    break;
                }
            }
        }
        else if (Input.GetMouseButtonDown(1))
        {
            //if (Input.GetKeyDown("r"))
            //{

            /*
             * Die die = DieLogic.clickedDie();
             *
             * if (die && stepLogic.currentStep == StepLogic.eSteps.SPIN)
             * {
             *  if (Input.GetKey(KeyCode.LeftShift))
             *  {
             *      GameLogic.instance.rollSimilarDice(die);
             *  }
             *  else
             *  {
             *      SoundControl.instance.setAudio("dice", "rollS");
             *      DieLogic.rollDie(die);
             *  }
             * }
             */
            //}
        }

        if (!GameState.newGame)
        {
            stepLogic.checkStepButton();
        }

        if (stepLogic.currentStep == StepLogic.eSteps.SPEND)
        {
            updateGameState();
        }
    }
Esempio n. 10
0
    public void scoreDice()
    {
        int s = DieLogic.getDiceScore(GameLogic.instance.gameLayout.getDiceInZone("zoneSummoned"));

        updatePlayerScore(s);
    }
Esempio n. 11
0
 public void attack()
 {
     attackValue = DieLogic.getDiceValue(GameLogic.instance.gameLayout.getDiceInZone("zoneSummoned"), Side.eValueTypes.ATTACK);
     Debug.Log(currentPlayer().getPlayerName() + " deals " + attackValue + " damage!");
 }