Example #1
0
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("OnTriggerEnter");
        PlayerInputController playerInputController = other.GetComponent <PlayerInputController>();

        if (playerInputController != null && playerInputController.isActiveAndEnabled)
        {
            TeleporterDefine td = DataManager.Instance.Teleporters[this.ID];
            if (td == null)
            {
                Debug.LogErrorFormat("TeleportObject:Character [{0}] Enter Teleporter[{1}}]", playerInputController.character.Info.Name, this.ID);
                return;
            }
            Debug.LogFormat("TeleportObject:Character [{0}] Enter Teleporter [{1}:{2}]", playerInputController.character.Info.Name, td.ID, td.Name);
            if (td.LinkTo > 0)
            {
                if (DataManager.Instance.Teleporters.ContainsKey(td.LinkTo))
                {
                    MapService.Instance.SendMapTeleporter(this.ID);
                }
                else
                {
                    Debug.LogErrorFormat("TeleporTer ID:{0} LinkID {1} error!", td.ID, td.LinkTo);
                }
            }
        }
    }
Example #2
0
        private void PlayerEnterArena()
        {
            TeleporterDefine redPoint = DataManager.Instance.Teleporters[this.RedPoint];

            this.Red.Session.Character.Position  = redPoint.Position;
            this.Red.Session.Character.Direction = redPoint.Direction;
            if (this.Blue != null)
            {
                TeleporterDefine bluePoint = DataManager.Instance.Teleporters[this.BluePoint];
                this.Blue.Session.Character.Position  = redPoint.Position;
                this.Blue.Session.Character.Direction = redPoint.Direction;
            }

            this.map.AddCharacter(this.Red, this.Red.Session.Character);
            if (this.Blue != null)
            {
                this.map.AddCharacter(this.Blue, this.Blue.Session.Character);
            }

            this.map.CharacterEnter(this.Red, this.Red.Session.Character);
            if (this.Blue != null)
            {
                this.map.CharacterEnter(this.Blue, this.Blue.Session.Character);
            }

            EntityManager.Instance.AddEntity(this.map.ID, this.map.InstanceId, this.Red.Session.Character);
            if (this.Blue != null)
            {
                EntityManager.Instance.AddEntity(this.map.ID, this.map.InstanceId, this.Blue.Session.Character);
            }
        }
Example #3
0
        void OnMapTeleport(NetConnection <NetSession> sender, MapTeleportRequest request)
        {
            Character character = sender.Session.Character;

            Log.InfoFormat("OnMapTeleport: characterID:{0}:{1} TeleporterId:{2}", character.Id, character.Data, request.teleporterId);

            if (!DataManager.Instance.Teleporters.ContainsKey(request.teleporterId))
            {
                Log.WarningFormat("Source TeleporterID [{0}] not existed", request.teleporterId);
                return;
            }
            TeleporterDefine source = DataManager.Instance.Teleporters[request.teleporterId];

            if (source.LinkTo == 0 || !DataManager.Instance.Teleporters.ContainsKey(source.LinkTo))
            {
                Log.WarningFormat("Source TeleporterID [{0}] LinkTo ID [{1}] not existed", request.teleporterId, source.LinkTo);
            }

            TeleporterDefine target = DataManager.Instance.Teleporters[source.LinkTo];

            MapManager.Instance[source.MapID].CharacterLeave(character);
            character.Position  = target.Position;
            character.Direction = target.Direction;
            MapManager.Instance[target.MapID].CharacterEnter(sender, character);
        }
Example #4
0
        void OnMapTeleport(NetConnection <NetSession> conn, MapTeleportRequest request)
        {
            Log.InfoFormat("MapTeleportRequest: TeleportID: {0}", request.teleporterId);

            TeleporterDefine from        = DataManager.Instance.Teleporters[request.teleporterId];
            TeleporterDefine destination = DataManager.Instance.Teleporters[from.LinkTo];

            if (from == null)
            {
                Log.ErrorFormat("TeleportID {0} cannot be found", request.teleporterId);
            }

            if (destination == null)
            {
                Log.ErrorFormat("TeleportID {0} cannot be found", from.LinkTo);
            }

            Log.InfoFormat("character {0} requests teleportation {1}", conn.Session.Character.Info.Name, from.Descript);

            MapManager.Instance[from.MapID].RemoveCharacter(conn.Session.Character);

            conn.Session.Character.Position  = destination.Position;
            conn.Session.Character.Direction = destination.Direction;

            MapManager.Instance[destination.MapID].CharacterEnter(conn, conn.Session.Character);
        }
Example #5
0
    // Update is called once per frame

    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("Trigger触发");
        PlayerInputerController pc = other.GetComponent <PlayerInputerController>();

        if (pc != null && pc.isActiveAndEnabled)
        {
            TeleporterDefine td = DataManager.Instance.Teleporters[this.ID];
            if (td == null)
            {
                Debug.LogFormat("TeleporterObject:Character[{0}] Enter TeleporterObject[{1}],But TeleporterDefine not exixted",
                                pc.character.nCharacterInfo.Name, this.ID);
                return;
            }
            Debug.LogFormat("TeleporterObject:Character[{0}] Enter TeleporterObject[{1}:{2}]",
                            pc.character.nCharacterInfo.Name, this.ID, td.Name);
            if (td.LinkTo > 0)
            {
                if (DataManager.Instance.Teleporters.ContainsKey(td.ID))
                {
                    MapService.Instance.SendMapTeleport(this.ID);
                }
                else
                {
                    Debug.LogFormat("Teleporter ID:{0} LinkId{1} error!", td.ID, td.LinkTo);
                }
            }
        }
    }
Example #6
0
    public static void ExportTeleporter()
    {
        Scene currScene = EditorSceneManager.GetActiveScene();

        if (currScene.isDirty)
        {
            EditorUtility.DisplayDialog("提示", "请先保存当前场景", "确定");
            return;
        }

        string currSceneName = currScene.path;

        DataManager.Instance.Load();
        int mapCount = DataManager.Instance.Maps.Count;
        int mapIndex = 0;

        foreach (var map in DataManager.Instance.Maps)
        {
            mapIndex++;
            string mapPath = $"Assets/Levels/{map.Value.Resource}.unity";
            if (!System.IO.File.Exists(mapPath))
            {
                Debug.LogError($"map'{map.Value.Resource}' no exist");
                continue;
            }

            EditorSceneManager.OpenScene(mapPath, OpenSceneMode.Single);

            TeleporterObj[] teleporterObjs = GameObject.FindObjectsOfType <TeleporterObj>();
            int             count          = teleporterObjs.Length;
            int             index          = 0;
            foreach (var teleporter in teleporterObjs)
            {
                index++;
                if (!DataManager.Instance.Teleporters.ContainsKey(teleporter.ID))
                {
                    Debug.LogError($"没有配置ID为{teleporter.ID}的传送点");
                    continue;
                }

                TeleporterDefine define = DataManager.Instance.Teleporters[teleporter.ID];
                if (define.MapID != map.Value.ID)
                {
                    Debug.LogError($"配置ID为{teleporter.ID}的传送点的MapID" +
                                   $"与实际该传送点所在地图ID不一致");
                    continue;
                }

                define.Position  = GameObjectTool.WorldToLogicN(teleporter.transform.position);
                define.Direction = GameObjectTool.WorldToLogicN(teleporter.transform.forward);
                EditorUtility.DisplayProgressBar("提示", string.Format("Scene:{0} ({1}/{2})", map.Value.Name, mapIndex, mapCount), index * 1.0f / count);
            }
        }
        DataManager.Instance.SaveTeleporters();
        EditorSceneManager.OpenScene(currSceneName, OpenSceneMode.Single);
        EditorUtility.ClearProgressBar();
        EditorUtility.DisplayDialog("提示", "导出完成", "确定");
    }
Example #7
0
        private void PlayerEnterArena()
        {
            TeleporterDefine starPoint = DataManager.Instance.Teleporters[this.startPoint];

            this.Player.Session.Character.Position  = starPoint.Position;
            this.Player.Session.Character.Direction = starPoint.Direction;
            this.map.AddCharacter(this.Player, this.Player.Session.Character);
            this.map.CharacterEnter(this.Player, this.Player.Session.Character);
            EntityManager.Instance.AddMapEntity(this.map.ID, this.map.InstanceId, this.Player.Session.Character);
        }
Example #8
0
    public static void ExportTeleporters()
    {
        DataManager.Instance.Load();

        Scene  current      = EditorSceneManager.GetActiveScene();
        string currentScene = current.name;

        if (current.isDirty)
        {
            EditorUtility.DisplayDialog("Tip", "Please save the current scene", "OK");
            return;
        }

        List <Teleporter> allTeleporters = new List <Teleporter>();

        foreach (var map in DataManager.Instance.Maps)
        {
            string sceneFile = "Assets/Levels/" + map.Value.Resource + ".unity";
            if (!File.Exists(sceneFile))
            {
                Debug.LogErrorFormat("scene {0} does not exist!", sceneFile);
                continue;
            }

            EditorSceneManager.OpenScene(sceneFile, OpenSceneMode.Single);

            Teleporter[] teleporters = GameObject.FindObjectsOfType <Teleporter>();
            foreach (var teleporter in teleporters)
            {
                if (!DataManager.Instance.Teleporters.ContainsKey(teleporter.ID))
                {
                    EditorUtility.DisplayDialog("Error",
                                                String.Format("in map {0}, teleporter {1} does not exist!", map.Value.Name, teleporter.ID), "OK");
                    return;
                }

                TeleporterDefine define = DataManager.Instance.Teleporters[teleporter.ID];
                if (define.ID != teleporter.ID)
                {
                    EditorUtility.DisplayDialog("Error",
                                                String.Format("In map {0}, teleporter[{1}], mapID: {3} does not match", map.Value.Name,
                                                              teleporter.ID, define.ID), "OK");
                }

                define.Position  = GameObjectTool.WorldToLogicN(teleporter.transform.position);
                define.Direction = GameObjectTool.WorldToLogicN(teleporter.transform.forward);
            }
        }

        DataManager.Instance.SaveTeleporters();
        EditorSceneManager.OpenScene("Assets/Levels/" + currentScene + ".unity");
        EditorUtility.DisplayDialog("Tip", "All teleporters are successfully exported!", "OK");
    }
Example #9
0
    public static void ExportTeleporters()
    {
        DataManager.Instance.Load();

        Scene  current      = EditorSceneManager.GetActiveScene();
        string currentScene = current.name;

        if (current.isDirty)
        {
            EditorUtility.DisplayDialog("提示", "请先保存场景", "确定");
            return;
        }

        List <TeleporterObject> allTeleporters = new List <TeleporterObject>();

        foreach (var map in DataManager.Instance.Maps)
        {
            string sceneFile = "Assets/Levels/" + map.Value.Resource + ".unity";
            if (!System.IO.File.Exists(sceneFile))
            {
                Debug.LogWarningFormat("Scene {0} not existed!", sceneFile);
                continue;
            }
            EditorSceneManager.OpenScene(sceneFile, OpenSceneMode.Single);

            TeleporterObject[] teleporters = GameObject.FindObjectsOfType <TeleporterObject>();
            foreach (var teleporter in teleporters)
            {
                if (!DataManager.Instance.Teleporters.ContainsKey(teleporter.ID))
                {
                    EditorUtility.DisplayDialog("错误", string.Format("地图:{0} 中配置的 Teleporter:[{1}]中不存在", map.Value.Resource, teleporter.ID), "确定");
                    return;
                }

                TeleporterDefine def = DataManager.Instance.Teleporters[teleporter.ID];
                if (def.MapID != map.Value.ID)
                {
                    EditorUtility.DisplayDialog("错误", string.Format("地图:{0} 中配置的 Teleporter:[{1}] MapID:[{2}] 错误", map.Value.Resource, teleporter.ID, def.MapID), "确定");
                    return;
                }
                def.Position  = GameObjectTool.WorldToLogicN(teleporter.transform.position);
                def.Direction = GameObjectTool.WorldToLogicN(teleporter.transform.forward);
            }
        }
        DataManager.Instance.SaveTeleporters();
        EditorSceneManager.OpenScene("Assets/Levels/" + currentScene + ".unity");
        EditorUtility.DisplayDialog("提示", "传送点到处完成", "确定");
    }
Example #10
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerInputController pc = other.gameObject.GetComponent <PlayerInputController>();

        if (pc && pc.isActiveAndEnabled)
        {
            TeleporterDefine td = DataManager.Instance.Teleporters[this.ID];
            if (td != null)
            {
                MapService.Instance.SendTelepoter(this.ID);
            }
            else
            {
                Debug.LogError("传送点有误:" + this.ID);
            }
        }
    }
Example #11
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerInputController pc = other.GetComponent <PlayerInputController>();

        if (pc != null && pc.enabled)
        {
            Debug.Log($"OnTriggerEnter Teleporter{ID}");
            TeleporterDefine define = null;
            if (Managers.DataManager.Instance.Teleporters.TryGetValue(ID, out define))
            {
                if (define.LinkTo > 0 && Managers.DataManager.Instance.Teleporters.ContainsKey(define.LinkTo))
                {
                    Services.MapService.Instance.SendMapTeleporter(ID);
                }
            }
        }
    }
Example #12
0
    public void SendPlayerTeleport(int teleportId)
    {
        TeleporterDefine define = DataManager.Instance.Teleporters[teleportId];

        if (define.LinkTo == 0)
        {
            return;
        }

        CharacterManager.Instance.Clear();

        NetMessage message = new NetMessage();

        message.Request             = new NetMessageRequest();
        message.Request.mapTeleport = new MapTeleportRequest();
        message.Request.mapTeleport.teleporterId = teleportId;

        NetClient.Instance.SendMessage(message);
    }
Example #13
0
    private void OnTriggerEnter(Collider collider)
    {
        PlayerController pc = collider.GetComponent <PlayerController>();

        //Debug.LogFormat("asdfsadf");
        if (pc != null && pc.isActiveAndEnabled)
        {
            Debug.LogFormat("Play enter teleport {0}", this.ID);
            TeleporterDefine td = DataManager.Instance.Teleporters[this.ID];

            if (td.LinkTo > 0 && DataManager.Instance.Teleporters.ContainsKey(td.LinkTo))
            {
                MapService.Instance.SendMapTeleport(this.ID);
            }
            else
            {
                Debug.LogWarningFormat("Teleport {0} equal to 0 or not exist ", td.LinkTo);
            }
        }
    }
Example #14
0
        private void OnMapTeleport(NetConnection <NetSession> sender, MapTeleportRequest message)
        {
            if (!DataManager.Instance.Teleporters.ContainsKey(message.teleporterId))
            {
                Log.WarningFormat("character {0} request teleport {1} not exist", sender.Session.Character.Info.Id, message.teleporterId);
                return;
            }
            TeleporterDefine sourse = DataManager.Instance.Teleporters[message.teleporterId];

            if (sourse.LinkTo == 0 || !DataManager.Instance.Teleporters.ContainsKey(sourse.LinkTo))
            {
                Log.WarningFormat("character {0} request teleport linkto {1} not exist", sender.Session.Character.Info.Id, message.teleporterId);
                return;
            }
            TeleporterDefine target = DataManager.Instance.Teleporters[sourse.LinkTo];

            MapManager.Instance[sourse.MapID].CharacterLeave(sender.Session.Character);
            sender.Session.Character.Info.mapId = target.MapID;
            sender.Session.Character.Position   = target.Position;
            sender.Session.Character.Direction  = target.Direction;
            MapManager.Instance[target.MapID].CharacterEnter(sender, sender.Session.Character);
        }