コード例 #1
0
    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;
                    }
                }
            }
        }
    }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }