예제 #1
0
    public void EnterScene(GameSceneId sceneId)
    {
        if (m_CurrentSceneData != null)
        {
            if (m_CurrentSceneData.sceneId == sceneId)
            {
                return;
            }

            if (m_CurrentSceneData.sceneObject != null)
            {
                m_CurrentSceneData.sceneObject.ShowSceneObject(false);
            }
        }

        GameSceneData sceneData = FindSceneData(sceneId);

        if (sceneData == null)
        {
            Debug.LogErrorFormat("Didn't Find Scene:{0}", sceneId);
            return;
        }

        if (sceneData.sceneObject == null)
        {
            sceneData.sceneObject = GlobalTools.AddChild <GameScene>(sceneParent, sceneData.scenePrefab);
        }
        sceneData.sceneObject.ShowSceneObject(true);
        m_CurrentSceneData = sceneData;
    }
    /// <summary>
    /// 加载场景
    /// </summary>
    /// <param name="sceneID"></param>
    public static void LoadScene(int sceneID)
    {
        GUIManager.HideAllView();
        GameSceneData sceneData = GameSceneData.GetByID(sceneID);

        if (sceneData == null)
        {
            Debuger.LogError("场景ID错误-" + sceneID);
            return;
        }
        string    stateName = sceneData.stateName;
        GameState state     = null;

        if (!map.TryGetValue(stateName, out state))
        {
            state = Assembly.GetExecutingAssembly().CreateInstance(stateName) as GameState;
            if (state == null)
            {
                Debuger.LogError("游戏状态为空" + stateName);
                return;
            }
            map.Add(stateName, state);
        }
        currentSceneData = sceneData;
        SetState(state);

        DownloadManager.Instance.LoadNormalScene(sceneData, state.LoadComplete);
    }
예제 #3
0
    void OnEnable()
    {
        //Declaring our DataController reference.//
        dataController = FindObjectOfType <DataController>();
        gameData       = dataController.GetGameData();
        gameSceneData  = gameData.gameSceneData;
        int wicksNeededToWin = gameSceneData.wicksNeededToWin;

        PlayerController.SetWicksNeededToWin(wicksNeededToWin);

        float forceOfGravity = gameSceneData.forceOfGravity;

        PlayerController.setForceofGravity(forceOfGravity);

        float sideVelocity = gameSceneData.sideVelocity;

        PlayerController.setSideVelocity(sideVelocity);

        float upThrust = gameSceneData.upThrust;

        PlayerController.setUpThrust(upThrust);

        float wickHeight = gameSceneData.wickHeight;

        Candle.setWickHeight(wickHeight);

        float stickHeight = gameSceneData.stickHeight;

        Candle.setStickHeight(stickHeight);

        winScene      = gameSceneData.winScene;
        gameOverScene = gameSceneData.gameOverScene;
    }
예제 #4
0
    public void LoadGame(string gameName)
    {
        GameSceneData gameSceneData = persistantDataManager.GetGameData(gameName);

        currentGameSceneData = gameSceneData;
        UnityEngine.SceneManagement.SceneManager.LoadScene("game", LoadSceneMode.Single);
    }
예제 #5
0
    public void CreateNewGame(int playerCount)
    {
        GameSceneData data = GameSceneData.NewGameDefault();

        persistantDataManager.CreateGameSceneData(data);
        currentGameSceneData = data;
        UnityEngine.SceneManagement.SceneManager.LoadScene("game", LoadSceneMode.Single);
    }
예제 #6
0
    IEnumerator _LoadNormalScene(GameSceneData data, LoadCallBack loadHandler, int loadingType = 1, params object[] args)
    {
        float startPercent = 0;

        yield return(new WaitForSeconds(0.1f));

        //GameObject[] sceneObject = GameObject.FindGameObjectsWithTag("scene");
        //for (int i = 0; i < sceneObject.Length; i++)
        //{
        //    sceneObject[i].SetActive(false);
        //}
        yield return(new WaitForSeconds(0.1f));

        int            startProgress   = (int)(startPercent * 100);
        int            displayProgress = startProgress;
        int            toProgress      = startProgress;
        AsyncOperation op = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(data.levelName);

        op.allowSceneActivation = false;
        while (op.progress < 0.9f)
        {
            toProgress = startProgress + (int)(op.progress * (1.0f - startPercent) * 100);
            while (displayProgress < toProgress)
            {
                ++displayProgress;
                SetProgress(displayProgress);
                yield return(null);
            }
            yield return(null);
        }

        toProgress = 100;
        while (displayProgress < toProgress)
        {
            ++displayProgress;
            SetProgress(displayProgress);
            yield return(null);
        }

        op.allowSceneActivation = true;
        yield return(new WaitForSeconds(0.1f));

        if (data.ResRefreshPointsPath.Length > 1)
        {
            GameObject point = Res.ResourceManager.Instance.Instantiate <GameObject>(data.ResRefreshPointsPath);
            point.transform.parent = null;
            point.transform.Reset();
        }

        yield return(new WaitForSeconds(1f));


        if (loadHandler != null)
        {
            loadHandler(args);
        }
    }
예제 #7
0
    //
    //======================================================================================
    /// <summary>
    /// 加载普通的场景
    /// </summary>
    /// <param name="sceneName"></param>
    /// <param name="startPercent"></param>
    /// <returns></returns>
    public void LoadNormalScene(int sceneId, LoadCallBack loadHandler, int loadingType = 1, params object[] args)
    {
        GameSceneData data = GameSceneData.GetByID(sceneId);

        if (data == null)
        {
            Debuger.LogError("场景ID错误-" + sceneId);
        }
        LoadNormalScene(data, loadHandler, loadingType, args);
    }
예제 #8
0
    public void StartMultiplayerGame()
    {
        GameSceneData data = GameSceneData.NewGameDefault();

        currentGameSceneData = data;
        Hashtable hashTable = PhotonNetwork.CurrentRoom.CustomProperties;

        hashTable[NetworkHelper.Constants.GAME_SCENE_DATA] = data;

        PhotonNetwork.LoadLevel("skimirish");
    }
예제 #9
0
        private void Change(GameSceneData data)
        {
            Assert.IsNotNull <GameSceneData>(data);
            if (data == null)
            {
#if UNITY_EDITOR
                Debug.LogError("[SCENE] 화면 정보가 없습니다.");
#endif
                return;
            }

            if (!isDone)
            {
#if UNITY_EDITOR
                Debug.Log("[SCENE] 화면 전환 중이므로 요청을 무시합니다.");
#endif
                return;
            }

            isDone = false;

            sceneData = data;
            sceneData.backgroundName = GameModeManager.instance.GetBackgroundName(data);

            var background = sceneTable.GetBackground(sceneData.backgroundName);
            // 환경음 초기화. 보통은 없다.
            sceneData.ambienceSound = string.Empty;
            if (background != null)
            {
                if (string.IsNullOrEmpty(sceneData.bgm))
                {
                    sceneData.bgm = background.bgm;
                }

                sceneData.ambienceSound = background.ambienceSound;

                if (FlashEffectManager.available)
                {
                    FlashEffectManager.instance.use = background.useFlash;
                }
            }

            /// 배경씬 변경이 필요한지 확인합니다.
            bool changeBackground = backgroundManager.ShouldChange(sceneData.backgroundName);

            /// 페이드 아웃이 필요한 경우 처리합니다.
            useFade = data.useFade || changeBackground;

            SoundManager.OnSceneLeave(sceneData);
            ResetTodo();
            OnPreChange();
        }
예제 #10
0
    static public QuestData QuestSceneDataLoad(string _SceneName)
    {
        GameSceneData scene = Resources.Load <GameSceneData>(_SceneName + "_data");
        QuestData     data  = new QuestData();

        data.m_Icon         = scene.m_SceneImage;
        data.m_Level        = scene.m_Level;
        data.m_ListDropItem = scene.m_DropItemList;
        data.m_Name         = scene.m_StageName;
        data.m_SceneName    = scene.m_SceneName;
        data.m_StaminaValue = scene.m_StaminaValue;
        data.m_Lock         = scene.m_Lock;
        return(data);
    }
예제 #11
0
    void OnEnable()
    {
        gameScene.SetActive(true);
        dataController = FindObjectOfType <DataController>();
        gameData       = dataController.GetGameData();
        gameSceneData  = gameData.gameSceneData;
        wickHitCount   = 0;
        gameObject.GetComponent <Renderer>().material.color = Color.white;
        pinky = gameObject.GetComponent <Rigidbody2D>();
        pinky.gravityScale = gameSceneData.forceOfGravity;

        gameObject.transform.localPosition                  = new Vector3(-1200, 200, 0);
        gameObject.GetComponent <Renderer>().enabled        = true;
        coverLayer.GetComponent <Renderer>().material.color = new Color((float)9 / 256, (float)9 / 256f, (float)14 / 256f, 0.95f);
    }
예제 #12
0
    private GameSceneData FindSceneData(GameSceneId sceneId)
    {
        GameSceneData sceneData = null;

        foreach (var data in sceneDatas)
        {
            if (data.sceneId == sceneId)
            {
                sceneData = data;
                break;
            }
        }

        return(sceneData);
    }
예제 #13
0
    static public QuestData QuestSceneDataLoad(string _SceneName, E_SCENETYPE _Type)
    {
        GameSceneData scene = Resources.Load <GameSceneData>(_SceneName + "_data");
        QuestData     data  = new QuestData();

        data.m_Icon         = scene.m_SceneImage;
        data.m_Level        = scene.m_Level;
        data.m_Multiplay    = _Type == E_SCENETYPE.SINGLE ? false : true;
        data.m_ListDropItem = scene.m_DropItemList;
        data.m_Name         = scene.m_StageName;
        data.m_SceneName    = scene.m_SceneName;
        data.m_StaminaValue = scene.m_StaminaValue;
        data.m_Lock         = scene.m_Lock;
        return(data);
    }
예제 #14
0
    void OnEnable()
    //void Start()
    {
        Debug.Log("player controller called here");
        gameScene.SetActive(true);

        dataController = FindObjectOfType <DataController>();
        gameData       = dataController.GetGameData();
        gameSceneData  = gameData.gameSceneData;

        wickHitCount = 0;
        gameObject.GetComponent <Renderer>().material.color = Color.white;
        rb2d = gameObject.GetComponent <Rigidbody2D>();
        rb2d.gravityScale = gameSceneData.forceOfGravity;
        gameObject.transform.localPosition = new Vector3(-1000, 200, 0);
        coverLayer.GetComponent <Renderer>().material.color = new Color((float)9 / 256, (float)9 / 256f, (float)14 / 256f, 0.95f);
    }
예제 #15
0
    //同步场景数据
    public void SendGameScenesData()
    {
        Debug.Log("同步数据中...");
        Dictionary <string, System.Object> result = new Dictionary <string, System.Object>();

        result.Add("Type", "Fight");
        //同步玩家生命值
        result.Add("p1HP", GameFightData.p1HP);
        result.Add("p2HP", GameFightData.p2HP);
        //同步战斗数据
        //result.Add("p1Money")

        //同步地图场景数据
        GameSceneData gameSceneData = new GameSceneData();

        for (int i = 0; i < p1map.Length; i++)
        {
            for (int j = 0; j < p1map[i].pos.Length; j++)
            {
                GameUnitData gameUnitData = new GameUnitData()
                {
                    unitId = !p1map[i].pos[j].build ? p1map[i].pos[j].unit.unitData.Id : 0,//id==0代表没有单位
                    HP     = !p1map[i].pos[j].build ? p1map[i].pos[j].unit.unitData.HP : 0
                };
                gameSceneData.p1[i][j] = gameUnitData;
            }
        }
        for (int i = 0; i < p2map.Length; i++)
        {
            for (int j = 0; j < p2map[i].pos.Length; j++)
            {
                GameUnitData gameUnitData = new GameUnitData()
                {
                    unitId = !p2map[i].pos[j].build ? p2map[i].pos[j].unit.unitData.Id : 0,//id==0代表没有单位
                    HP     = !p2map[i].pos[j].build ? p2map[i].pos[j].unit.unitData.HP : 0
                };
                gameSceneData.p2[i][j] = gameUnitData;
            }
        }
        result.Add("data", gameSceneData);
        GameData.webSocket.Send(JsonMapper.ToJson(result));
    }
예제 #16
0
    protected override void Awake()
    {
        base.Awake();

        for (int i = 0; i < (int)E_TEAMTYPE.MAX; ++i)
        {
            m_ListCharacters.Add(new List <Character>());
        }

        gameObject.AddComponent <FrameChecker>();
        Instantiate(m_StageDefaultCamera, Vector3.zero, Quaternion.identity);
        Resources.Load <Shader>(m_DissolveShader.name);
        m_GameSceneData = Resources.Load <GameSceneData>(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + "_data");
        if (m_GameSceneData)
        {
            m_DropItemList = m_GameSceneData.m_DropItemList.ToArray();
        }

        StartCoroutine(C_Initialize());
    }
예제 #17
0
    public override void OnActive(object data)
    {
        base.OnActive(data);
        string pictureName;

        if (data != null)
        {
            sceneData = data as GameSceneData;
        }
        else
        {
            int stageToLoad = User.GetContinueStage();
            //User.SaveStageProgress(1);
            sceneData = new GameSceneData(stageToLoad);
        }

        if (sceneData.stageID < 0)
        {
            Debug.Log("Stage ID < 0, loading stage using picture name instead");
            pictureName = sceneData.pictureID;
#if SQLITE4UNITY
            stageData = GameDatabase.Service.GetStageDataFromPicture(pictureName);
            if (stageData == null)
            {
                stageData = GameDatabase.Service.GetStageData(1);
            }
#else
            not implemented
                stageData = DatabaseSimpleSQL.Instance.GetStageData(1);
#endif
        }
        else
        {
#if SQLITE4UNITY
            stageData = GameDatabase.Service.GetStageData(sceneData.stageID);
# else
            stageData = DatabaseSimpleSQL.Instance.GetStageData(sceneData.stageID);
#endif
            pictureName = stageData.picture_name;
        }
    // Use this for initialization
    private void Awake()
    {
        Instance = this;
        try
        {
            gameSceneData = SceneManager.Instance.currentGameSceneData;
            if (gameSceneData == null)
            {
                gameSceneData = GameSceneData.NewGameDefault();
            }
        }
        catch
        {
            gameSceneData = GameSceneData.NewGameDefault();
        }
        Player[] players = new Player[gameSceneData.players.Count];

        for (int i = 0; i < gameSceneData.players.Count; i++)
        {
            players[i] = gameSceneData.players[i].player;
        }

        PlayerDatabase.Instance.SetUpDatabase(players);

        /*foreach (PlayerPersistance playerPersistance in gameSceneData.players)
         * {
         *  foreach (ShipControllerPersistance shipPersistence in playerPersistance.ships)
         *  {
         *      Spawner.Instance.SpawnShip(shipPersistence.shipType, playerPersistance.playerNumber, shipPersistence.mapObjectPersitance.localPosition, Quaternion.identity);
         *  }
         * }
         *
         * CreateAsteroidFields();
         *
         * SetUpPlayerManager();*/
        SetUpPlayerManager();
        SetUpAI();
        LoadGameSceneData();
        MonoBehaviourEvents.cleaner.StartThread();
    }
예제 #19
0
    void OnEnable()
    {
        //Declaring our DataController reference.//
        dataController = FindObjectOfType <DataController>();

        gameData = dataController.GetGameData();
        //startScene.SetActive(true);
        //gameScene.SetActive(false);
        Debug.Log("start scene set active in Game Controller");
        gameSceneData = gameData.gameSceneData;
        // Debug.Log("That's correct" );
        int wicksNeededToWin = gameSceneData.wicksNeededToWin;

        PlayerController.SetWicksNeededToWin(wicksNeededToWin);

        float forceOfGravity = gameSceneData.forceOfGravity;

        PlayerController.setForceofGravity(forceOfGravity);
        float sideVelocity = gameSceneData.sideVelocity;

        PlayerController.setSideVelocity(sideVelocity);
        float upThrust = gameSceneData.upThrust;

        PlayerController.setUpThrust(upThrust);

        float wickHeight = gameSceneData.wickHeight;

        Candle.setWickHeight(wickHeight);
        float stickHeight = gameSceneData.stickHeight;

        Candle.setStickHeight(stickHeight);

        //retrieving strings from Data class.
        winScene      = gameSceneData.winScene;
        gameOverScene = gameSceneData.gameOverScene;
    }
예제 #20
0
 public void LoadMainMenu()
 {
     currentGameSceneData = null;
     UnityEngine.SceneManagement.SceneManager.LoadScene("mainMenu", LoadSceneMode.Single);
 }
예제 #21
0
        // CONSTRUCTOR ---------------------------------------------------------------------------------------
        public LoadingScene(string pDestination, GameSceneData pData = null)
        {
            if(pData==null) {
                pData = DEFAULT_GAME_SCENE_DATA;
                GAME_SCENE_DATA = pData;
            }

            this.Camera.SetViewFromViewport();

            stopwatch = Stopwatch.StartNew();

            _levelNumber = pData.level;
            _gameTimer = pData.timeLimit;
            _angle = 0.0f;
            _timer = 0.0f;
            _loadIndex = 0;

            Hub = new Node();
            Hub.Position = new Vector2(480.0f, 272.0f);
            this.AddChild(Hub);

            //			LoadingSpinner = Support.SpriteFromFile("/Application/assets/images/UI/loading.png");
            LoadingSpinner = Support.SpriteFromAtlas("crystallonUI", "loading.png");
            LoadingSpinner.Pivot = new Vector2(0.5f, 0.5f);
            LoadingSpinner.Position = new Vector2(-145.0f, -119.0f);
            LoadingSpinner.RegisterPalette(1);
            Hub.AddChild(LoadingSpinner);

            LoadingText = new Label("loading", UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold")));
            LoadingText.Position = new Vector2(445.0f, 257.0f);
            LoadingText.RegisterPalette(2);
            this.AddChild(LoadingText);

            // LOADING PROCEDURE HEADER
            loadProc = new List<Action>{
                () => {
                    ;//dummy
                },
                () => {
                    InputManager.Instance.enabled = false;
                },
                // PRE-LOAD LEVEL DATA
                () => {
                    LevelManager.Instance.LoadGameData();
                }
            };

            switch(pDestination) {
            case("Level Select"):
                AddLevelSelectProcs();
                break;
            case("Menu"):
                AddMenuProcs();
                break;
            case("Game"):
            default:
                AddGameProcs();
                break;
            }

            loadProc.AddRange( new List<Action> {
                () => {
                    InputManager.Instance.enabled = true;
                }
            } );

            Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);
        }
예제 #22
0
 public void LoadNormalScene(GameSceneData data, LoadCallBack loadHandler, int loadingType = 1, params object[] args)
 {
     StartCoroutine(_LoadNormalScene(data, loadHandler, loadingType, args));
 }