Example #1
0
 public bool Init()
 {
     //InitProcedure(null);
     InitLogic.StartInit();
     SceneMain.Instance.StartInnerCoroutine(InitProcedure(null));
     return(true);
 }
Example #2
0
    public bool Init()
    {
        Camera cam = Camera.main;

        if (cam == null)
        {
            cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
        }
        AudioListener mListener = cam.gameObject.GetComponent <AudioListener>();

        if (mListener == null)
        {
            if (cam != null)
            {
                mListener = cam.gameObject.AddComponent <AudioListener>();
            }
        }
        //#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
        //        BGAudio = mListener.audio;
        //#else
        LoopAudio = mListener.GetComponent <AudioSource>();
        //#endif
        if (LoopAudio == null)
        {
            LoopAudio = mListener.gameObject.AddComponent <AudioSource>();
        }
        LoopAudio_1    = mListener.gameObject.AddComponent <AudioSource>();
        LoopAudio_Gift = mListener.gameObject.AddComponent <AudioSource>();
        InitLogic.StartInit();
        SceneMain.Instance.StartInnerCoroutine(Initaudio(null));
        LoadAudioValue();
        SetBGMusicVolue(m_BgValue);
        SetMusicVolue(m_Value);
        //int bg = Random.Range(4, 7);
        int bg = 1;

        GlobalAudioMgr.Instance.PlayerBGMusic(Audio.EffectBGType.EffectBGSound2);

        //GlobalAudioMgr.Instance.PlayerBGMusic(GlobalAudioMgr.BGMusic.BgMusic0);
        return(true);
    }
    public static bool Init()
    {
        ConnectServerIdx = Utility.Range(0, ServerList.Count);
        //Object obj = ResManager.Instance.LoadObject("ServerSetting", "GlobalRes/ServerSetting/", ResType.GlobalRes, typeof(TextAsset));
        //if (obj == null)
        //    return false;
        //TextAsset ta = obj as TextAsset;
        //XmlDocument doc = new XmlDocument();
        //doc.LoadXml(ta.text);

        //XmlElement ele = doc.DocumentElement;

        //XmlNode fishNode = ele.SelectSingleNode("FishInfo");
        //XmlNode launcherNode = ele.SelectSingleNode("LauncherInfo");
        //XmlNode bulletNode = ele.SelectSingleNode("BulletInfo");
        //XmlNode skillNode = ele.SelectSingleNode("SkillInfo");
        //XmlNode otherNode = ele.SelectSingleNode("Other");
        //XmlNode fishDeadNode = ele.SelectSingleNode("FishDeadTime");

        //if (fishNode == null ||
        //    launcherNode == null ||
        //    bulletNode == null ||
        //    skillNode == null ||
        //    otherNode == null ||
        //    fishDeadNode == null)
        //{
        //    LogMgr.Log("ServerSetting load failed.");
        //    return false;
        //}
        //XmlNode childNode;
        ////fish
        //FishSetting.FISH_MAX_NUM = ushort.Parse(fishNode.Attributes["scene_max_num"].Value);
        //int fishCount = fishNode.ChildNodes.Count;
        //FishSetting.FishDataList = new FishData[fishCount];

        //for (int i = 0; i < fishCount; ++i)
        //{
        //    XmlNode node = fishNode.ChildNodes[i];
        //    FishData fd = new FishData();
        //    fd.ID = byte.Parse(node.Attributes["id"].Value);
        //    fd.Gold = ushort.Parse(node.Attributes["gold"].Value);
        //    if (FishSetting.FishDataList[fd.ID] != null)
        //    {
        //        LogMgr.Log("Exist the same fish id:" + fd.ID);
        //        return false;
        //    }
        //    FishSetting.FishDataList[fd.ID] = fd;
        //}
        ////launcher
        //int launcherCount = launcherNode.ChildNodes.Count;
        //LauncherSetting.LauncherDataList = new LauncherData[launcherCount];
        //for (int i = 0; i < launcherCount; ++i)
        //{
        //    LauncherData ld = new LauncherData();
        //    XmlNode node = launcherNode.ChildNodes[i];
        //    ld.ID = byte.Parse(node.Attributes["id"].Value);
        //    ld.Interval = float.Parse(node.Attributes["interval"].Value);
        //    ld.Energy = ushort.Parse(node.Attributes["energy"].Value);
        //    ld.Consume = byte.Parse(node.Attributes["consume"].Value);
        //    ld.Speed = float.Parse(node.Attributes["bullet_speed"].Value);
        //    ld.LaserCDTime = float.Parse(node.FirstChild.Attributes["cdtime"].Value);
        //    ld.LaserReduction.Speed = float.Parse(node.FirstChild.Attributes["speed"].Value);
        //    ld.LaserReduction.Duration1 = float.Parse(node.FirstChild.Attributes["duration1"].Value);
        //    ld.LaserReduction.Duration2 = float.Parse(node.FirstChild.Attributes["duration2"].Value);
        //    ld.LaserReduction.Duration3 = float.Parse(node.FirstChild.Attributes["duration3"].Value);

        //    if (LauncherSetting.LauncherDataList[ld.ID] != null)
        //    {
        //        LogMgr.Log("Exist the same launcher id.");
        //        return false;
        //    }
        //    LauncherSetting.LauncherDataList[ld.ID] = ld;
        //}

        ////bullet
        //BulletSetting.BULLET_MAX_NUM = byte.Parse(bulletNode.Attributes["scene_max_num"].Value);
        //childNode = bulletNode.SelectSingleNode("FreezeReduction");
        //if (childNode == null)
        //{
        //    LogMgr.Log("FreezeReduction not found.");
        //    return false;
        //}
        //BulletSetting.FreezeBulletReduction.Speed = float.Parse(childNode.Attributes["speed"].Value);
        //BulletSetting.FreezeBulletReduction.Duration1 = float.Parse(childNode.Attributes["duration1"].Value);
        //BulletSetting.FreezeBulletReduction.Duration2 = float.Parse(childNode.Attributes["duration2"].Value);
        //BulletSetting.FreezeBulletReduction.Duration3 = float.Parse(childNode.Attributes["duration3"].Value);
        //childNode = bulletNode.SelectSingleNode("BulletRate");
        //if (childNode == null)
        //{
        //    LogMgr.Log("BulletRate not found.");
        //    return false;
        //}
        //int rateCount = childNode.ChildNodes.Count;
        //BulletSetting.BulletRate = new ushort[rateCount];
        //for (int i = 0; i < rateCount; ++i)
        //{
        //    BulletSetting.BulletRate[i] = ushort.Parse(childNode.ChildNodes[i].FirstChild.Value);
        //}

        ////SkillInfo
        //int skillCount = skillNode.ChildNodes.Count;
        //SkillSetting.SkillDataList = new SkillData[skillCount];
        //for (int i = 0; i < skillCount; ++i)
        //{
        //    SkillData sd = new SkillData();
        //    sd.ID = byte.Parse(skillNode.ChildNodes[i].Attributes["id"].Value);
        //    sd.CDTime = float.Parse(skillNode.ChildNodes[i].Attributes["cdtime"].Value);
        //    sd.Reduction.Speed = float.Parse(skillNode.ChildNodes[i].Attributes["speed"].Value);
        //    sd.Reduction.Duration1 = float.Parse(skillNode.ChildNodes[i].Attributes["duration1"].Value);
        //    sd.Reduction.Duration2 = float.Parse(skillNode.ChildNodes[i].Attributes["duration2"].Value);
        //    sd.Reduction.Duration3 = float.Parse(skillNode.ChildNodes[i].Attributes["duration3"].Value);
        //    if (SkillSetting.SkillDataList[sd.ID] != null)
        //    {
        //        LogMgr.Log("Exist the same skill id.");
        //        return false;
        //    }
        //    SkillSetting.SkillDataList[sd.ID] = sd;
        //}

        ////Other
        //childNode = otherNode.SelectSingleNode("MultipleEffect");
        //if (childNode == null)
        //{
        //    LogMgr.Log("MultipleEffect not found.");
        //    return false;
        //}
        //ExtraSetting.MultipleEffect = byte.Parse(childNode.FirstChild.Value);

        //childNode = otherNode.SelectSingleNode("DoubleHit");
        //if (childNode == null)
        //{
        //    LogMgr.Log("DoubleHit not found.");
        //    return false;
        //}
        //DoubleHit.IntervalTime = float.Parse(childNode.Attributes["interval_time"].Value);
        //DoubleHit.MaxTimes = ushort.Parse(childNode.Attributes["max_times"].Value);

        //childNode = otherNode.SelectSingleNode("RoomInfo");
        //if (childNode == null)
        //{
        //    LogMgr.Log("RoomInfo not found.");
        //    return false;
        //}
        //int roomCount = childNode.ChildNodes.Count;
        //ExtraSetting.RoomDataList = new RoomData[roomCount];
        //for (int i = 0; i < roomCount; ++i)
        //{
        //    RoomData rd = new RoomData();
        //    rd.RoomID = byte.Parse(childNode.ChildNodes[i].Attributes["id"].Value);
        //    rd.RoomRateIdx = byte.Parse(childNode.ChildNodes[i].FirstChild.Value);
        //    if (ExtraSetting.RoomDataList[rd.RoomID] != null)
        //    {
        //        LogMgr.Log("Exist the same room id.");
        //        return false;
        //    }
        //    ExtraSetting.RoomDataList[rd.RoomID] = rd;
        //}

        ////FishDeadTime
        //FishDeadTimeData ftd = new FishDeadTimeData();
        //ftd.TianZai_DouDong_Time = float.Parse(fishDeadNode.ChildNodes[0].FirstChild.Value);

        //ftd.TianZai_Stay_Time1 = float.Parse(fishDeadNode.ChildNodes[1].FirstChild.Value);
        //ftd.TianZai_Stay_Time2 = float.Parse(fishDeadNode.ChildNodes[2].FirstChild.Value);

        //ftd.TianZai_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[3].FirstChild.Value);
        //ftd.TianZai_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[4].FirstChild.Value);

        //ftd.Bullet_BingDong_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[5].FirstChild.Value);
        //ftd.Bullet_BingDong_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[6].FirstChild.Value);

        //ftd.BingDong_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[7].FirstChild.Value);
        //ftd.BingDong_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[8].FirstChild.Value);

        //ftd.ShanDian_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[9].FirstChild.Value);
        //ftd.ShanDian_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[10].FirstChild.Value);

        //ftd.LongJuanFeng_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[11].FirstChild.Value);
        //ftd.LongJuanFeng_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[12].FirstChild.Value);

        //ftd.JiGuang_Stay_Time = float.Parse(fishDeadNode.ChildNodes[13].FirstChild.Value);

        //ftd.JiGuang_Dead_Time1 = float.Parse(fishDeadNode.ChildNodes[14].FirstChild.Value);
        //ftd.JiGuang_Dead_Time2 = float.Parse(fishDeadNode.ChildNodes[15].FirstChild.Value);

        //ftd.ShandDian_Speed = float.Parse(fishDeadNode.ChildNodes[16].FirstChild.Value);
        //ftd.JiGuang_Speed = float.Parse(fishDeadNode.ChildNodes[17].FirstChild.Value);
        //ftd.JiGuang_BingDong_Speed = float.Parse(fishDeadNode.ChildNodes[18].FirstChild.Value);
        //ftd.TianZai_Speed = float.Parse(fishDeadNode.ChildNodes[19].FirstChild.Value);
        //ftd.BingDong_Speed = float.Parse(fishDeadNode.ChildNodes[20].FirstChild.Value);

        //FishSetting.FishDeadTime = ftd;
        ////end

        //ResManager.Instance.UnloadObject(obj);
        InitLogic.StartInit();
        SceneMain.Instance.StartInnerCoroutine(OnNewInit(null));

        Object obj = ResManager.Instance.LoadObject("FishConfig", "GlobalRes/ServerSetting/", ResType.GlobalRes, typeof(TextAsset));

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

        Object objErrorStr = ResManager.Instance.LoadObject("ErrorString", "GlobalRes/ServerSetting/", ResType.GlobalRes, typeof(TextAsset));

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

        InitLogic.StartInit();
        SceneMain.Instance.StartInnerCoroutine(FishConfig.Instance.LoadFishConfig(obj, objErrorStr));
        return(true);
    }