private void OnEnable()
        {
            m_Target = target as SemaphoreMark;
            allNpcs  = ConfigVO <NpcVO> .Instance.GetList();

            if (allNpcs != null)
            {
                for (int iNpc = 0; iNpc < allNpcs.Count; iNpc++)
                {
                    if (allNpcs[iNpc].ID == m_Target.m_NpcId)
                    {
                        m_Target.m_SelectNpcIndex = iNpc;
                        break;
                    }
                }
            }

            if (m_Target.m_NpcIdArray == null || m_Target.m_NpcIdArray.Length <= 0)
            {
                if (allNpcs != null && allNpcs.Count > 0)
                {
                    m_Target.m_NpcIdArray = new string[allNpcs.Count];
                    for (int iNpc = 0; iNpc < allNpcs.Count; iNpc++)
                    {
                        NpcVO vo = allNpcs[iNpc];
                        m_Target.m_NpcIdArray[iNpc] = string.Format("{0}_{1}", vo.ID, vo.Name);
                    }
                }
            }
            m_LastNpcId   = m_Target.m_NpcId;
            m_LastGroupId = m_Target.m_GroupId;
        }
Beispiel #2
0
        /// <summary>
        /// 初始化当前选择的npcid
        /// </summary>
        private void InitSelectNpcId()
        {
            m_NpcListTemplateList = ConfigVO <NpcVO> .Instance.GetList();

            if (m_NpcListTemplateList != null)
            {
                for (int iNpc = 0; iNpc < m_NpcListTemplateList.Count; iNpc++)
                {
                    if (m_NpcListTemplateList[iNpc].ID == m_Target.m_NpcId)
                    {
                        m_Target.m_SelectNpcIndex = iNpc;
                        break;
                    }
                }
            }


            if (m_Target.m_NpcIdArray == null || m_Target.m_NpcIdArray.Length <= 0)
            {
                if (m_NpcListTemplateList != null && m_NpcListTemplateList.Count > 0)
                {
                    m_Target.m_NpcIdArray = new string[m_NpcListTemplateList.Count];
                    for (int iNpc = 0; iNpc < m_NpcListTemplateList.Count; iNpc++)
                    {
                        NpcVO vo = m_NpcListTemplateList[iNpc];
                        m_Target.m_NpcIdArray[iNpc] = string.Format("{0}_{1}", vo.ID, vo.Name);
                    }
                }
            }
        }
Beispiel #3
0
        public void Init(EditorCreature creature)
        {
            m_Uid          = creature.creatureId;
            m_NpcId        = creature.tplId;
            m_AutoCreation = creature.autoCreation == 1 ? true : false;
            m_ReviveRange  = creature.reviveRange;
            string strUid = m_Uid.ToString();

            if (strUid.Length > 3)
            {
                string creatureIdStr = strUid.Substring(strUid.Length - 3, 3);
                if (!string.IsNullOrEmpty(creatureIdStr))
                {
                    m_CreatureId = int.Parse(creatureIdStr);
                }
            }
            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_NpcId);

            if (vo != null)
            {
                gameObject.name = string.Format("{0}_{1}", vo.Name, m_Uid);
            }

            transform.position = GetPositon(creature.position);
            transform.rotation = GetRotation(creature.rotation);
        }
Beispiel #4
0
    public void init(NpcVO npc)
    {
        shower.sprite = Resources.Load<Sprite>("ui/npc/weapon/" + npc.weapon.ToString() + "/1");

        lSprites = new List<Sprite>();

        for (int i = 1; i <= npc.weaponFrameLength; i++)
        {
            lSprites.Add(Resources.Load<Sprite>("ui/npc/weapon/" + npc.weapon.ToString() + "/" + i.ToString()));
        }
    }
Beispiel #5
0
    public void init(NpcVO npc)
    {
        this.npc = npc;

        gameObject.GetComponentInChildren<UMovie>().init(npc);

        //Debug.Log("URL::" + "ui/npc/body/" + npc.body.ToString());
        //Debug.Log(gameObject.transform.FindChild("body").GetComponent<SpriteRenderer>().sprite);

        gameObject.transform.FindChild("body").GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("ui/npc/body/" + npc.body.ToString());
    }
Beispiel #6
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void Init(ulong uid, int creatureId, CreatureRoot root)
        {
            m_Root       = root;
            m_Uid        = uid;
            m_CreatureId = creatureId;

            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_NpcId);

            if (vo != null)
            {
                gameObject.name = string.Format("{0}_{1}", vo.Name, m_Uid);
            }
            transform.localPosition = Vector3.zero;
        }
        private void OnEnable()
        {
            m_Target       = target as Creature;
            m_IsAutoCreate = m_Target.m_AutoCreation;
            List <NpcVO> allNpcs = ConfigVO <NpcVO> .Instance.GetList();

            if (allNpcs != null && allNpcs.Count > 0)
            {
                m_NpcListTemplateList = new List <NpcVO>();
                KMapPathType mapPathType = m_Target.m_Root.GetGamingMapPathType();
                for (int iAllNpc = 0; iAllNpc < allNpcs.Count; iAllNpc++)
                {
                    NpcVO vo = allNpcs[iAllNpc];
                    if ((mapPathType == KMapPathType.KMapPath_Groud && vo.motionType == (int)MotionType.Human) ||
                        (mapPathType == KMapPathType.KMapPath_Space && vo.motionType == (int)MotionType.Ship))
                    {
                        m_NpcListTemplateList.Add(vo);
                    }
                }
            }

            if (m_NpcListTemplateList != null)
            {
                for (int iNpc = 0; iNpc < m_NpcListTemplateList.Count; iNpc++)
                {
                    if (m_NpcListTemplateList[iNpc].ID == m_Target.m_NpcId)
                    {
                        m_Target.m_SelectNpcIndex = iNpc;
                        break;
                    }
                }
            }


            if (m_Target.m_NpcIdArray == null || m_Target.m_NpcIdArray.Length <= 0)
            {
                if (m_NpcListTemplateList != null && m_NpcListTemplateList.Count > 0)
                {
                    m_Target.m_NpcIdArray = new string[m_NpcListTemplateList.Count];
                    for (int iNpc = 0; iNpc < m_NpcListTemplateList.Count; iNpc++)
                    {
                        NpcVO vo = m_NpcListTemplateList[iNpc];
                        m_Target.m_NpcIdArray[iNpc] = string.Format("{0}_{1}", vo.ID, vo.Name);
                    }
                }
            }
            m_LastNpcId = m_Target.m_NpcId;
        }
Beispiel #8
0
        /// <summary>
        /// 当前npc是否为复活npc
        /// </summary>
        /// <returns></returns>
        public bool IsRelieveCreature()
        {
            if (m_NpcId <= 0)
            {
                return(false);
            }

            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_NpcId);

            if (vo == null)
            {
                return(false);
            }

            return(vo.NpcType == (int)KHeroType.reliveObj);
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.LabelField("Uid", m_Target.m_Uid.ToString());
            //if (m_Target.m_NpcIdArray != null)
            //{
            //	m_Target.m_SelectNpcIndex = EditorGUILayout.Popup(new GUIContent("Npc ID"), m_Target.m_SelectNpcIndex, m_Target.m_NpcIdArray);
            //}

            GUILayout.BeginHorizontal();
            NpcVO npcVo = ConfigVO <NpcVO> .Instance.GetData(m_Target.m_NpcId);

            if (npcVo != null)
            {
                EditorGUILayout.LabelField("Npc ID", string.Format("{0}_{1}", npcVo.ID, npcVo.Name));
            }
            else
            {
                EditorGUILayout.LabelField("Npc ID");
            }

            if (GUILayout.Button("选择"))
            {
                OnSelect();
            }

            GUILayout.EndHorizontal();
            m_IsAutoCreate          = EditorGUILayout.Toggle("自动创建", m_IsAutoCreate);
            m_Target.m_AutoCreation = m_IsAutoCreate;
            OnSelectNpc();
            if (m_Target.IsShowLand())
            {
                m_IsForceLand = EditorGUILayout.Toggle("强制落地", m_IsForceLand);
                if (m_lastLand != m_IsForceLand)
                {
                    m_Target.ForceLand();
                    m_lastLand = m_IsForceLand;
                }
            }

            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_Target.m_NpcId);

            if (vo != null && vo.NpcType == (int)KHeroType.reliveObj)
            {
                m_Target.m_DebugShowRange = EditorGUILayout.Toggle("是否显示复活半径", m_Target.m_DebugShowRange);
                m_Target.m_ReviveRange    = EditorGUILayout.Slider("复活半径:", m_Target.m_ReviveRange, 0.1f, 100f);
            }
        }
Beispiel #10
0
        protected override string GetModelPath()
        {
            if (!string.IsNullOrEmpty(m_ModelPath))
            {
                return(m_ModelPath);
            }
            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_NpcId);

            if (vo != null)
            {
                int     modelId   = vo.Model;
                string  assetName = "";
                ModelVO modelVo   = ConfigVO <ModelVO> .Instance.GetData(modelId);

                if (modelVo != null)
                {
                    assetName = modelVo.assetName;
                }
                if (!string.IsNullOrEmpty(assetName))
                {
                    if (!assetName.Contains("Assets"))
                    {
                        string[] resAssets = AssetDatabase.FindAssets(string.Format("{0} t:Prefab", assetName));
                        if (resAssets != null && resAssets.Length > 0)
                        {
                            for (int iRes = 0; iRes < resAssets.Length; iRes++)
                            {
                                string   path     = AssetDatabase.GUIDToAssetPath(resAssets[iRes]);
                                string[] resSplit = path.Split('/');
                                if (resSplit != null && resSplit.Length > 0)
                                {
                                    string lastName = resSplit[resSplit.Length - 1];
                                    if (lastName.Equals(string.Format("{0}.prefab", assetName)))
                                    {
                                        assetName = path;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                m_ModelPath = assetName;
                return(assetName);
            }
            return(GamingMapEditorUtility.GetCreatureTempletePath());
        }
Beispiel #11
0
    public void initData()
    {
        TextAsset txtDb = null;

        npcDB = new Dictionary<int, NpcVO>();
        txtDb = Resources.Load<TextAsset>("data/npc");
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(txtDb.text);
        XmlNodeList nodeList = xmlDoc.SelectSingleNode("NPCConfig").ChildNodes;
        for(int i = 0; i < nodeList.Count; i++)
        {
            XmlElement xe = nodeList.Item(i) as XmlElement;

            if (xe == null) continue;

            int key = int.Parse(xe.GetAttribute("ID"));
            npcDB[key] = new NpcVO();
            for(int j = 0; j < xe.Attributes.Count; j++)
            {
                XmlAttribute attr = xe.Attributes[j];

                switch(attr.Name)
                {
                    case "ID":
                        npcDB[key].id = int.Parse(attr.Value);
                        break;

                    case "name":
                        npcDB[key].name = attr.Value;
                        break;

                    case "weaponFrameLength":
                        npcDB[key].weaponFrameLength = int.Parse(attr.Value);
                        break;

                    case "weapon":
                        npcDB[key].weapon = int.Parse(attr.Value);
                        break;

                    case "body":
                        npcDB[key].body = int.Parse(attr.Value);
                        break;
                }
            }
        }
    }
Beispiel #12
0
        public IEnumerator OnUpdate(CreatureRoot root, bool showModel)
        {
            m_Root      = root;
            m_ShowModel = showModel;
            RefreshModel();
            yield return(null);

            RefreshPosition();
            yield return(null);

            NpcVO vo = ConfigVO <NpcVO> .Instance.GetData(m_NpcId);

            if (vo != null)
            {
                gameObject.name = string.Format("{0}_{1}", vo.Name, m_Uid);
            }
            yield return(null);
        }
        private void OnSelect()
        {
            List <NpcVO> npcListTemplateList = null;

            ConfigInfoWindow.OpenWindow(() =>
            {
                List <NpcVO> allNpcs = ConfigVO <NpcVO> .Instance.GetList();
                if (allNpcs != null && allNpcs.Count > 0)
                {
                    npcListTemplateList      = new List <NpcVO>();
                    KMapPathType mapPathType = m_Target.m_Root.GetGamingMapPathType();
                    for (int iAllNpc = 0; iAllNpc < allNpcs.Count; iAllNpc++)
                    {
                        NpcVO vo = allNpcs[iAllNpc];
                        if ((mapPathType == KMapPathType.KMapPath_Groud && vo.motionType == (int)MotionType.Human) ||
                            (mapPathType == KMapPathType.KMapPath_Space && vo.motionType == (int)MotionType.Ship))
                        {
                            npcListTemplateList.Add(vo);
                        }
                    }
                }
                return(npcListTemplateList != null ? npcListTemplateList.Count : 0);
            }, (index) =>
            {
                string str = "";
                if (npcListTemplateList != null && npcListTemplateList.Count > index)
                {
                    str = $"{npcListTemplateList[index].ID}_{npcListTemplateList[index].Name}";
                }
                return(str);
            }, (index) =>
            {
                m_Target.m_SelectNpcIndex = index;
            });
            //NpcInfoWindow.OpenWindow(m_Target);
        }