Exemple #1
0
    private void UpdateAttackKeys()
    {
        if (Input.GetKey(KeyCode.F) && !isAttacking)
        {
            PlayAnim((int)Combo.thrown);
            foreach (var a in RightHand.GetComponentsInChildren <Renderer>())
            {
                a.enabled = false;
            }
            var g = (Monkey)Instantiate(_Database.monkey, RightHand.position, RightHand.rotation);
            g.transform.parent = RightHand;
            Physics.IgnoreCollision(collider, g.collider);
            g.enabled = false;
            PlayAnim((int)Combo.thrown, delegate
            {
                g.enabled           = true;
                g.transform.parent  = null;
                g.transform.forward = mouseDir;
                g.vel = mouseDir * 20;
                foreach (var a in RightHand.GetComponentsInChildren <Renderer>())
                {
                    a.enabled = true;
                }
            });
        }
        _Loader.Log(comboStartPos, comboEndPos);
        if (mouse && (!isAttacking || CurrentWeapon.weaponType == WeaponType.Bow))
        {
            PlayAnim(mouse1 ? (int)CurrentWeapon.combosSpecial : CurrentWeapon.combos[(currentAttack % CurrentWeapon.combos.Length)], OnAttack);
            comboStartPos = pos;
            comboEndPos   = mousePos;
            if (currentCombo == (int)Combo.hammer2)
            {
                StartCoroutine(AddUpdate(delegate
                {
                    if (!infoSpecial.IsTag("idle"))
                    {
                        if ((comboStartPos - comboEndPos).magnitude > 2)
                        {
                            pos = Vector3.Lerp(comboStartPos, comboEndPos, -.2f + infoSpecial.normalizedTime * 2.5f);
                            _Loader.Log(pos);
                        }
                    }
                    return(isAttacking);
                }));
            }

            special = mouse1;
        }
        if (isAttacking && CurrentWeapon.ShootInterval > 0)
        {
            lastAttack += Time.deltaTime;
            if (lastAttack > CurrentWeapon.ShootInterval && CurrentWeapon.weaponType == WeaponType.Bow)
            {
                createBullet();
                lastAttack = lastAttack % CurrentWeapon.ShootInterval;
            }
        }
    }