private IEnumerator SimpleMeleeSwing(int damage, float reach, float swingTime, Kit.ItemData data, LayerMask hitMask, bool backSlash, bool isMain) { bool hit = false; float t = 0; //mainHand.itemSprite.sprite = data.itemSprite; while (t < swingTime) { if (!hit) { Collider2D[] hitObjects = Physics2D.OverlapCircleAll(mainHand.handTransform.position, reach, hitMask); if (hitObjects.Length > 0) { hit = true; for (int i = 0; i < hitObjects.Length; i++) { Debug.Log(hitObjects[i].name); } } } mainHand.itemSprite.sprite = data.itemActiveSprite; mainHand.itemSprite.flipX = backSlash; t += Time.deltaTime; yield return(new WaitForEndOfFrame()); } mainHand.itemSprite.sprite = data.itemSprite; mainHand.itemSprite.flipX = false; }
public void StopBlock(Kit.ItemData mainData, Kit.ItemData offData) { StopAllCoroutines(); blocking = false; lineRenderer.enabled = false; edgeCollider.enabled = false; currentAimStretch = baseAimStretch; mainHand.doesItemPoint = true; offHand.doesItemPoint = false; mainHand.itemSprite.sprite = mainData.itemSprite; offHand.itemSprite.sprite = offData.itemSprite; }
public void Block(int blockStrength, float blockArcWidth, float blockArcHeight, float counterTime, float stretchOverride, Kit.ItemData mainData, Kit.ItemData offData) { //Switch hand and held item to block sprite (sideways shield) mainHand.doesItemPoint = true; offHand.doesItemPoint = false; //Swap sprite for hands mainHand.itemSprite.sprite = offData.itemActiveSprite; offHand.itemSprite.sprite = mainData.itemSprite; //Increase stretch to push shield further out currentAimStretch = stretchOverride; blocking = true; //Activate blocking async process StartCoroutine(Blocking(blockStrength, blockArcHeight, blockArcWidth, counterTime)); }
public void SimpleMelee(int damage, float reach, float swingTime, Kit.ItemData itemData, LayerMask hitMask, bool backSlash, bool isMain) { StopCoroutine("SimpleMelee"); StartCoroutine(SimpleMeleeSwing(damage, reach, swingTime, itemData, hitMask, backSlash, isMain)); }