Exemple #1
0
    public void ActivateNextDK(DiceKey DK, string status, int number)
    {
        int index = 0;

        for (int i = 0; i < diceKeys.Count; i++)
        {
            if (diceKeys[i] == DK)
            {
                index = i;
            }
        }

        if (status == "deactivated")
        {
            diceKeys[index].SetInactive(true, number);
            diceKeys[index].SetGold(false, number);
            diceKeys[index].SetPlatinum(false, number);
            diceKeyImages[index].sprite = diceSpritesInactive[number - 1];
        }
        else if (status == "gold")
        {
            diceKeys[index].SetInactive(false, number);
            diceKeys[index].SetGold(true, number);
            diceKeys[index].SetPlatinum(false, number);
            diceKeyImages[index].sprite = diceSpritesGold[number - 1];
        }
        else if (status == "plat")
        {
            diceKeys[index].SetInactive(false, number);
            diceKeys[index].SetGold(false, number);
            diceKeys[index].SetPlatinum(true, number);
            diceKeyImages[index].sprite = diceSpritesPlatinum[number - 1];
        }
        else
        {
            diceKeys[index].SetInactive(false, number);
            diceKeys[index].SetGold(false, number);
            diceKeys[index].SetPlatinum(false, number);
            diceKeyImages[index].sprite = diceSprites[number - 1];
        }

        DK.SetAssignedStatus(false, number);
        diceKeyNumbers[index] = number;
    }
Exemple #2
0
    public void PressedCancel()
    {
        if (state == BattleState.PLAYERTURN)
        {
            if (!cancelPressed)
            {
                cancelPressed = true;
                bool diceDeselected = false;
                var  go             = EventSystem.current.currentSelectedGameObject;

                for (int i = 0; i < diceObjects.Count; i++)
                {
                    if (diceObjects[i].GetMarkedStatus())
                    {
                        diceDeselected = true;
                        diceObjects[i].SetMarkedStatus(false);
                    }
                }

                //If no die was marked
                if (!diceDeselected)
                {
                    //If the selected dice is a dice key
                    if (go.GetComponent <DiceKey>() != null)
                    {
                        DiceKey pressedDiceKey = go.GetComponent <DiceKey>();

                        foreach (var enemyGO in enemiesGO)
                        {
                            if (enemyGO.GetComponent <EnemyBattleBase>().GetDiceKey() == pressedDiceKey)
                            {
                                enemyGO.GetComponent <EnemyBattleBase>().Assign(false, 0);

                                for (int k = 0; k < diceObjects.Count; k++)
                                {
                                    if (diceObjects[k].GetAssignedTo() == go)
                                    {
                                        diceObjects[k].SetAssignedStatus(false);
                                        diceObjects[k].SetAssignedTo(null);
                                        break;
                                    }
                                }
                                break;
                            }
                        }

                        //if the dicekey was assigned
                        if (pressedDiceKey.GetAssignedStatus())
                        {
                            pressedDiceKey.SetAssignedStatus(false, diceKeyNumbers[diceKeys.IndexOf(pressedDiceKey)]);

                            for (int i = 0; i < diceObjects.Count; i++)
                            {
                                if (diceObjects[i].GetAssignedTo() == pressedDiceKey.gameObject)
                                {
                                    //TODO
                                    Debug.Log("Hejsan");
                                }
                            }
                        }
                    }

                    //If the selected dice is a added one
                    else if (go.GetComponent <Dice>() != null)
                    {
                        Dice pressedDice = go.GetComponent <Dice>();

                        if (!pressedDice.GetInactiveStatus() && !pressedDice.GetAssignedStatus() && !pressedDice.GetLockedStatus())
                        {
                            if (go.GetComponent <Dice>().GetGoldStatus())
                            {
                                if (firstDicePair[1] != -1)
                                {
                                    if (pressedDice == diceObjects[firstDicePair[1]])
                                    {
                                        diceObjects[firstDicePair[1]].SetGold(false, -1);
                                        diceObjects[firstDicePair[0]].SetInactiveStatus(false);
                                        diceNumbers[firstDicePair[1]]      -= diceNumbers[firstDicePair[0]];
                                        diceImages[firstDicePair[1]].sprite = diceSprites[diceNumbers[firstDicePair[1]] - 1];

                                        firstDicePair[0] = -1;
                                        firstDicePair[1] = -1;
                                        buttonPanel.SetEmptyRedText();
                                    }
                                }

                                if (secondDicePair[1] != -1)
                                {
                                    //argument out of range, kan inte cancla nr 2
                                    if (pressedDice == diceObjects[secondDicePair[1]])
                                    {
                                        diceObjects[secondDicePair[1]].SetGold(false, -1);
                                        diceObjects[secondDicePair[0]].SetInactiveStatus(false);
                                        diceNumbers[secondDicePair[1]]      -= diceNumbers[secondDicePair[0]];
                                        diceImages[secondDicePair[1]].sprite = diceSprites[diceNumbers[secondDicePair[1]] - 1];

                                        secondDicePair[0] = -1;
                                        secondDicePair[1] = -1;
                                        buttonPanel.SetEmptyRedText();
                                    }
                                }
                            }

                            else if (go.GetComponent <Dice>().GetPlatinumStatus())
                            {
                                if (thirdDicePair[1] != -1)
                                {
                                    if (pressedDice == diceObjects[thirdDicePair[1]])
                                    {
                                        diceObjects[thirdDicePair[1]].SetPlatinum(false, -1);
                                        diceObjects[thirdDicePair[0]].SetInactiveStatus(false);
                                        diceNumbers[thirdDicePair[1]] -= diceNumbers[thirdDicePair[0]];
                                        diceObjects[thirdDicePair[0]].SetGold(true, diceNumbers[thirdDicePair[0]]);
                                        diceObjects[thirdDicePair[1]].SetGold(true, diceNumbers[thirdDicePair[1]]);
                                        diceImages[thirdDicePair[1]].sprite = diceSpritesGold[diceNumbers[thirdDicePair[1]] - 1];

                                        thirdDicePair[0] = -1;
                                        thirdDicePair[1] = -1;
                                        buttonPanel.SetSplitText();
                                    }
                                }
                            }
                        }
                    }

                    else if (go.GetComponent <BattleAbilityHolder>() != null)
                    {
                        BattleAbilityHolder holder = go.GetComponent <BattleAbilityHolder>();

                        if (holder.GetMarkedStatus())
                        {
                            holder.AbilityClicked();
                        }
                    }
                }
            }

            if (cancelPressed)
            {
                cancelPressed = false;
            }
        }
    }
 public void SetDiceKeyGO(DiceKey diceKey)
 {
     diceKeyGO    = diceKey;
     diceKeyImage = diceKeyGO.GetComponent <Image>();
 }