Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //PLAYER INPUT//
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Input.GetButtonDown("Fire2") || firstClick && targetedEnemy == null && Input.GetButton("Fire2"))
        {
            firstClick = true;
            if (Physics.Raycast(ray, out hit, 100f, Layers.Enemy | Layers.Floor))
            {
                HandleRayCastHit(hit);
            }
        }

        HandleAbilityInput();

        //PLAYER ACTION//
        if (activeSpecialAbility != null && activeSpecialAbility.GetAction() == AbilityHelper.Action.AOE)
        {
            AimAOESpecial();
        }
        else if (activeSpecialAbility != null && activeSpecialAbility.GetAction() == AbilityHelper.Action.Target)
        {
            if (specialTargetedEnemy == null)
            {
                AimTargetSpecial();
            }
            else
            {
                ShootSpecialOnTarget(specialTargetedEnemy);
            }
        }
        else if (activeSpecialAbility != null && activeSpecialAbility.GetAction() == AbilityHelper.Action.TargetFriend)
        {
            if (specialTargetedFriend == null)
            {
                AimTargetFriendSpecial();
            }
            else
            {
                ShootSpecialOnFriendTarget(specialTargetedFriend);
            }
        }
        else if (activeSpecialAbility != null && activeSpecialAbility.GetAction() == AbilityHelper.Action.Equip)
        {
            animController.AnimateAimStanding();
            if (activeSpecialAbility.RemainingTime() < activeSpecialAbility.coolDownTime - activeSpecialAbility.timeToCast)
            {
                animController.AnimateIdle();
                activeSpecialAbility = null;
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                if (Physics.Raycast(ray, out hit, 100f, Layers.Enemy))
                {
                    HandleRayCastHit(hit);
                }
            }
            if (targetedEnemy != null)
            {
                ShootGun();
            }
        }

        //PLAYER ANIMATION//
        if (specialTargetedEnemy != null)
        {
            HandleDestinationAnimation(specialTargetedEnemy, activeSpecialAbility);
        }
        else if (specialTargetedFriend != null)
        {
            HandleDestinationAnimation(specialTargetedFriend, activeSpecialAbility);
        }
        else
        {
            HandleDestinationAnimation(targetedEnemy, abilities.Basic);
        }
    }