Ejemplo n.º 1
0
    public Vector3 GetNpcPosition(TownRunTargetType type, uint id)
    {
        if (type == TownRunTargetType.Potal)
        {
            return(GetPotalObject().transform.position);
        }
        else
        {
            InputTownModel model = GetNpcObject((ushort)id);
            if (model != null)
            {
                return(model.transform.GetChild(0).position);
            }
        }

        return(Vector3.zero);
    }
Ejemplo n.º 2
0
    public void RunTownUnit(TownRunTargetType type, uint id = 0)
    {
        Vector3 pos = Vector3.zero;

        if (type == TownRunTargetType.Npc)
        {
            InputTownModel twm = GetNpcObject((ushort)id);
            if (twm == null)
            {
                return;
            }

            Vector3 offset = TownUnit.transform.position - twm.transform.position;

            pos = twm.transform.position + (offset.normalized);
        }
        else if (type == TownRunTargetType.Potal)
        {
            GameObject go = GetPotalObject();
            if (go == null)
            {
                return;
            }

            pos = go.transform.position;
        }

        TownUnit.townUnitHelper.MovePosition(pos);
        //TownUnit.MovePosition(pos, 1f);

        /*
         * if (TownUnit.CalculatePath(pos))
         * {
         *  TownUnit.ChangeState(UnitState.Move);
         *  //townUnit.PlayAnim(eAnimName.Anim_move);
         *  //IsRun = true;
         * }
         */
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 마을에 있는 NPC를 생성한. - 이건 테이블을 정의해서 목록 만들어서 구현이 필요하다.
    /// </summary>
    IEnumerator CreateTownNpcs()
    {
        foreach (Transform trans in GetComponentsInChildren <Transform>())
        {
            InputTownModel model = (InputTownModel)trans.GetComponent("InputTownModel");
            if (null != model)
            {
                NpcData.NpcInfo npcData = _LowDataMgr.instance.GetNPCInfo((ushort)model.NpcId);

                if (npcData != null)
                {
                    //GameObject oriUnit = ResourceMgr.Load(string.Format("Character/Prefab/{0}", npcData.prefab)) as GameObject;

                    GameObject oriUnit = null;
                    yield return(StartCoroutine(ResourceMgr.LoadAsync(string.Format("Character/Prefab/{0}", npcData.prefab), (retVal) => {
                        oriUnit = retVal as GameObject;
                    })));

//					ResourceRequest resReq = Resources.LoadAsync (string.Format("Character/Prefab/{0}", npcData.prefab), typeof(GameObject));
//					while (!resReq.isDone) {
//						yield return null;
//					}
//					GameObject oriUnit = resReq.asset as GameObject;

                    if (oriUnit == null)
                    {
                        Debug.LogWarning("not found npc model error! path = Character/Prefab/" + npcData.prefab);
                        oriUnit = ResourceMgr.Load(string.Format("Etc/Missing_Model")) as GameObject;
                    }

                    GameObject Model = Instantiate(oriUnit) as GameObject;
                    Model.transform.parent           = model.transform;
                    Model.transform.localScale       = Vector3.one;
                    Model.transform.localPosition    = Vector3.zero;
                    Model.transform.localEulerAngles = Vector3.zero;

                    Model.GetComponent <Animation>().cullingType = AnimationCullingType.BasedOnRenderers;

                    if (QualityManager.instance.GetQuality() != QUALITY.QUALITY_HIGH)
                    {
                        GameObject shadowGO = ResourceMgr.Instantiate <GameObject>("Etc/Shadow");
                        shadowGO.transform.parent        = Model.transform;
                        shadowGO.transform.localPosition = new Vector3(0f, 0.06f, 0f);
                        shadowGO.transform.localRotation = Quaternion.Euler(new Vector3(270, 0, 0));
                        shadowGO.transform.localScale    = Vector3.one * 1.8f;
                    }

                    BoxCollider bc = model.gameObject.AddComponent <BoxCollider>();
                    bc.isTrigger = true;
                    bc.size      = new Vector3(2f, 2f, 2f);
                    bc.center    = new Vector3(0, 1, 0);
                    string npcName = _LowDataMgr.instance.GetStringUnit(npcData.DescriptionId);

                    if (npcName == null)
                    {
                        npcName = "cannot find name.";
                    }

                    model.InitNpc(TownUnit.GetComponent <Collider>(), npcData.Type, npcName);

                    NpcModels.Add(model);
                    NGUITools.SetLayer(Model, 14);
                }
            }
        }


        UIBasePanel Map = UIMgr.GetUIBasePanel("UIPanel/MapPanel");

        if (Map != null)
        {
            (Map as MapPanel).SetTownNpc();
        }


        yield return(null);
    }