private bool OnMouseClickSelectAttackTarget() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100.0f)) { Node node = hit.transform.parent.GetComponent <Node>(); if (node) { node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected)); MagicCursor.Instance.MoveTo(node); if (CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary && node.steps.Count > 0) { int resultAttackA = UnityEngine.Random.Range(0, 6); int resultAttackB = UnityEngine.Random.Range(0, 6); int resultDefendA = UnityEngine.Random.Range(0, 6); int resultDefendB = UnityEngine.Random.Range(0, 6); // Debug.LogError($"AttackA : {resultAttackA}, DefendA {resultDefendA}"); // Debug.LogError($"AttackB : {resultAttackB}, DefendB {resultDefendB}"); PhotonNetworkRaiseEvent(EventCode.SelectNodeAttack, new object[] { node.nid, resultAttackA, resultAttackB, resultDefendA, resultDefendB }); return(true); } } } return(false); } else { return(false); } }
private void ReceiveNodeSkillSelected(Node node, BaseSkill skill) { node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected)); MagicCursor.Instance.MoveTo(node); switch (skill.TargetType) { case TargetType.Self: if (node.TileProperty.Type != TileType.Sanctuary) { m_cameraController.Show(CameraType.Action); ResetNodeColor(); skill.OnActivate(m_currentPlayer.Poring); isSelectedTargetSkill = true; } break; case TargetType.Another: if (node.steps.Count > 0 && CheckAnotherPoringInTargetNode(node)) { isSelectedTargetSkill = SkillSelectPoringTarget(skill, node); } break; case TargetType.Tile: if (node.steps.Count > 0) { isSelectedTargetSkill = SkillSelectTile(skill, node); } break; } }
public override void UpdateGameMode() { switch (state) { case DokaponGameState.focus: if (currentPoring == null) { return; } float distance = Vector3.Distance(currentPoring.transform.position, currentCamera.transform.position); //print(distance); if (distance < 11.2f) { state = DokaponGameState.roll; m_timeForRoll = TimeForRoll; // panelRoll.SetRoll(6); } break; case DokaponGameState.roll: m_timeForRoll -= Time.deltaTime; if (m_timeForRoll < 0) { Roll(); } break; case DokaponGameState.plan: if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100.0f)) { Node node = hit.transform.parent.GetComponent <Node>(); if (node) { Debug.Log("You selected the " + node.nid); SFX.PlayClip(resource.sound[0]).GetComponent <AudioSource>().time = 0.3f; node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected)); if (node.steps.Count > 0) { MagicCursor.Instance.MoveTo(node); Route.Clear(); // PathToNode(node); // foreach (Node n in PathToNode(node)) { // s += n.nid + ", "; // } RouteToNode(node); // foreach (List) //print(GetNodeString(PathToNode(node))); // print(s); foreach (List <Node> r in Route) { print(GetNodeString(r)); } } } } } break; } }
private void ReceiveNodeSelected(Node node, int attackA, int attackB, int defendA, int defendB) { if (node) { // Debug.Log("You selected the " + node.nid); // SFX.PlayClip(resource.sound[0]).GetComponent<AudioSource>().time = 0.3f; node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected)); MagicCursor.Instance.MoveTo(node); if (node == m_currentPlayer.Poring.Node && CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary) { List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring); m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)]; m_currentPlayer.Poring.AttackResultIndex = attackA; m_currentPlayer.Poring.DefendResultIndex = defendA; m_currentPlayer.Poring.Target.AttackResultIndex = attackB; m_currentPlayer.Poring.Target.DefendResultIndex = defendB; m_cameraController.Show(CameraType.Action); isSelectedNode = true; ResetNodeColor(); CurrentGameState = eStateGameMode.Encounter; } else if (node.steps.Count > 0 && (CheckAnotherPoringInTargetNode(node) || node.steps.Find(step => step == m_step) == m_step)) { MagicCursor.Instance.MoveTo(node); if (CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary) { List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring); m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)]; m_currentPlayer.Poring.AttackResultIndex = attackA; m_currentPlayer.Poring.DefendResultIndex = defendA; m_currentPlayer.Poring.Target.AttackResultIndex = attackB; m_currentPlayer.Poring.Target.DefendResultIndex = defendB; RouteList.Clear(); FindRouteNode(m_step, 0, m_currentPlayer.Poring.Node, m_currentPlayer.Poring.PrevNode); RouteList = FindTargetRoute(RouteList, node); } else if (node.steps.Find(step => step == m_step) == m_step) { m_currentPlayer.Poring.Target = null; RouteList.Clear(); RouteToNode(node); } int indexRoute = Random.Range(0, RouteList.Count - 1); // TODO send result route to rendar path with UI m_currentPlayer.Poring.Behavior.SetupJumpToNodeTarget(RouteList[indexRoute]); m_cameraController.Show(CameraType.Action); isSelectedNode = true; ResetNodeColor(); } } }
private void OnEvent(EventData photonEvent) { object[] data = (object[])photonEvent.CustomData; switch (photonEvent.Code) { // Move case (byte)EventCode.BeginRollMove: BeginRollMove((int)data[0], (int)data[1]); break; case (byte)EventCode.SelectNodeMove: ReceiveNodeSelected(GetNodeByNodeId((int)data[0]), (int)data[1], (int)data[2], (int)data[3], (int)data[4]); break; // Attack case (byte)EventCode.SelectNodeAttack: Node node = GetNodeByNodeId((int)data[0]); if (!IsMineTurn()) { node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected)); MagicCursor.Instance.MoveTo(node); } ReceiveNodeAttackTarget(node, (int)data[1], (int)data[2], (int)data[3], (int)data[4]); break; case (byte)EventCode.HighlightNodeAttack: CheckHasTargetInRange((int)data[0]); DisplayNodeHeatByAttackRange(); if (IsMineTurn()) { StartCoroutine(WaitForSelectTarget()); } break; // Use skill case (byte)EventCode.SelectNodeSkill: ReceiveNodeSkillSelected(GetNodeByNodeId((int)data[0]), GetSkillOfPoring((string)data[1], (int)data[2])); break; case (byte)EventCode.HighlightNodeSkill: BaseSkill skill = GetSkillOfPoring((string)data[0], (int)data[1]); ParseSelectableNode(skill); DisplayNodeHeatBySkill(skill); if (IsMineTurn()) { StartCoroutine(WaitForSelectTarget(skill)); } break; // Roll end case (byte)EventCode.RollEnd: Poring poring = m_player[(int)data[2]]; OnRollEnd((int)data[0], (DiceType)((int)data[1]), poring); break; // On click cancel case (byte)EventCode.OnClickCancel: ResetNodeColor(); break; case (byte)EventCode.SkipToEndTurn: CameraController.Instance.Show(CameraType.Default); CurrentGameState = eStateGameMode.EndTurn; break; } }