예제 #1
0
    private void loadWeapon(ref CRArm arm, CRItem item)
    {
        // todo make sure this weapon is really a weapon and not just some equippable item

        CRWeaponItem weapon = null;

        if (null != item && typeof(CRWeaponItem) == item.GetType())
            weapon = (CRWeaponItem)item;

        if (null == arm)
        {
            arm = new CRArm(weapon);
        }
        else if (arm.weapon != weapon)
        {
            arm.setWeapon(weapon);
        }

        arm.updateSpeed(1.0f + _controller.offence.haste(_controller.creature.level) * 0.01f);
    }
예제 #2
0
    private void processArm(CRArm arm, float multiplier)
    {
        if (null == arm.weapon)
            return;

        if (arm.delay.IsDone())
        {
            if (Vector3.Distance(_controller.transform.position, _target.transform.position) > (GetComponent<NavMeshAgent>().radius +  _target.GetComponent<NavMeshAgent>().radius) + 1.0f)
            {
                _swingLock = false;
                arm.swinging = false;
                return;
            }

            // todo direction check (are we facing the target)
            if (arm.swinging)
            {
                if (arm.swing.IsDone())
                {
                    CRCombatManager.Attack(_controller, arm.weapon, multiplier, _target);

                    _swingLock = false;

                    arm.swinging = false;
                    arm.delay.Reset();
                }
            }
            else
            {
                _controller.creature.conditionManager.RemoveAllConditionsOfType(CRConditionType.STEALTHED);

                // start swinging
                if (!_swingLock)
                {
                    _swingLock = true;
                }

                arm.swinging = true;
                arm.swing.Reset();

                if (null != arm.weapon.particles)
                {
                    networkView.RPC ("NetworkAttack", RPCMode.All, transform.position + (_target.transform.position - _controller.transform.position).normalized);
                }

                if (_animator)
                {
                    _animator.SetBool("Attack", true);
                }
            }
        }
    }