Beispiel #1
0
        public bool ChangeCurrentLevel(string name)
        {
            var data = GetLevelData(name);

            if (data == null)
            {
                return(false);
            }

            CurrentLevel = data;

            return(false);
        }
Beispiel #2
0
        public SaveBlack GetLevelData(string name)
        {
            SaveBlack ret = null;

            foreach (var black in BlacksTable)
            {
                if (black.LevelName.Equals(name))
                {
                    ret = black;
                    break;
                }
            }

            return(ret);
        }
Beispiel #3
0
        public void AddNewLevel(string levelName, string asName, Vector3 pos)
        {
            var data = GetLevelData(levelName);

            if (data != null)
            {
                return;
            }

            CurrentLevel             = new SaveBlack();
            CurrentLevel.LevelName   = levelName;
            CurrentLevel.LevelASName = asName;
            CurrentLevel.CollectIds  = new List <int>();
            CurrentLevel.BornPos     = pos;

            BlacksTable.Add(CurrentLevel);
        }
Beispiel #4
0
        void Start()
        {
            if (PlayerObject == null)
            {
                PlayerObject = GameObject.Find("Faylisa");
                if (PlayerObject == null)
                {
                    PlayerObject = GameObject.Find("BlueHat");
                }
            }
            RecordingTime = true;
            IsPause       = false;
            InputMgr      = gameObject.AddComponent <GameInput>();
            PlayerLogic   = PlayerObject.AddMissingComponent <Player>();
            LineMgr       = gameObject.AddMissingComponent <LineMgr>();
            UiManager     = gameObject.AddMissingComponent <UIManager>();
            UiManager.OpenUI(0);

            Config = new GameConfig();
            Config.Load();

            // 查找开关
            var s = GameObject.Find("GameSwitch");

            if (s != null)
            {
                WorldSwith = s.GetComponent <GameSwitch>();
            }

            if (WorldSwith == null)
            {
                WorldSwith = new GameSwitch();
                WorldSwith.ForbidDrawLine      = false;
                WorldSwith.ForbidTimeOperation = false;
            }

            if (Camera.main.GetComponent <ProCamera2D>().CameraTargets.Count == 0)
            {
                Camera.main.GetComponent <ProCamera2D>().AddCameraTarget(PlayerObject.transform);
            }
            Camera.main.GetComponent <ProCamera2DTransitionsFX>().TransitionEnter();

            GameObject bgm = GameObject.Find("BGManager");

            if (bgm == null)
            {
                Instantiate(Resources.Load("prefabs/Utilities/BGManager"));
            }

            // 首先从gamedata中得到当前level的保存信息
            // 如果没有保存内容,那么就创建一个
            if (GameData.Instance != null)
            {
                SaveBlack data = GameData.Instance.GetLevelData(LevelName);
                if (data == null)
                {
                    GameData.Instance.AddNewLevel(LevelName, LevelName, PlayerLogic.Position);
                }
                else
                {
                    GameData.Instance.ChangeCurrentLevel(LevelName);

                    // 重置玩家坐标
                    PlayerLogic.SetRevivePoint(data.BornPos);
                    PlayerLogic.Position = data.BornPos;
                }
            }

            CreateLevelItem();

            PlayerLogic.OnPickUpAction += GameData.Instance.SaveCollectPickup;
        }