public GameObject InstantiateHitBox(AttackInfo attackInfo, Transform transform_attacker) //attacker의 transform을 기준으로 DamagingCollider 생성 { BoxCollider2D damagingCollider_Collider2D = Instantiate(_damagingCollider, transform_attacker.position, Quaternion.identity).GetComponent <BoxCollider2D>(); DamagingCollider damagingCollider = damagingCollider_Collider2D.gameObject.GetComponent <DamagingCollider>(); damagingCollider_Collider2D.size = attackInfo.attackRange; Vector3 tempV3 = damagingCollider_Collider2D.transform.position; tempV3.x += attackInfo.hitBoxPostion.x * (int)transform_attacker.GetComponentInParent <Character>().Direction; tempV3.y += attackInfo.hitBoxPostion.y; damagingCollider_Collider2D.transform.position = tempV3; damagingCollider.damage = attackInfo.damage; if (PlayManager.Instance.isTestMode) { damagingCollider.ChangeSprite(attackInfo.attackRange); } damagingCollider.gameObject.transform.SetParent(transform_attacker); damagingCollider.DestroyCollider(attackInfo.duration); damagingCollider.parentTransform = transform_attacker; return(damagingCollider.gameObject); }
private void Start() { cameraShaker = GetComponent <CinemachineImpulseSource>(); damageColl = GetComponentInChildren <DamagingCollider>(); damageColl.Damage = impactDamage; DeactivateAttack(); animator.SetFloat("speedMultiplier", rpm / 60f); }
private void PlayCurrentAnimation() { animationOver = false; if (currentAnimation != null) { Frame currentFrame = currentAnimation.frames[animTimer]; spr.sprite = currentFrame.sprite; if (hubM != null) { hubM.SetHurtboxes(currentFrame); } if (hibM != null) { hibM.DrawHitboxes(currentFrame); } if (ctr != null) { Vector2 forceMovement = currentFrame.forceMovement; Vector2 addMovement = currentFrame.addMovment; if (spr.flipX) { forceMovement.x *= -1; addMovement.x *= -1; } ctr.forceMovement += forceMovement; ctr.addMovement = addMovement; if (currentFrame.spawnProjectile != Vector2.zero) { Character chr = GetComponent <Character>(); if (chr != null) { chr.RaiseSpawnProjectileEvent(chr, currentFrame.spawnProjectile); } if (SpawnProjectile != null) { SpawnProjectile(transform.position, currentFrame.spawnProjectile); } } ctr.resetVelocity = currentFrame.resetVelocity; } if (currentFrame.spawnHoldItem != null) { Player player = GetComponent <Player>(); if (player != null) { GameObject holdItem = Instantiate(currentFrame.spawnHoldItem, transform); Item pickUpItem = holdItem.GetComponent <Item>(); if (pickUpItem is ICanBePickedUp) { player.ReleaseHoldItem(); player.SetHoldItem(pickUpItem); } } else { GameObject spawnItem = Instantiate(currentFrame.spawnHoldItem, transform.position, Quaternion.identity); DamagingCollider damagingCollider = spawnItem.GetComponent <DamagingCollider>(); if (damagingCollider == null) { return; } damagingCollider.damage.Owner = player; damagingCollider.damage.attackType = EAttackType.Item; } } if (frameTimer == 0 && currentFrame.soundName != "") { AudioManager.PlaySound(currentFrame.soundName, spr.transform.position); } frameTimer += animationSpeed; if (frameTimer >= currentAnimation.frames[animTimer].duration) { animTimer++; frameTimer = 0; } if (animTimer >= currentAnimation.frames.Count) { animTimer = 0; animationOver = true; if (AnimationOver != null) { AnimationOver(currentAnimation); } } } else { Debug.Log("Current animation == null."); } }