Exemple #1
0
    /*헷갈릴거 같으니 주석.
     * //움직임 정지 콜라이더와 충돌이 실행시킨다
     * public void ChangeStateIdle()
     * {
     *  TownUnit.moveTargetPotal = false;
     *  TownUnit.ChangeState(UnitState.Idle);
     * }
     */

    /// <summary>
    /// 플레이어 캐릭터가 삭제되고 생성될때 호출됨.
    /// </summary>
    /// <param name="newUnit"></param>
    public void SetNewMyTownHero(MyTownUnit newUnit)
    {
        TownUnit = newUnit;
        for (int i = 0; i < Potals.Length; i++)
        {
            Collider           bc  = Potals[i].GetComponentInChildren <Collider>();
            CollisionTownModel ctm = bc.GetComponent <CollisionTownModel>();
            ctm.SetNewTargetCollider(TownUnit.GetComponent <Collider>());
        }

        for (int i = 0; i < NpcModels.Count; i++)
        {
            //BoxCollider bc = NpcModels[i].GetComponentInChildren<BoxCollider>();
            NpcModels[i].SetNewTargetCollider(TownUnit.GetComponent <Collider>());
        }
    }
Exemple #2
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);
    }