예제 #1
0
 void Awake()
 {
     genLavas = GetComponent<Sct_LavasHandler>();
     rainlauncher = GetComponent<Sct_RainLauncher>();
     birdgenerator = GetComponent<Sct_BirdGenerator>();
     froggenerator = GetComponent<Sct_FrogGenerator>();
 }
예제 #2
0
 void Awake()
 {
     _createlava = _instance.AddComponent<Sct_LavasHandler>();
     _createfood = _instance.AddComponent<Sct_FoodControl>();
     _createweather = _instance.AddComponent<Sct_WeatherControl>();
     _createitems = _instance.AddComponent<Sct_ItemControl>();
 }
예제 #3
0
	void Start ()
    {
        _lavaController = Sct_GameHandler.CreateInstance.GetComponent<Sct_LavasHandler>();
	}
예제 #4
0
    /// <summary>
    /// 初始化場景
    /// </summary>
    protected override void InitSceneDo()
    {
        #region 接收資料
        //接收參數 設定相關項目
        if( Datalist != null)
        {
            //蟲蟲顏色編號 : 0.沒放蟲 1.藍色 2.綠色 3.紫色 4.紅色
            lavaPosData = (int[])Datalist[0];
            #if Debug
            Debug.Log("左上蟲蟲編號: " + lavaPosData[0]);
            Debug.Log("右上蟲蟲編號: " + lavaPosData[1]);
            Debug.Log("左下蟲蟲編號: " + lavaPosData[2]);
            Debug.Log("右下蟲蟲編號: " + lavaPosData[3]);
            #endif
        }
        #endregion

        #region 設定相關介面
        //生成Panel
        _BGPanel		= this.LoadPrefab("Pfb_Game_BGPanel"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
        _GamePanel 		= this.LoadPrefab("Pfb_GamePanel"		, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
        _GamePanel.SetActive(true);
        _GameStartPanel	= this.LoadPrefab("Pfb_StartPanel"		, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
        _GameStopPanel 	= this.LoadPrefab("Pfb_StopPanel"		, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
        _GameEndPanel 	= this.LoadPrefab("Pfb_EndPanel"		, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
           		_GameTimePanel	= this.LoadPrefab("Pfb_Game_TimePanel"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_CENTER);
        _TLControl		= this.LoadPrefab("Pfb_BtnControl_TL"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_TOP_LEFT);
        _TRControl 		= this.LoadPrefab("Pfb_BtnControl_TR"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_TOP_RIGHT);
        _BLControl		= this.LoadPrefab("Pfb_BtnControl_BL"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_BOTTOM_LEFT);
        _BRControl		= this.LoadPrefab("Pfb_BtnControl_BR"	, Sct_DEFCONST.FILE_PATH.GAME_PREFAB_FILE_PATH,Sct_DEFCONST.ANCHOR_SIDE.ANCHOR_BOTTOM_RIGHT);

        //取得物件
        /*OLD Btn
        btn_Left[0]		= _TLControl.transform.Find("Btn_Left").gameObject;
        btn_Left[1]		= _TRControl.transform.Find("Btn_Left").gameObject;
        btn_Left[2]		= _BLControl.transform.Find("Btn_Left").gameObject;
        btn_Left[3]		= _BRControl.transform.Find("Btn_Left").gameObject;
        btn_Right[0]	= _TLControl.transform.Find("Btn_Right").gameObject;
        btn_Right[1]	= _TRControl.transform.Find("Btn_Right").gameObject;
        btn_Right[2]	= _BLControl.transform.Find("Btn_Right").gameObject;
        btn_Right[3]	= _BRControl.transform.Find("Btn_Right").gameObject;
        */
        btn_Control[0]	= _TLControl.transform.Find("Btn_Control").gameObject;
        btn_Control[1]	= _TRControl.transform.Find("Btn_Control").gameObject;
        btn_Control[2]	= _BLControl.transform.Find("Btn_Control").gameObject;
        btn_Control[3]	= _BRControl.transform.Find("Btn_Control").gameObject;
        btn_Bouns[0]	= _TLControl.transform.Find("Btn_Bonus").gameObject;
        btn_Bouns[1]	= _TRControl.transform.Find("Btn_Bonus").gameObject;
        btn_Bouns[2]	= _BLControl.transform.Find("Btn_Bonus").gameObject;
        btn_Bouns[3]	= _BRControl.transform.Find("Btn_Bonus").gameObject;
        sprite_CircleBg[0]	= _TLControl.transform.Find("Sprite_CircleBg").GetComponent<UISprite>();
        sprite_CircleBg[1]	= _TRControl.transform.Find("Sprite_CircleBg").GetComponent<UISprite>();
        sprite_CircleBg[2]	= _BLControl.transform.Find("Sprite_CircleBg").GetComponent<UISprite>();
        sprite_CircleBg[3]	= _BRControl.transform.Find("Sprite_CircleBg").GetComponent<UISprite>();
        itemGroupPanel[0] = _TLControl.transform.Find("ItemPanel").gameObject;
        itemGroupPanel[1] = _TRControl.transform.Find("ItemPanel").gameObject;
        itemGroupPanel[2] = _BLControl.transform.Find("ItemPanel").gameObject;
        itemGroupPanel[3] = _BRControl.transform.Find("ItemPanel").gameObject;
        btn_Catcher[0] = itemGroupPanel[0].transform.Find("Btn_Item1").gameObject;
        btn_Catcher[1] = itemGroupPanel[1].transform.Find("Btn_Item1").gameObject;
        btn_Catcher[2] = itemGroupPanel[2].transform.Find("Btn_Item1").gameObject;
        btn_Catcher[3] = itemGroupPanel[3].transform.Find("Btn_Item1").gameObject;
        btn_Poison[0] = itemGroupPanel[0].transform.Find("Btn_Item2").gameObject;
        btn_Poison[1] = itemGroupPanel[1].transform.Find("Btn_Item2").gameObject;
        btn_Poison[2] = itemGroupPanel[2].transform.Find("Btn_Item2").gameObject;
        btn_Poison[3] = itemGroupPanel[3].transform.Find("Btn_Item2").gameObject;
        sprite_BtnCatcher[0] = btn_Catcher[0].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnCatcher[1] = btn_Catcher[1].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnCatcher[2] = btn_Catcher[2].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnCatcher[3] = btn_Catcher[3].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnPoison[0] = btn_Poison[0].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnPoison[1] = btn_Poison[1].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnPoison[2] = btn_Poison[2].transform.Find("ItemSprite").GetComponent<UISprite>();
        sprite_BtnPoison[3] = btn_Poison[3].transform.Find("ItemSprite").GetComponent<UISprite>();
        //設定按鈕發送事件的目標
        for(int btnNum = 0; btnNum < Sct_DEFCONST.LAVA_AMOUNT_MAX; btnNum++)
        {
            //Sct_UIMgr.instance.setMsgTarget(btn_Left[btnNum]);
            //Sct_UIMgr.instance.setMsgTarget(btn_Right[btnNum]);
            Sct_UIMgr.instance.setMsgTarget(btn_Control[btnNum]);
            Sct_UIMgr.instance.setMsgTarget(btn_Bouns[btnNum]);
            Sct_UIMgr.instance.setMsgTarget(btn_Catcher[btnNum]);
            Sct_UIMgr.instance.setMsgTarget(btn_Poison[btnNum]);
        }
        //設定道具按鈕隱藏
        for(int lavaTag = 0;lavaTag < Sct_DEFCONST.LAVA_AMOUNT_MAX; lavaTag++)
        {
            setSkillBtn(lavaTag+1,1,false);
            setSkillBtn(lavaTag+1,2,false);
        }
        //每個控制器初始化
        InitControlsColor(lavaPosData,WeatherType.Sunny);
        //隱藏開始介面
        Sct_UIMgr.instance.setObjVisable(_GameStartPanel,false);
        //隱藏暫停介面
        Sct_UIMgr.instance.setObjVisable(_GameStopPanel,false);
        //隱藏結束介面
        Sct_UIMgr.instance.setObjVisable(_GameEndPanel,false);

        //背景設定
        sunnyBackgroundObj = _BGPanel.transform.Find("Sprite_SunnyBg").gameObject;
        cloudyBackgroundObj = _BGPanel.transform.Find("Sprite_CloudyBg").gameObject;
        rainyBackgroundObj = _BGPanel.transform.Find("Sprite_RainyBg").gameObject;
        //sunnyBackgroundSprite = sunnyBackgroundObj.GetComponent<UISprite>();
        //cloudyBackgroundSprite = cloudyBackgroundObj.GetComponent<UISprite>();
        //rainyBackgroundSprite = rainyBackgroundObj.GetComponent<UISprite>();

        setWeatherBackground(WeatherType.Sunny);
        //時間顯示設定
        time_TenDigit 		= _GameTimePanel.transform.Find("Sprite_TenDigit").GetComponent<UISprite>();
        time_SingleDigit 	= _GameTimePanel.transform.Find("Sprite_SingleDigit").GetComponent<UISprite>();
        //setTimeInfo(90,false);
        #endregion

        #region 遊戲相關設定
        //產生遊戲管理器實體
        _GameMgr = Sct_GameHandler.CreateInstance;
        //取得蟲蟲管理器
        lavaHandler = _GameMgr.GetComponent<Sct_LavasHandler>();

        //按輸入值產生玩家
        if (_GameMgr != null)
        {
            for (int i = 0 ; i < lavaPosData.Length ; ++i)
            {
                lavaHandler.AddPlayer(i, lavaPosData [i]);
            }
        }
        #endregion

        //打開環境音效
        if (PlayerPrefs.GetInt("EnableSound") == 1)
            Sct_SoundManager.Instance.EnvironmentSFX(true);
        else
            Sct_SoundManager.Instance.EnvironmentSFX(false);
    }