private void onDiceRoll(DiceRollEvent data) { var component = Instantiate(RollDiceComp, transform) as RollDiceComponent; component.NumberToDisplay = data.diceUsed.GetDiceResult(); uiQueue.Enqueue(component); }
private void registerEvents() { StartOfTurnEvent.RegisterListener(onStartOfTurn); DiceRollEvent.RegisterListener(onDiceRoll); PlayerDecisionEvent.RegisterListener(onPlayerAction); PlayerWonEvent.RegisterListener(onPlayerWon); }
private void fireDiceEvent() { DiceRollEvent eventRoll = new DiceRollEvent(); eventRoll.diceUsed = this; eventRoll.result = currentResult; eventRoll.FireEvent(); }
public void InitiateDiceEvent(DiceRollEvent diceRollEvent) { Debug.Log("Event Initiated"); m_diceRollEvent = diceRollEvent; m_diceRollResults = new List <int>(); if (DiceEventSetup != null) { DiceEventSetup(); } }
private void RecieveDiceResults(List <int> diceResults) { if (m_shootingPhase == ShootingPhase.ShootingToHit) { int numberOfHits = 0; for (int i = 0; i < diceResults.Count; i++) { if (diceResults[i] >= 6 - m_unitView.UnitData.shootingSkill) { numberOfHits++; } } if (numberOfHits > 0) { DiceRollEvent diceRollEvent = new DiceRollEvent(m_playerCamera, numberOfHits, RecieveDiceResults); GameManager.Instance.DiceManager.InitiateDiceEvent(diceRollEvent); m_shootingPhase = ShootingPhase.ShootingToWound; } else { m_unitShootingComplete.Invoke(); m_unitShootingGuide.DisableShootingGuide(); } } else if (m_shootingPhase == ShootingPhase.ShootingToWound) { int diceRollNeeded = WoundChart.ValueNeededToCauseAWound(m_targetView.UnitData.defense, m_unitView.UnitData.strength); int numberOfWoundsCaused = 0; for (int j = 0; j < diceResults.Count; j++) { if (diceResults[j] >= 0) { Debug.Log("Wound!!"); numberOfWoundsCaused++; } } if (numberOfWoundsCaused > 0) { m_targetView.PhotonView.RPC("RemoveHealthPoints", PhotonTargets.All, numberOfWoundsCaused); } m_unitShootingComplete.Invoke(); m_unitShootingGuide.DisableShootingGuide(); } }
private void SearchForTarget() { Ray ray = m_playerCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Vector3 targetPosition = Vector3.zero; bool hasValidHitPoint = false; bool hasValidTarget = false; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.collider.CompareTag("Ground")) { hasValidHitPoint = true; targetPosition = hit.point; } if (hit.collider.CompareTag("EnemyUnit")) { if (m_targetTransform == null || m_targetTransform != hit.transform) { m_targetTransform = hit.transform; m_targetView = m_targetTransform.GetComponent <UnitView>(); } hasValidTarget = IsValidTarget(m_targetTransform); hasValidHitPoint = true; targetPosition = m_targetTransform.position; if (hasValidTarget) { if (Input.GetMouseButton(0)) { DiceRollEvent diceRollEvent = new DiceRollEvent(m_playerCamera, m_rangedWeaponData.numberOfShots, RecieveDiceResults); GameManager.Instance.DiceManager.InitiateDiceEvent(diceRollEvent); this.enabled = false; } } } } m_unitShootingGuide.SetShootingGuide(targetPosition, hasValidTarget, hasValidHitPoint); }