Exemplo n.º 1
0
    public virtual void attack()
    {
        isAttacking = false;
        if (charInput.getSwitchSpellDown())
        {
            spellIndex = (spellIndex + 1) % spells.Length;
            spell      = (GameObject)Resources.Load("Prefabs/" + spells[spellIndex]);
        }
        if (charInput.spawnBoi)
        {
            Instantiate((GameObject)Resources.Load("Prefabs/Enemies/Enemy"), (hit.distance != 0?hit.point:(cameraT.position + cameraT.forward * 100)), Quaternion.identity);
        }
        //attacking
        bool valid = attackValid();

        if (charInput.leftMouseDown && valid)
        {
            isAttacking = true;
            animator.SetInteger("attack", 2);
            attackFrameCounter = -1;
        }
        if (!charInput.leftMouseDown && charInput.leftMouseDownPrev || !valid)
        {
            animator.SetInteger("attack", 0);
            if ((!charInput.leftMouseDown && charInput.leftMouseDownPrev && valid) || (!valid && attackValidPrev))
            {
                attackFrameCounter = 7;
            }
            isAttacking = false;
        }
        if (!isAttacking && attackFrameCounter > 0)
        {
            attackFrameCounter -= 1;
        }
        if (charInput.getSwitchAttackDown())
        {
            attackMode = !attackMode;
            animator.SetBool("scope", attackMode);
            if (OnAttackModeSwitch != null)
            {
                OnAttackModeSwitch();
            }
        }
        if ((isAttacking || attackFrameCounter > 0 || attackMode) && controller.isGrounded)
        {
            arm.RotateAround(arm.position, transform.right, !flying?(cameraT.eulerAngles.x + (attackMode?-20 * (currentSpeed / runSpeed):0)):0);
        }
        rotateArm(cameraT.forward, transform.forward);
        attackValidPrev = valid;
    }
Exemplo n.º 2
0
 public virtual void attack()
 {
     isAttacking = false;
     if (charInput.getSwitchSpellDown())
     {
         spellIndex = (spellIndex + 1) % spells.Length;
         spell      = (GameObject)Resources.Load("Prefabs/" + spells[spellIndex]);
         spell.GetComponent <Spell>().PreStartStuff();
     }
     if (charInput.spawnBoi)
     {
         Instantiate((GameObject)Resources.Load("Prefabs/Enemies/Enemy"), (hit.distance != 0?hit.point:(cameraT.position + cameraT.forward * 100)), Quaternion.identity);
     }
     if (charInput.shield && !drawPad)
     {
         shielding = true;
         if (currShield == null)
         {
             currShield = Instantiate(shield, wandTip.transform.position, Quaternion.identity);
             currShield.GetComponent <Shield>().SetPlayer(this);
         }
         animator.SetInteger("shield", 1);
     }
     else
     {
         shielding = false;
         if (currShield != null)
         {
             currShield.GetComponent <Shield>().kill();
         }
         animator.SetInteger("shield", 0);
     }
     if (charInput.getDrawPadDown())
     {
         timeSpeed = timeSpeed == 0?1:0;
         drawPad   = !drawPad;
         if (OnDrawPadSwitch != null)
         {
             OnDrawPadSwitch();
         }
         if (drawPad)
         {
             drawPadObj       = Instantiate((GameObject)Resources.Load("Prefabs/DrawSpellCaster"), transform.position + 3 * transform.up, Quaternion.LookRotation(cameraT.forward));
             drawMouseTracker = new Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane);
         }
         else
         {
             if (drawPadObj != null)
             {
                 drawPadObj.GetComponent <DrawSpellCaster>().kill();
             }
         }
     }
     //attacking
     valid = attackValid();
     if ((charInput.leftMouseDown && valid))
     {
         isAttacking = true;
         animator.SetInteger("attack", 2);
         attackFrameCounter = -1;
     }
     if (!charInput.leftMouseDown && charInput.leftMouseDownPrev || !valid)
     {
         animator.SetInteger("attack", 0);
         if ((!charInput.leftMouseDown && charInput.leftMouseDownPrev && valid) || (!valid && attackValidPrev))
         {
             attackFrameCounter = 7;
         }
         isAttacking = false;
     }
     if (!isAttacking && attackFrameCounter > 0)
     {
         attackFrameCounter -= 1;
     }
     if (charInput.getSwitchAttackDown())
     {
         attackMode = !attackMode;
         animator.SetBool("scope", attackMode);
     }
     if ((isAttacking || attackFrameCounter > 0 || attackMode || shielding))
     {
         if (!drawPad)
         {
             armdegY = Mathf.SmoothDampAngle(armdegY, !flying?(cameraT.eulerAngles.x + (attackMode?-20 * (targetSpeed / runSpeed):0)):0, ref armturnYvel, 0.1f);
             arm.RotateAround(arm.position, transform.right, armdegY);
         }
         else
         {
             armdegY += (-charInput.mouseY);
             arm.RotateAround(arm.position, transform.right, armdegY);
         }
     }
     if (drawPad)
     {
         drawMouseTracker.x += 20 * charInput.mouseX;
         rotateArm(Camera.main.ScreenToWorldPoint(new Vector3(drawMouseTracker.x, charInput.mousePosition.y, Camera.main.nearClipPlane)) - cameraT.position, transform.forward, false);
     }
     else if (attackMode || isAttacking)
     {
         rotateArm(cameraT.forward, transform.forward, true);
     }
     attackValidPrev = valid;
 }