public void Attack(Vector3 dir) { // Attack Vector3 boltShootDir = (GetMouseWorldPosition() - transform.position).normalized; float boltOffset = 10f; Vector3 boltSpawnPosition = transform.position + boltShootDir * boltOffset; ProjectileBolt.Create(boltSpawnPosition, boltShootDir); SetStateAttacking(); Vector3 attackDir = boltShootDir; Transform swordSlashTransform = Instantiate(GameAssets.i.pfSwordSlash, GetPosition() + attackDir * 13f, Quaternion.Euler(0, 0, GetAngleFromVector(attackDir))); swordSlashTransform.GetComponent <SpriteAnimator>().onLoop = () => Destroy(swordSlashTransform.gameObject); UnitAnimType activeAnimType = characterBase.GetUnitAnimation().GetActiveAnimType(); if (activeAnimType == GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword) { swordSlashTransform.localScale = new Vector3(swordSlashTransform.localScale.x, swordSlashTransform.localScale.y * -1, swordSlashTransform.localScale.z); characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword2, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } else { characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } }
public void Attack() { // Attack SetStateAttacking(); Vector3 attackDir = (UtilsClass.GetMouseWorldPosition() - GetPosition()).normalized; //transform.position = transform.position + attackDir * 4f; Transform swordSlashTransform = Instantiate(GameAssets.i.pfSwordSlash, GetPosition() + attackDir * 13f, Quaternion.Euler(0, 0, UtilsClass.GetAngleFromVector(attackDir))); swordSlashTransform.GetComponent <SpriteAnimator>().onLoop = () => Destroy(swordSlashTransform.gameObject); UnitAnimType activeAnimType = characterBase.GetUnitAnimation().GetActiveAnimType(); if (activeAnimType == GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword) { swordSlashTransform.localScale = new Vector3(swordSlashTransform.localScale.x, swordSlashTransform.localScale.y * -1, swordSlashTransform.localScale.z); characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword2, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } else { characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } }
public void CinematicLookDown(float timer) { state = State.Busy; rigidbody3D.velocity = Vector3.zero; //characterBase.GetUnitAnimation().PlayAnimForced(UnitAnimType.GetUnitAnimType(""), new Vector3(0, -1), 1f, null, null, null); characterBase.GetUnitAnimation().PlayAnimForced(UnitAnim.GetUnitAnim("dBareHands_Victory"), 1f, null, null, null); FunctionTimer.Create(() => { state = State.Normal; }, timer); }
private void HandleAttack() { if (Input.GetMouseButtonDown(0)) { // Attack SetStateAttacking(); Vector3 attackDir = (GetMouseWorldPosition() - GetPosition()).normalized; EnemyHandler enemyHandler = EnemyHandler.GetClosestEnemy(GetPosition() + attackDir * 4f, 20f); if (enemyHandler != null) { //enemyHandler.Damage(this); if (enemyHandler.IsDead()) { OnEnemyKilled?.Invoke(this, EventArgs.Empty); } attackDir = (enemyHandler.GetPosition() - GetPosition()).normalized; transform.position = enemyHandler.GetPosition() + attackDir * -12f; } else { transform.position = transform.position + attackDir * 4f; } Transform swordSlashTransform = Instantiate(GameAssets.i.pfSwordSlash, GetPosition() + attackDir * 13f, Quaternion.Euler(0, 0, GetAngleFromVector(attackDir))); swordSlashTransform.GetComponent <SpriteAnimator>().onLoop = () => Destroy(swordSlashTransform.gameObject); UnitAnimType activeAnimType = characterBase.GetUnitAnimation().GetActiveAnimType(); if (activeAnimType == GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword) { swordSlashTransform.localScale = new Vector3(swordSlashTransform.localScale.x, swordSlashTransform.localScale.y * -1, swordSlashTransform.localScale.z); characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword2, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } else { characterBase.GetUnitAnimation().PlayAnimForced(GameAssets.UnitAnimTypeEnum.dSwordTwoHandedBack_Sword, attackDir, 1f, (UnitAnim unitAnim) => SetStateNormal(), null, null); } } }