Пример #1
0
    private void ShootSpecialOnTarget(Transform target)
    {
        if (target == null)
        {
            return;
        }
        float remainingDistance = Vector3.Distance(target.position, transform.position);

        if (remainingDistance <= activeSpecialAbility.effectiveRange && isTargetVisible(target))
        {
            //Within range, look at enemy and shoot
            transform.LookAt(target);
            //animController.AnimateAimStanding();

            if (activeSpecialAbility.isReady() && !target.GetComponent <EnemyHealth>().isDead)
            {
                activeSpecialAbility.Execute(player, gameObject, target.gameObject);

                if (specialTargetedEnemy != null && target.GetComponent <EnemyHealth>().isDead)
                {
                    if (changeTargetOnSpecial)
                    {
                        targetedEnemy = null;
                    }
                }
                activeSpecialAbility = null;
                specialTargetedEnemy = null;
            }

            navMeshAgent.destination = transform.position;
            animSpeed = 0.0f;
        }
    }
Пример #2
0
 private void useSpecialIfPossible(ISpecial ability)
 {
     //TODO: add debug/actual messages saying why ability failed
     if (ability.isReady() && resources.currentEnergy > ability.energyRequired)
     {
         if (ability.GetAction() == AbilityHelper.Action.Equip)
         {
             ability.Execute(player, gameObject, gameObject);
             activeSpecialAbility = ability;
         }
         else if (ability.GetAction() == AbilityHelper.Action.AOE)
         {
             Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             if (Physics.Raycast(ray, out hit, 100f, Layers.Floor))
             {
                 aoeArea = Instantiate(ability.aoeTarget, hit.point, Quaternion.Euler(-90, 0, 0)) as GameObject;
             }
             else
             {
                 aoeArea = Instantiate(ability.aoeTarget, transform.position, Quaternion.Euler(-90, 0, 0)) as GameObject;
             }
             aoeArea.GetComponent <AOETargetController>().effectiveRange = ability.effectiveRange;
             navMeshAgent.Resume();
             activeSpecialAbility = ability;
             //AimAOE
         }
         else if (ability.GetAction() == AbilityHelper.Action.Target || ability.GetAction() == AbilityHelper.Action.TargetFriend)
         {
             activeSpecialAbility = ability;
             //AimTarget
         }
     }
 }
Пример #3
0
    private IEnumerator ExecuteAOE(Player player, GameObject origin, GameObject aoeTarget, ISpecial ability)
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        ability.Execute(player, origin, aoeTarget);
    }