예제 #1
0
    private void AttachControllers()
    {
        CharacterController characterController = NkUtil.GuarranteeComponent <CharacterController>(this.m_kRootGameObj);
        CapsuleCollider     componentInChildren = this.m_kBaseObject.GetComponentInChildren <CapsuleCollider>();

        if (null != componentInChildren)
        {
            characterController.radius     = 0.1f;
            characterController.height     = componentInChildren.height;
            characterController.center     = new Vector3(0f, characterController.height / 2f, 0f);
            characterController.slopeLimit = 45f;
            characterController.stepOffset = 0.8f;
            UnityEngine.Object.DestroyObject(componentInChildren);
        }
        else
        {
            characterController.radius = 0.1f;
            this.m_pkPickingCollider   = NkUtil.GetChild(this.m_kRootGameObj.transform, "PickingCollider");
            if (this.m_pkPickingCollider != null)
            {
                BoxCollider component = this.m_pkPickingCollider.GetComponent <BoxCollider>();
                if (component != null)
                {
                    characterController.height = component.size.y;
                }
                else
                {
                    characterController.height = 1f;
                }
            }
            else
            {
                characterController.height = 1f;
            }
            characterController.center     = new Vector3(0f, characterController.height / 2f, 0f);
            characterController.slopeLimit = 45f;
            characterController.stepOffset = 0.8f;
        }
        if (this.m_kBaseObject != null)
        {
            Transform child = NkUtil.GetChild(this.m_kBaseObject.transform, "Camera");
            if (child == null)
            {
                GameObject gameObject = new GameObject("Camera");
                Vector3    a          = characterController.center;
                a.y += characterController.height / 4f;
                a   += this.m_kBaseObject.transform.position;
                Vector3 vector = this.m_kBaseObject.transform.position;
                vector  += this.m_kBaseObject.transform.forward * 2f;
                vector.y = Mathf.Max(0.3f, a.y);
                gameObject.transform.localPosition = vector;
                gameObject.transform.parent        = this.m_kBaseObject.transform;
            }
        }
        this.m_kCharacterCtrl = characterController;
    }
예제 #2
0
    private void RegistAdaptor(GameObject goEffect, NkEffectUnit kEffectUnit)
    {
        TsAnimationEventConnector componentInChildren = goEffect.GetComponentInChildren <TsAnimationEventConnector>();

        if (null != componentInChildren)
        {
            NkBattleChar      casterChar        = kEffectUnit.CasterChar;
            NrCharInfoAdaptor nrCharInfoAdaptor = NkUtil.GuarranteeComponent <NrCharInfoAdaptor>(goEffect);
            nrCharInfoAdaptor.SetCharInfoInterface(new NrCharInfoLogic(casterChar));
        }
    }
예제 #3
0
    private void AttachControllers()
    {
        NkUtil.GuarranteeComponent <NrCharInfoAdaptor>(this.m_kRootGameObj);
        CharacterController characterController = NkUtil.GuarranteeComponent <CharacterController>(this.m_kRootGameObj);
        CapsuleCollider     componentInChildren = this.m_kRootGameObj.GetComponentInChildren <CapsuleCollider>();

        if (null != componentInChildren)
        {
            characterController.radius     = 0.1f;
            characterController.height     = componentInChildren.height;
            characterController.center     = new Vector3(0f, characterController.height / 2f, 0f);
            characterController.slopeLimit = 45f;
            characterController.stepOffset = 0.8f;
            UnityEngine.Object.DestroyObject(componentInChildren);
        }
        else
        {
            characterController.radius = 0.1f;
            this.m_pkPickingCollider   = NkUtil.GetChild(this.m_kRootGameObj.transform, "PickingCollider");
            if (this.m_pkPickingCollider != null)
            {
                BoxCollider component = this.m_pkPickingCollider.GetComponent <BoxCollider>();
                if (component != null)
                {
                    characterController.height = component.size.y;
                }
                else
                {
                    characterController.height = 1f;
                }
            }
            else
            {
                characterController.height = 1f;
            }
            characterController.center     = new Vector3(0f, characterController.height / 2f, 0f);
            characterController.slopeLimit = 45f;
            characterController.stepOffset = 0.8f;
        }
        this.m_kCharacterCtrl = characterController;
    }