protected virtual void UpdateSkill() { if (_coolTick == 0) { // 유효한 타겟 if (_target == null || _target.Room != Room || _target.HP <= 0) { _target = null; State = CreatureState.Moving; BroadCastMove(); return; } // 스킬이 아직 사용 가능한지 Vector2int dir = (_target.CellPos - CellPos); int dist = dir.cellDistFromZero; bool canUseSkill = (dist <= _skillRange && (dir.x == 0 || dir.y == 0)); if (canUseSkill == false) { State = CreatureState.Moving; BroadCastMove(); return; } // 타게팅 방향 주시 MoveDir lookDir = GetDirFromVec(dir); if (Dir != lookDir) { Dir = lookDir; BroadCastMove(); } SKill skilldata = null; DataManager.SkillDict.TryGetValue(1, out skilldata); // 데미지 판정 _target.OnDamaged(this, skilldata.damage + Stat.Attack); // 스킬 사용 BroadCast S_Skill skillPacket = new S_Skill() { Info = new SKillInfo() }; skillPacket.ObjectId = Id; skillPacket.Info.Skillid = skilldata.id; Room.BroadCast(skillPacket); // 스킬 쿨타임 적용 int coolTick = (int)(1000 * skilldata.cooldown); _coolTick = Environment.TickCount64 + coolTick; } if (_coolTick > Environment.TickCount64) { return; } _coolTick = 0; }
void Update() { timer += Time.deltaTime; if (timer >= timeBetweenAttacks) { isAttacking = false; isCharging = false; timer = 0f; } if (isGlobalCoolDown) { GlobalCurrent += Time.deltaTime; if (GlobalCurrent >= GlobalMax) { isGlobalCoolDown = false; GlobalCurrent = 0; } } #region Melee Controls if (meleeWeapon.activeInHierarchy) { timeBetweenAttacks = .75f; GetComponent <Animator>().SetBool("isSword1", isAttacking); if (Input.GetMouseButtonDown(0) && UI.stealControl == false) { if (playerHealth.currentHealth > 0 && !isAttacking) { isAttacking = true; // says player is attacking hitBox.ChanageStatus(0); meleeWeapon.GetComponent <AudioSource>().Play(); } } } #endregion #region Ranged Controls else if (rangeWeapon.activeInHierarchy) { timeBetweenAttacks = 0.75f; if (Input.GetMouseButton(0) && UI.stealControl == false) // holding left mouse button { if (playerHealth.currentHealth > 0 && !isReticleActive && !isAttacking) { isCharging = true; } } if (isCharging) { RaiseAccuracy(); GetComponent <Animator>().SetBool("isCharging", true); } else { ContinueAnimation(); } if (Input.GetMouseButtonUp(0) && UI.stealControl == false) // releasing left mouse button { if (playerHealth.currentHealth > 0 && !isReticleActive && isCharging) { ContinueAnimation(); isCharging = false; BowSkills BS = FindObjectOfType <BowSkills>(); if (BS.playerAnimator.GetBool("isRainingDown") == false) { Shoot(); } else { viewMesh.Clear(); } rangeWeapon.GetComponent <AudioSource>().Play(); GetComponent <Animator>().SetBool("isCharging", false); } } if (Input.GetMouseButtonDown(0) && UI.stealControl == false && isReticleActive) // clicking left mouse button { BowSkills BS = FindObjectOfType <BowSkills>(); if (BS.target.activeInHierarchy == true) { RangedSlot4Placeholder Rslot4 = FindObjectOfType <RangedSlot4Placeholder>(); Rslot4.GetComponentInChildren <SKill>().VolleyActivate(); BS.playerAnimator.SetBool("isRainingDown", true); BS.target.SetActive(false); isReticleActive = false; } } } #endregion #region Skill Controls if (Input.GetKeyDown(KeyCode.Alpha1) && !isAttacking) { Slot1Placeholder slot1 = FindObjectOfType <Slot1Placeholder>(); slot1.GetComponentInChildren <SKill>().ActivateSkill(); } if (Input.GetKeyDown(KeyCode.Alpha2) && !isAttacking) { Slot2Placeholder slot2 = FindObjectOfType <Slot2Placeholder>(); slot2.GetComponentInChildren <SKill>().ActivateSkill(); } if (Input.GetKeyDown(KeyCode.Alpha3) && !isAttacking) { Slot3Placeholder slot3 = FindObjectOfType <Slot3Placeholder>(); slot3.GetComponentInChildren <SKill>().ActivateSkill(); } if (Input.GetKeyDown(KeyCode.Alpha4) && !isAttacking) { RangedSlot4Placeholder rSlot4 = FindObjectOfType <RangedSlot4Placeholder>(); Slot4Placeholder slot4 = FindObjectOfType <Slot4Placeholder>(); if (meleeWeapon.activeInHierarchy) { slot4.GetComponentInChildren <SKill>().ActivateSkill(); } else if (rangeWeapon.activeInHierarchy) { rSlot4.GetComponentInChildren <SKill>().ReticleCall(); } } if (Input.GetKeyDown(KeyCode.Tab)) { GameObject slotQ = FindObjectOfType <SlotQPlaceholder>().gameObject; SKill currentSkill = slotQ.GetComponentInChildren <SKill>(); if (currentSkill.onCooldown == false) { if (playerHealth.currentHealth >= 0 || playerHealth.currentHealth < playerHealth.healthMax) { playerHealth.currentHealth += 15; healthParticle.Play(); currentSkill.onCooldown = true; } else { return; } } } #endregion }