//private string _BackWeaponName = "";

        void Awake()
        {
            _AnimationUnitComp   = gameObject.GetComponent <AnimationUnit>();
            _HasCombatAnimation  = (_AnimationUnitComp != null && _AnimationUnitComp.HasAnimation(AnimationUnit.BATTLE_STAND));
            _HangPointHolderComp = gameObject.GetComponent <HangPointHolder>();
            _AnimationLength     = _AnimationUnitComp != null?_AnimationUnitComp.GetAniLength(AnimationUnit.UNLOAD_WEAPON) : 0f;
        }
        private void GetWeapons()
        {
            if (null == _HangPointHolderComp)
            {
                _HangPointHolderComp = gameObject.GetComponent <HangPointHolder>();
            }
            if (null == _HangPointHolderComp)
            {
                return;
            }
            var back1     = _HangPointHolderComp.GetHangPoint(HangPointHolder.HangPointType.WeaponBack1);
            var back2     = _HangPointHolderComp.GetHangPoint(HangPointHolder.HangPointType.WeaponBack2);
            var leftHand  = _HangPointHolderComp.GetHangPoint(HangPointHolder.HangPointType.WeaponLeft);
            var rightHand = _HangPointHolderComp.GetHangPoint(HangPointHolder.HangPointType.WeaponRight);

            if (back1 != null && back1.transform.childCount > 0)
            {
                _LeftHandWeaponTrans = back1.transform.GetChild(0);
            }
            else if (leftHand != null && leftHand.transform.childCount > 0)
            {
                _LeftHandWeaponTrans = leftHand.transform.GetChild(0);
            }

            if (back2 != null && back2.transform.childCount > 0)
            {
                _RightHandWeaponTrans = back2.transform.GetChild(0);
            }
            else if (rightHand != null && rightHand.transform.childCount > 0)
            {
                _RightHandWeaponTrans = rightHand.transform.GetChild(0);
            }
        }
Exemple #3
0
    /// <summary>
    /// Select Camera Pos according to current playing animation
    /// </summary>
    /// <param name="t_pos">Camera Pos</param>
    /// <param name="t_lookat">LookAt Pos</param>
    private void GetHangPoint(GameObject target, ref Transform t_pos, ref Transform t_lookat)
    {
        int       pos_set = 0;
        Animation anim    = target.GetComponentInChildren <Animation>();

        if (anim != null)
        {
            var cam_info = target.GetComponentInChildren <NpcCameraPosInfo>();
            if (cam_info != null)
            {
                int c = cam_info.GetCount();
                for (int i = 0; i < c; i++)
                {
                    string anim_name = cam_info.GetAnimAt(i);
                    if (anim.IsPlaying(anim_name))
                    {
                        pos_set = cam_info.GetPos(anim_name);
                        break;
                    }
                }
            }
        }

        HangPointHolder hang_holder = target.GetComponentInChildren <HangPointHolder>();

        if (null != hang_holder)
        {
            GameObject g_camPos    = null;
            GameObject g_camLookAt = null;

            if (pos_set == 0)
            {
                g_camPos    = hang_holder.GetHangPoint(HangPointHolder.HangPointType.DCamPos);
                g_camLookAt = hang_holder.GetHangPoint(HangPointHolder.HangPointType.DCamPosLookAt);
            }
            else if (pos_set == 1)
            {
                g_camPos    = hang_holder.GetHangPoint(HangPointHolder.HangPointType.DCamPos1);
                g_camLookAt = hang_holder.GetHangPoint(HangPointHolder.HangPointType.DCamPosLookAt1);
            }

            t_pos    = g_camPos != null ? g_camPos.transform : null;
            t_lookat = g_camLookAt != null ? g_camLookAt.transform : null;
        }
    }
Exemple #4
0
        void Awake()
        {
            _AnimatorComponent  = GetComponent <Animator>();
            _AnimationComponent = GetComponent <Animation>();
            _AnimationInfo      = GetComponent <AnimationInfo>();
            _HangPointHolder    = GetComponent <HangPointHolder>();

            if (_AnimationComponent != null)
            {
                _UnloadWeaponState = GetAnimationStateByName(UNLOAD_WEAPON);
                if (null != _HangPointHolder && null != _HangPointHolder.HangPoint_WaistTrans)
                {
                    _WaistTrans = _HangPointHolder.HangPoint_WaistTrans.transform;
                }
                else
                {
                    _WaistTrans = transform.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1/Bip001 Spine2");
                    if (_WaistTrans == null)
                    {
                        _WaistTrans = transform.Find("Bip001/Bip001 Pelvis/Bip001 Spine/Bip001 Spine1");
                    }
                }

                if (_UnloadWeaponState != null && _WaistTrans != null)
                {
                    _UnloadWeaponState.wrapMode = WrapMode.Once;
                    _UnloadWeaponState.layer    = 1;
                    _UnloadWeaponState.weight   = 1f;
                    _UnloadWeaponState.enabled  = false;
                    _UnloadWeaponState.AddMixingTransform(_WaistTrans);
                }
                _AnimationComponent.cullingType = AnimationCullingType.AlwaysAnimate;
            }
            else if (null != _AnimatorComponent)
            {
            }
        }
Exemple #5
0
    //现在客户端逻辑是只有接主任务和交主任务的npc才会用Npc摄像机
    private void CheckNPC(Quest quest, int npcTid, QuestNpcType questNpcType, int index, bool bCheckNpcCamera)
    {
        int questTid = quest.Id;

        if (npcTid == 0)
        {
            if (questNpcType == QuestNpcType.Provide || questNpcType == QuestNpcType.Deliver)
            {
                _ErrorString += string.Format("任务npc不存在! questTid: {0}, questName: {1}, npcTid: {2}, 类型: {3}, 索引: {4}\n", questTid, quest.Name, npcTid, questNpcType, index);
            }
            else
            {
                return;             //其他类型npc的id为0时暂时跳过
            }
        }

        if (_NpcData.ContainsKey(npcTid))
        {
            Npc        npc = _NpcData[npcTid];
            GameObject go  = AssetBundleCheck.Instance.LoadAsset(npc.ModelAssetPath) as GameObject;
            if (go == null)
            {
                _ErrorString += string.Format("模型为空! questTid: {0}, questName: {1}, npcTid: {2}, npcPath: {3}, 类型: {4}, 索引: {5}\n", questTid, quest.Name, npcTid, npc.ModelAssetPath, questNpcType, index);
            }
            else
            {
                if (bCheckNpcCamera)
                {
                    HangPointHolder hangHolder = go.GetComponentInChildren <HangPointHolder>();
                    if (hangHolder != null)
                    {
                        GameObject g_camPos    = hangHolder.GetHangPoint(HangPointHolder.HangPointType.DCamPos);
                        GameObject g_camLookAt = hangHolder.GetHangPoint(HangPointHolder.HangPointType.DCamPosLookAt);

                        if (g_camPos == null)
                        {
                            _ErrorString += string.Format("缺少摄像机挂点 HangPoint_DCamPos! questTid: {0}, questName: {1}, npcTid: {2}, npcPath: {3}, 类型: {4}, 索引: {5}\n", questTid, quest.Name, npcTid, npc.ModelAssetPath, questNpcType, index);
                        }
                        if (g_camLookAt == null)
                        {
                            _ErrorString += string.Format("缺少摄像机挂点 HangPoint_DCamPosLookAt! questTid: {0}, questName: {1}, npcTid: {2}, npcPath: {3}, 类型: {4}, 索引: {5}\n", questTid, quest.Name, npcTid, npc.ModelAssetPath, questNpcType, index);
                        }
                    }
                    else
                    {
                        _ErrorString += string.Format("缺少挂载点 HangPointHolder! questTid: {0}, questName: {1}, npcTid: {2}, npcPath: {3}, 类型: {4}, 索引: {5}\n", questTid, quest.Name, npcTid, npc.ModelAssetPath, questNpcType, index);
                    }
                }
            }
        }
        else
        {
            _ErrorString += string.Format("任务npc不存在! questTid: {0}, questName: {1}, npcTid: {2}, 类型: {3}, 索引: {4}\n", questTid, quest.Name, npcTid, questNpcType, index);
        }

        //检查生成点
        foreach (var scene in _SceneData.Values)
        {
            string navmesh = scene.NavMeshName;
            foreach (var generator in scene.EntityGeneratorRoot.EntityGenerators)
            {
                if (generator.EntityType != (int)EntityType.Npc)
                {
                    continue;
                }

                foreach (var entityInfo in generator.EntityInfos)
                {
                    if (npcTid != entityInfo.EntityId)
                    {
                        continue;
                    }
                    Vector3 pos = new Vector3();
                    pos.x = generator.PositionX;
                    pos.y = generator.PositionY;
                    pos.z = generator.PositionZ;

                    if (!NavMeshManager.Instance.IsValidPositionStrict(Template.Path.BasePath, navmesh, pos))
                    {
                        _ErrorString += string.Format("npc生成点不在navmesh可达点: questTid: {0}, questName: {1}, npcTid: {2}, 类型: {3}, 索引: {4}, 场景Id: {5}, 生成器: {6}\n", questTid, quest.Name, npcTid, questNpcType, index, scene.Id, generator.Id);
                    }
                }
            }
        }
    }