public void AttackOnFace(float duration, int face) { int numFaces = ground.rings[0].sections.Count; int numRings = ground.rings.Count; int playerRingPosCorrected = playerCtrl.ringIndex + numRings; int playerSectPosCorrected = playerCtrl.faceIndex + numFaces; hurtingFaces = new bool[numRings, numFaces]; for (int i = 0; i < numRings; i++) { GroundSections attackRing = Instantiate(attackRingPrefab, new Vector3(0, 0.1f, 0), Quaternion.identity); GroundColorChanger attackRingControl = attackRing.GetComponent <GroundColorChanger>(); hurtingFaces[i, face] = true; attackRing.rings[i].sections[face].gameObject.SetActive(true); attackRingControl.ChangeColor(i, face, damageMat); gcc.ChangeColorDelayed(i, face, damageMat, duration); ground.SwitchFaceDelayed(i, face, duration); ground.rings[i].sections[face].isTarget = true; if (i == 0) { StartCoroutine(AttackCoroutine(duration, attackRing, new Vector3(0, 2, 0), new Vector3(2, 2, 2))); } else { StartCoroutine(AttackCoroutine(duration, attackRing, new Vector3(4, 2, 4), new Vector3(2, 2, 2))); } } }
private IEnumerator AttackCoroutine(float duration, GroundSections attackRing, int targetRing) { Transform tr = attackRing.GetComponent <Transform>(); Vector3 finalScale = new Vector3(2, 2, 2); Vector3 startScale; if (targetRing == 0) { startScale = new Vector3(0, 2, 0); } else { startScale = new Vector3(4, 2, 4); } float tLerp = 0; while (tLerp <= duration) { tr.localScale = Vector3.Lerp(startScale, finalScale, tLerp / duration); tLerp += Time.deltaTime; yield return(null); } Destroy(tr.gameObject); }
private IEnumerator AttackCoroutine(float duration, GroundSections attackRing, Vector3 startScale, Vector3 endScale) { Transform tr = attackRing.GetComponent <Transform>(); float tLerp = 0; while (tLerp <= duration) { tr.localScale = Vector3.Lerp(startScale, endScale, tLerp / duration); tLerp += Time.deltaTime; yield return(null); } Destroy(tr.gameObject); }
public void AttackOnFace(float duration, int face) { GroundSections attackRing = Instantiate(attackRingPrefab, Vector3.zero, Quaternion.identity); GroundColorChanger attackRingControl = attackRing.GetComponent <GroundColorChanger>(); int numFaces = playerGround.rings[0].sections.Count; int numRings = playerGround.rings.Count; int playerRingPosCorrected = player.ringIndex + numRings; int playerSectPosCorrected = player.faceIndex + numFaces; hurtingFaces = new bool[numRings, numFaces]; hurtingFaces[player.ringIndex, face] = true; attackRing.rings[player.ringIndex].sections[face].gameObject.SetActive(true); attackRingControl.ChangeColor(player.ringIndex, face, damageMat); playerGroundControl.ChangeColorDelayed(player.ringIndex, face, damageMat, duration); playerGround.SwitchFaceDelayed(player.ringIndex, face, duration); playerGround.rings[0].sections[face].isTarget = true; StartCoroutine(AttackCoroutine(duration, attackRing)); }
public override void StartAttack(float duration) { GroundSections attackRing = Instantiate(attackRingPrefab, new Vector3(0, 0.1f, 0), Quaternion.identity); GroundColorChanger attackRingControl = attackRing.GetComponent <GroundColorChanger>(); if (firstAtt) { targetRing = playerCtrl.ringIndex; for (int i = 0; i < ground.rings[targetRing].sections.Count; i++) { attackRing.rings[targetRing].sections[i].gameObject.SetActive(true); attackRingControl.ChangeColor(targetRing, i, damageMat); gcc.ChangeColorDelayed(targetRing, i, damageMat, duration); ground.SwitchFaceDelayed(targetRing, i, duration); ground.rings[targetRing].sections[i].isTarget = true; } StartCoroutine(FindTargetFaces(targetRing, duration - 0.15f)); StartCoroutine(AttackCoroutine(duration, attackRing, targetRing)); firstAtt = false; } else { targetRing = (targetRing + 1) % 2; for (int i = 0; i < ground.rings[targetRing].sections.Count; i++) { attackRing.rings[targetRing].sections[i].gameObject.SetActive(true); attackRingControl.ChangeColor(targetRing, i, damageMat); gcc.ChangeColorDelayed(targetRing, i, damageMat, duration); ground.SwitchFaceDelayed(targetRing, i, duration); ground.rings[targetRing].sections[i].isTarget = true; attackRing.rings[(targetRing + 1) % 2].sections[i].gameObject.SetActive(false); ground.SwitchFaceDelayed((targetRing + 1) % 2, i, false, duration); } StartCoroutine(FindTargetFaces(targetRing, duration - 0.15f)); StartCoroutine(AttackCoroutine(duration, attackRing, targetRing)); } }
public override void StartAttack(float duration) { if (firstAtt) { GroundSections attackRing1 = Instantiate(attackRingPrefab, new Vector3(0, 0.1f, 0), Quaternion.identity); GroundSections attackRing2 = Instantiate(attackRingPrefab, new Vector3(0, 0.1f, 0), Quaternion.identity); GroundColorChanger attackRingControl1 = attackRing1.GetComponent <GroundColorChanger>(); GroundColorChanger attackRingControl2 = attackRing2.GetComponent <GroundColorChanger>(); numFaces = ground.rings[0].sections.Count; numRings = ground.rings.Count; Debug.Assert(numRings == 2); int playerRingPosCorrected = playerCtrl.ringIndex + numRings; int playerSectPosCorrected = playerCtrl.faceIndex + numFaces; int ringIndex = playerCtrl.ringIndex; for (int i = 0; i < numFaces; i++) { if ((i + numFaces + 1) % numFaces == playerCtrl.faceIndex || (i + numFaces - 1) % numFaces == playerCtrl.faceIndex) { ground.rings[ringIndex].sections[i].isTarget = false; hurtingFaces[ringIndex, i] = false; hurtingFaces[(ringIndex + 1) % numRings, i] = true; attackRing2.rings[(ringIndex + 1) % numRings].sections[i].gameObject.SetActive(true); attackRingControl2.ChangeColor((ringIndex + 1) % numRings, i, damageMat); gcc.ChangeColorDelayed((ringIndex + 1) % numRings, i, damageMat, duration); ground.SwitchFaceDelayed((ringIndex + 1) % numRings, i, duration); } else { hurtingFaces[ringIndex, i] = true; hurtingFaces[(ringIndex + 1) % numRings, i] = false; attackRing1.rings[ringIndex].sections[i].gameObject.SetActive(true); attackRingControl1.ChangeColor(ringIndex, i, damageMat); gcc.ChangeColorDelayed(ringIndex, i, damageMat, duration); ground.SwitchFaceDelayed(ringIndex, i, duration); } } if (ringIndex == 0) { StartCoroutine(AttackCoroutine(duration, attackRing1, new Vector3(0, 2, 0), new Vector3(2, 2, 2))); StartCoroutine(AttackCoroutine(duration, attackRing2, new Vector3(4, 2, 4), new Vector3(2, 2, 2))); } else { StartCoroutine(AttackCoroutine(duration, attackRing1, new Vector3(4, 2, 4), new Vector3(2, 2, 2))); StartCoroutine(AttackCoroutine(duration, attackRing2, new Vector3(0, 2, 0), new Vector3(2, 2, 2))); } StartCoroutine(FindTargetFaces(hurtingFaces, duration - 0.15f)); firstAtt = false; } else { for (int i = 0; i < numRings; i++) { GroundSections attackRing = Instantiate(attackRingPrefab, new Vector3(0, 0.1f, 0), Quaternion.identity); GroundColorChanger attackRingControl = attackRing.GetComponent <GroundColorChanger>(); for (int j = 0; j < numFaces; j++) { hurtingFaces[i, j] = !hurtingFaces[i, j]; if (hurtingFaces[i, j]) { attackRing.rings[i].sections[j].gameObject.SetActive(true); attackRingControl.ChangeColor(i, j, damageMat); gcc.ChangeColorDelayed(i, j, damageMat, duration); ground.SwitchFaceDelayed(i, j, true, duration); } else { attackRing.rings[i].sections[j].gameObject.SetActive(false); ground.SwitchFaceDelayed(i, j, false, duration); } } if (i == 0) { StartCoroutine(AttackCoroutine(duration, attackRing, new Vector3(0, 2, 0), new Vector3(2, 2, 2))); } else { StartCoroutine(AttackCoroutine(duration, attackRing, new Vector3(4, 2, 4), new Vector3(2, 2, 2))); } } StartCoroutine(FindTargetFaces(hurtingFaces, duration - 0.15f)); } }
public void StartAttack(float duration) { GroundSections attackRing = Instantiate(attackRingPrefab, Vector3.zero, Quaternion.identity); GroundColorChanger attackRingControl = attackRing.GetComponent <GroundColorChanger>(); if (firstAtt) { int numFaces = playerGround.rings[0].sections.Count; int numRings = playerGround.rings.Count; Debug.Assert(numRings == 1); int playerRingPosCorrected = player.ringIndex + numRings; int playerSectPosCorrected = player.faceIndex + numFaces; hurtingFaces = new bool[numRings, numFaces]; for (int i = 0; i < playerGround.rings.Count; i++) { for (int j = 0; j < playerGround.rings[i].sections.Count; j++) { if ((j + numFaces + 1) % numFaces == player.faceIndex || (j + numFaces - 1) % numFaces == player.faceIndex) { hurtingFaces[i, j] = false; playerGround.rings[i].sections[j].isTarget = false; } else { hurtingFaces[i, j] = true; attackRing.rings[i].sections[j].gameObject.SetActive(true); attackRingControl.ChangeColor(i, j, damageMat); playerGroundControl.ChangeColorDelayed(i, j, damageMat, duration); playerGround.SwitchFaceDelayed(i, j, duration); } } } StartCoroutine(FindTargetFaces(hurtingFaces, duration - 0.15f)); StartCoroutine(AttackCoroutine(duration, attackRing)); firstAtt = false; } else { for (int i = 0; i < playerGround.rings.Count; i++) { for (int j = 0; j < playerGround.rings[i].sections.Count; j++) { hurtingFaces[i, j] = !hurtingFaces[i, j]; if (hurtingFaces[i, j]) { attackRing.rings[i].sections[j].gameObject.SetActive(true); attackRingControl.ChangeColor(i, j, damageMat); playerGroundControl.ChangeColorDelayed(i, j, damageMat, duration); playerGround.SwitchFaceDelayed(i, j, true, duration); } else { attackRing.rings[i].sections[j].gameObject.SetActive(false); playerGround.SwitchFaceDelayed(i, j, false, duration); } } } StartCoroutine(FindTargetFaces(hurtingFaces, duration - 0.15f)); StartCoroutine(AttackCoroutine(duration, attackRing)); } }