Ejemplo n.º 1
0
    /// <summary>
    /// 携程-加载模型
    /// </summary>
    /// <param name="modelInfo"></param>
    /// <param name="userModelData"></param>
    /// <param name="action"></param>
    /// <returns></returns>
    public IEnumerator CoroutineForLoadModel(ModelInfoBean modelInfo, UserModelDataBean userModelData, Action action)
    {
        //读取模型
        ResourceRequest resourceRequest = Resources.LoadAsync("Model/" + modelInfo.model_name);

        yield return(resourceRequest);

        GameObject objModelTemp = resourceRequest.asset as GameObject;

        //移除场景中的模型
        CptUtil.RemoveChildsByActive(gameObject);
        //创建模型
        GameObject objModel = Instantiate(gameObject, objModelTemp);

        //初始化模型位置
        objModel.transform.position = Vector3.zero;
        //添加模型控件
        GameModelCpt gameModel = CptUtil.AddCpt <GameModelCpt>(objModel);

        gameModel.SetData(userModelData, modelInfo);
        //设置加载的模型
        currentLoadModel = gameModel;
        action?.Invoke();
        Resources.UnloadUnusedAssets();
    }
Ejemplo n.º 2
0
 protected override void Awake()
 {
     canvas           = CptUtil.AddCpt <Canvas>(gameObject);
     canvasScaler     = CptUtil.AddCpt <CanvasScaler>(gameObject);
     graphicRaycaster = CptUtil.AddCpt <GraphicRaycaster>(gameObject);
     ChangeUIRenderMode(RenderMode.ScreenSpaceOverlay);
 }
Ejemplo n.º 3
0
    private void Awake()
    {
        aiForCharacterPath = CptUtil.AddCpt <AIForCharacterPathAuto>(gameObject);
        characterAnim      = GetComponent <CharacterAnimCpt>();

        AutoLinkHandler();
        ReflexUtil.AutoLinkDataForChild(this, "transform_");
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 炸飞
    /// </summary>
    /// <param name="blowPosition"></param>
    public void BlowUp(Vector3 blowPosition)
    {
        Collider collider = transform.GetComponent <Collider>();

        collider.isTrigger = false;
        Rigidbody rigidbody = CptUtil.AddCpt <Rigidbody>(gameObject);

        rigidbody.AddExplosionForce(500f, blowPosition, 10);
    }
Ejemplo n.º 5
0
    private void Awake()
    {
        switch (ProjectConfigInfo.AI_PATHFINDING)
        {
        case PathFindingEnum.Navigation:
            navigationPathFinding = CptUtil.AddCpt <NavigationPathFinding>(gameObject);
            break;

        case PathFindingEnum.Astar:
            astarPathFinding = CptUtil.AddCpt <AstarPathFinding>(gameObject);
            break;
        }
    }
Ejemplo n.º 6
0
    private void OnGUI()
    {
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
        EditorGUILayout.BeginVertical();

        EditorGUILayout.BeginHorizontal();
        EditorUI.GUIText("场景ID");
        sceneId = EditorUI.GUIEditorText(sceneId);
        if (EditorUI.GUIButton("读取场景"))
        {
            LoadSceneData();
        }
        if (EditorUI.GUIButton("保存场景"))
        {
            SaveSceneData();
        }

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        EditorUI.GUIText("物件ID");
        buildingId = EditorUI.GUIEditorText(buildingId);
        if (EditorUI.GUIButton("加载物件"))
        {
            GameObject   objBuildingModel = BuildingHandler.Instance.manager.GetSceneBuildingModel(buildingId);
            GameObject   objBuilding      = Instantiate(objBuildingModel, BuildingHandler.Instance.transform);
            BuildingBase baseBuilding     = CptUtil.AddCpt <BuildingBase>(objBuilding);
            baseBuilding.buildingInfo = BuildingHandler.Instance.manager.GetBuildingInfo(buildingId);
        }


        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 7
0
 private void Awake()
 {
     listPerson.Clear();
     playerControl = CptUtil.AddCpt <PlayerControl>(gameObject);
 }
Ejemplo n.º 8
0
 protected override void Awake()
 {
     base.Awake();
     controlForBuild = CptUtil.AddCpt<BuildControl>(gameObject);
     controlForBuild.ChangeMode(BuildControlModeEnum.Build);
 }
Ejemplo n.º 9
0
 protected virtual void Awake()
 {
     manager = CptUtil.AddCpt <T>(gameObject);
     AutoLinkHandler();
     AutoLinkManager();
 }
Ejemplo n.º 10
0
 private void Awake()
 {
     aiSeeker      = CptUtil.AddCpt <Seeker>(gameObject);
     characterAnim = GetComponent <CharacterAnimCpt>();
 }
Ejemplo n.º 11
0
    public void SetPersonNumber(PersonInfoBean personInfo)
    {
        PersonDetailsBean personDetails = personInfo.GetPersonDetilas();

        if (manager.personContainer.transform.childCount < personInfo.person_number)
        {
            int offsetNumber = personInfo.person_number - manager.personContainer.transform.childCount;
            for (int i = 0; i < offsetNumber; i++)
            {
                GameObject objPersonModel = manager.GetPersonModel("Person");
                GameObject objPerson      = Instantiate(manager.personContainer, objPersonModel);
            }
        }
        for (int i = 0; i < manager.personContainer.transform.childCount; i++)
        {
            Transform tfChild = manager.personContainer.transform.GetChild(i);
            if (i >= personInfo.person_number)
            {
#if UNITY_EDITOR
                DestroyImmediate(tfChild.gameObject);
#else
                Destroy(tfChild.gameObject);
#endif
                i--;
            }
            else
            {
                PersonDetailsItemBean personDetailsItem = personDetails.listPersonData[i];
                Person person = CptUtil.AddCpt <Person>(tfChild.gameObject, out bool isNew);
                if (isNew)
                {
                    manager.AddPerson(person);
                }
                person.SetData(personDetailsItem.position.GetVector3(), personDetailsItem.bufferTime, isNew);
                if (Application.isPlaying)
                {
                    //tfChild.DOLocalMove(personDetailsItem.position.GetVector3(), 0.5f);
                    tfChild.DOScale(personDetailsItem.size.GetVector3(), 0.5f);
                    tfChild.DOLocalRotate(personDetailsItem.angle.GetVector3(), 0.5f);
                }
                else
                {
                    //tfChild.localPosition = personDetailsItem.position.GetVector3();
                    tfChild.localScale       = personDetailsItem.size.GetVector3();
                    tfChild.localEulerAngles = personDetailsItem.angle.GetVector3();
                }

                Transform[] listPartTF = tfChild.GetComponentsInChildren <Transform>();
                for (int f = 0; f < listPartTF.Length; f++)
                {
                    Transform tfItemPart = listPartTF[f];
                    if (tfItemPart == tfChild)
                    {
                        continue;
                    }
                    for (int p = 0; p < personDetailsItem.listPartData.Count; p++)
                    {
                        PersonDetailsItemPartBean personDetailsItemPart = personDetailsItem.listPartData[p];
                        if (tfItemPart.name.Equals(personDetailsItemPart.partName))
                        {
                            if (Application.isPlaying)
                            {
                                tfItemPart.DOLocalMove(personDetailsItemPart.position.GetVector3(), 0.5f);
                                tfItemPart.DOScale(personDetailsItemPart.size.GetVector3(), 0.5f);
                                tfItemPart.DOLocalRotate(personDetailsItemPart.angle.GetVector3(), 0.5f);
                            }
                            else
                            {
                                tfItemPart.localPosition    = personDetailsItemPart.position.GetVector3();
                                tfItemPart.localScale       = personDetailsItemPart.size.GetVector3();
                                tfItemPart.localEulerAngles = personDetailsItemPart.angle.GetVector3();
                            }

                            break;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 12
0
 private void Awake()
 {
     gameModelControl  = CptUtil.AddCpt <GameModelControl>(gameObject);
     gameModelProgress = CptUtil.AddCpt <GameModelProgress>(gameObject);
 }