// Update is called once per frame void Update() { if (buttonDown && !passCompleted) { if (eventSystem.currentSelectedGameObject != null) { savedSelectedGameObject = eventSystem.currentSelectedGameObject; audioManager.Play("Passing"); } eventSystem.SetSelectedGameObject(null); buttonPanel.SetEmptyRedText(); buttonPanel.SetEmptyGreenText(); buttonPanel.SetEmptyBlueText(); buttonDownTimer += Time.deltaTime; if (buttonDownTimer >= requiredHoldTime) { if (passCompleted == false) { passCompleted = true; completedImage.SetActive(true); fillImage.gameObject.SetActive(false); PassCompleted(); } } fillImage.fillAmount = buttonDownTimer / requiredHoldTime; } else if (!passCompleted) { if (buttonDownTimer > 0) { buttonDownTimer -= Time.deltaTime; if (buttonDownTimer < 0) { buttonDownTimer = 0; } fillImage.fillAmount = buttonDownTimer / requiredHoldTime; } } }
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; } } }