Exemplo n.º 1
0
    //SCENE

    public void SceneObjectMouseEnter(SceneObjectController sceneObject)
    {
        if (GameController.InteractionState != GameInteractionState.NavigatingScene)
        {
            return;
        }

        CursorTooltipSetText(sceneObject.tooltipText);
        switch (sceneObject.type)
        {
        case SceneObjectType.Character:
            CursorSet(TalkCursorTexture);
            break;

        case SceneObjectType.InteractableObject:
            CursorSet(InteractCursorTexture);
            break;

        case SceneObjectType.ObservableObject:
            CursorSet(ObserveCursorTexture);
            break;

        default:
            CursorSet(DefaultCursorTexture);
            break;
        }
    }
Exemplo n.º 2
0
        IEnumerator Spawn(List <string> roleIdList, string teamId, int level)
        {
            // 刷怪前掉落装备给玩家 add by TangJian 2019/3/23 11:59
            List <string> itemIdList = ItemManager.Instance.GetDropItemByLevel(level);
            string        dropItemId = itemIdList[Random.Range(0, itemIdList.Count)];

            GameObject            dropItemObject        = GameObjectManager.Instance.Create(dropItemId);
            SceneObjectController sceneObjectController = dropItemObject.GetComponent <SceneObjectController>();

            if (sceneObjectController != null)
            {
                SceneManager.Instance.DropItemEnterSceneWithWorldPosition(sceneObjectController, SceneId, Tools.RandomPositionInCube(transform.position, transform.lossyScale));
            }


            for (int i = 0; i < roleIdList.Count; i++)
            {
                string         roleId         = roleIdList[i];
                GameObject     roleGameObject = GameObjectManager.Instance.Create(roleId);
                RoleController roleController = roleGameObject.GetComponent <RoleController>();
                roleController.RoleData.TeamId          = teamId;
                roleController.RoleData.difficultyLevel = level;

                SceneManager.Instance.RoleEnterSceneWithWorldPosition(roleController, SceneId,
                                                                      Tools.RandomPositionInCube(transform.position, transform.lossyScale));

                yield return(roleController);
            }
            yield return(0);
        }
Exemplo n.º 3
0
    public void SceneObjectMouseExit(SceneObjectController sceneObject)
    {
        if (GameController.InteractionState != GameInteractionState.NavigatingScene)
        {
            return;
        }

        CursorTooltipClearText();
        CursorReset();
    }
Exemplo n.º 4
0
 public void GetHit()
 {
     if (--hp <= 0)
     {
         SceneObjectController scene = FindObjectOfType <SceneObjectController>();
         if (destroyedPrefab != null)
         {
             GameObject destroyed = Instantiate(destroyedPrefab, transform.parent);
             destroyed.transform.position = transform.position;
             destroyed.transform.rotation = transform.rotation;
             scene.UpdatePickablesFrom(destroyed.transform);
         }
         scene.RemovePickablesFrom(transform);
         Destroy(gameObject);
     }
 }
Exemplo n.º 5
0
    private void LoadSceneObjects()
    {
        foreach (var model in model.ObjectsInScene)
        {
            GameObject sceneObject = new GameObject();
            sceneObject = model.ItemModel.ApplyItemProperties(sceneObject);
            ISceneObjectView       sceneObjectView       = model.CreateView(sceneObject);
            ISceneObjectController sceneObjectController = new SceneObjectController(model, sceneObjectView);

            if (model is ModelSceneObjectModel || model is RegionSceneObjectModel)
            {
                sceneObject.layer = LayerMask.NameToLayer("SceneObject");
            }
            else if (model is CameraSceneObjectModel)
            {
                sceneObject.layer = LayerMask.NameToLayer("Visualization");
                ((CameraSceneObjectModel)model).OnCreateImage      += sceneObjectController.CreateImage;
                ((CameraSceneObjectModel)model).OnSetMainCamera    += sceneObjectController.SetMainCamera;
                ((CameraSceneObjectModel)model).OnSetDefaultCamera += sceneObjectController.SetDefaultCamera;
            }
            else if (model is AbstractLightSceneObjectModel)
            {
                sceneObject.layer = LayerMask.NameToLayer("Visualization");
            }

            OnDestroyController                       += sceneObjectController.DestoryController;
            OnRequestSceneObjectParameter             += sceneObjectController.RequestParameter;
            sceneObjectController.OnSendParameter     += DisplaySceneObjectParameter;
            sceneObjectController.OnDeleteReferences  += DeleteReferences;
            sceneObjectController.OnUpdateArrow       += UpdateArrow;
            sceneObjectController.OnDeleteSceneObject += DeleteSelectionModel;

            foreach (var parameter in model.Parameter)
            {
                parameter.UpdateParameterOnSceneObject(sceneObject);
            }
        }
    }
Exemplo n.º 6
0
    private GameObject CreateSceneObject <T>(T model) where T : AbstractItemModel
    {
        GameObject sceneObject = new GameObject();

        sceneObject = model.ApplyItemProperties(sceneObject);
        AbstractSceneObjectModel sceneObjectModel = model.CreateSceneObjectModel();

        foreach (var parameter in sceneObjectModel.Parameter)
        {
            parameter.InitFromGameObject(sceneObject);
        }
        ISceneObjectView       sceneObjectView       = sceneObjectModel.CreateView(sceneObject);
        ISceneObjectController sceneObjectController = new SceneObjectController(sceneObjectModel, sceneObjectView);

        this.model.AddSceneObject(sceneObjectModel);
        OnDestroyController                       += sceneObjectController.DestoryController;
        OnRequestSceneObjectParameter             += sceneObjectController.RequestParameter;
        sceneObjectController.OnSendParameter     += DisplaySceneObjectParameter;
        sceneObjectController.OnDeleteReferences  += DeleteReferences;
        sceneObjectController.OnUpdateArrow       += UpdateArrow;
        sceneObjectController.OnDeleteSceneObject += DeleteSelectionModel;
        return(sceneObject);
    }
Exemplo n.º 7
0
        static void InitSelectionChange()
        {
            Selection.selectionChanged = () =>
            {
                for (int i = 0; i < Selection.objects.Length; i++)
                {
                    object     obj        = Selection.objects[i];
                    GameObject gameObject = obj as GameObject;
                    if (gameObject)
                    {
                        PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject);
                        switch (prefabType)
                        {
                        case PrefabType.DisconnectedPrefabInstance:
                        case PrefabType.PrefabInstance:
                            // 处理预制体实例 add by TangJian 2018/11/8 17:53
                        {
                            GameObject prefabParent = AssetDatabase.LoadAssetAtPath <GameObject>(Tools.GetPrefabPath(gameObject));

                            if (prefabParent.GetComponent <SceneComponent>() != null && gameObject.GetComponent <SceneComponent>() != null)
                            {
                                SceneComponent sceneComponent = gameObject.GetComponent <SceneComponent>();

                                // 自动选择当前编辑的场景 add by TangJian 2018/11/27 21:48
                                SceneController sceneController = null;
                                {
                                    sceneComponent.transform.RecursiveParent((Transform parent, int depth) =>
                                        {
                                            if (sceneController == null && parent != null)
                                            {
                                                sceneController = parent.GetComponent <SceneController>();
                                            }
                                        }, 0, 99);

                                    if (sceneController != null)
                                    {
                                        var currSceneControllerList = GetCurrSceneControllerList();
                                        CurrSelectedSceneIndex = currSceneControllerList.FindIndex((SceneController sc) =>
                                            {
                                                return(sc.name == sceneController.name);
                                            });
                                        MapEditorManager.CurrSceneController = sceneController;
                                    }
                                    Repaint();
                                }

                                if (MapEditorManager.IsEditing && CurrSceneController != null)
                                {
                                    Debug.Log("加入组件 " + sceneComponent.name + " 到场景" + CurrSceneController.name);

                                    Transform parent = CurrSceneController.transform.FindAndAutoAdd(sceneComponent.PathInScene);
                                    sceneComponent.transform.parent = parent;
                                }

                                Debug.Log("为场景组件 " + gameObject.name + " 设置预制体路径");
                                sceneComponent.Editor_UpdatePath();
                                //sceneComponent.Editor_UpdateRendererSort();
                                //sceneComponent.Editor_UpdateRendererShader();
                            }
                            else if (prefabParent.GetComponent <SceneObjectController>() != null && gameObject.GetComponent <SceneObjectController>())
                            {
                                SceneObjectController sceneObjectController = gameObject.GetComponent <SceneObjectController>();

                                SceneController sceneController = null;
                                gameObject.transform.RecursiveParent((Transform parent, int depth) =>
                                    {
                                        if (sceneController == null && parent != null)
                                        {
                                            sceneController = parent.GetComponent <SceneController>();
                                        }
                                    }, 0, 99);

                                if (sceneController != null)
                                {
                                    sceneObjectController.CurrSceneController = sceneController;
                                }
                            }
                        }
                        break;

                        default:
                            Debug.Log("prefabType = " + prefabType);
                            break;
                        }
                    }
                }
            };
        }