void SendAbilities() { foreach (KeyValuePair <AbilityType, Player.AbilityInfo> abilityPair in _abilities) { Player.AbilityInfo abilityInfo = abilityPair.Value; if (Input.GetKeyUp(abilityInfo.keyCode) && abilityInfo.cooldown <= 0) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Vector3 targetPosition = hit.point; switch (abilityPair.Key) { case AbilityType.AUTOATTACK: targetPosition.y = _player.transform.position.y; SendAutoAttack(abilityInfo, targetPosition); break; case AbilityType.FREEZE: SendFreeze(abilityInfo, targetPosition); break; case AbilityType.FLASH: SendFlash(abilityInfo, targetPosition); break; } } } } }
private void SendFreeze(Player.AbilityInfo ability, Vector3 targetPosition) { if (IsInRange(targetPosition, ability.range)) { ability.cooldown = _player.freezeInfo.cooldown; _gameController.SendBroadcast(new AbilityInput(_id, AbilityType.FREEZE, targetPosition), true); } }
private Player.AbilityInfo Copy(Player.AbilityInfo abilityInfo) { Player.AbilityInfo copy = new Player.AbilityInfo(); copy.cooldown = 0; copy.keyCode = abilityInfo.keyCode; copy.range = abilityInfo.range; return(copy); }
private void SendAutoAttack(Player.AbilityInfo ability, Vector3 targetPosition) { ability.cooldown = _player.autoAttackInfo.cooldown; targetPosition.y = _player.transform.position.y; _gameController.SendBroadcast(new AbilityInput(_id, AbilityType.AUTOATTACK, targetPosition), true); }