Beispiel #1
0
    public void Init(int mapId)
    {
        resSev   = ResSev.Instance;
        audioSev = AudioSev.Instance;

        stateMgr = gameObject.AddComponent <StateMgr>();
        skillMgr = gameObject.AddComponent <SkillMgr>();

        stateMgr.Init();
        skillMgr.Init();

        mapCfg = resSev.GetMapCfgData(mapId);
        resSev.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init(this);

            map.transform.localPosition = Vector3.zero;
            map.transform.localScale    = Vector3.one;

            Camera.main.transform.position         = mapCfg.mainCamPos;
            Camera.main.transform.localEulerAngles = mapCfg.mainCamRote;

            LoadPlayer(mapCfg);

            audioSev.PlayBGM(Constans.HuangYeBGM);

            ActiveCurrentBatchMonsters();
        });
    }
Beispiel #2
0
    public void Init(int mapId)
    {
        resSvc   = ResSvc.instance;
        audioSvc = AudioSvc.instance;
        timerSvc = TimerSvc.instance;

        stateMgr = this.gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = this.gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();


        mapCfg = resSvc.GetMapCfgData(mapId);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            GameObject mapObj = GameObject.FindWithTag("MapRoot");
            mapMgr            = mapObj.GetComponent <MapMgr>();
            mapMgr.Init();
            audioSvc.PlayBgMusic(Constants.BGHuangye);

            mapObj.transform.position   = Vector3.zero;
            mapObj.transform.localScale = Vector3.one;

            Camera.main.transform.position         = mapCfg.mainCamPos;
            Camera.main.transform.localEulerAngles = mapCfg.mainCamRote;

            LoadPlayer(mapCfg);

            SetActiveCurrentBatchMonsters();
        });
    }
Beispiel #3
0
    public void Init(int mapID)
    {
        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        //初始化各个管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();


        //加载战场地图
        MapCfgs mapData = resSvc.GetMapCfgData(mapID);

        resSvc.AsyncLoadScene(mapData.sceneName, () =>
        {
            //初始化地图数据
            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init();

            //初始化地图位置和摄像机位置
            map.transform.localPosition            = Vector3.zero;
            map.transform.localScale               = Vector3.zero;
            Camera.main.transform.position         = mapData.mainCamPos;
            Camera.main.transform.localEulerAngles = mapData.mainCamRote;


            LoadPlayer(mapData);
            audioSvc.PlayBGMusic(Constants.BGHuangYe);
            entityPlayer.Idle();
        });
    }
    public void Init(int mapid, Action cb = null)
    {
        TriggerCheck = true;
        IsPauseGame  = false;
        //初始化各管理器
        m_StateMgr.Init();
        m_SkillMgr.Init();

        //加载战场地图
        m_MapCfg = GameEntry.Res.GetMapCfg(mapid);
        //初始化地图数据
        //GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
        m_MapMgr = GameObject.FindObjectOfType <MapMgr>();
        m_MapMgr.Init(this);
        monsterDic.Clear();

        Camera.main.transform.position         = m_MapCfg.mainCamPos;
        Camera.main.transform.localEulerAngles = m_MapCfg.mainCamRote;

        LoadPlayer();


        //GameEntry.Sound.PlayUISound(Constants.BGHuangYe);
        if (cb != null)
        {
            cb();
        }
    }
Beispiel #5
0
    public void Init(int mapID)
    {
        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        //初始化各个管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();

        MapCfg mapData = resSvc.GetMapCfgData(mapID);

        resSvc.AsyncLoadScene(mapData.sceneName, () =>
        {
            audioSvc.PlayBGMusic(Constants.BGHuangYe);

            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init();

            Camera.main.transform.position    = mapData.mainCamPos;
            Camera.main.transform.eulerAngles = mapData.mainCamRote;

            LoadPlayer(mapData);
        });
    }
Beispiel #6
0
    public void Init(int mapId)
    {
        mResSvc   = ResSvc.Instance;
        mAudioSvc = AudioSvc.Instance;
        mCfgSvc   = CfgSvc.Instance;

        mSkillMgr = gameObject.AddComponent <SkillMgr>();
        mSkillMgr.Init();
        mStateMgr = gameObject.AddComponent <StateMgr>();
        mStateMgr.Init();


        mAudioSvc.PlayBgAudio(Constant.Audio_BgHuangYe);

        CfgMap cfg = mCfgSvc.GetCfgMap(mapId);

        if (cfg == null)
        {
            Debug.LogError("╪сть╣ьм╪й╖╟э:  " + mapId);
            return;
        }

        mResSvc.AsyncLoadScene(cfg.sceneName, () =>
        {
            GameObject mapGo = GameObject.FindGameObjectWithTag("MapRoot");

            mMapMgr = mapGo.AddComponent <MapMgr>();
            mMapMgr.Init();
            InitScene(cfg);
        });
    }
Beispiel #7
0
    public void Init(int fbid, Action cb)
    {
        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        //初始化各状态管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();

        //加载战斗的地图
        mapCfg = resSvc.GetMapCfg(fbid);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            //地图初始化
            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init(this);


            audioSvc.PlayBGMusic(Constant.BGOrge, true);

            map.transform.localPosition = Vector3.zero;
            map.transform.localScale    = Vector3.one;

            Camera.main.transform.position         = mapCfg.mainCamPos;
            Camera.main.transform.localEulerAngles = mapCfg.mainCamRote;

            LoadPlayer(mapCfg);
            BattleSys.Instance.SetPlayerCtrlWindow(true);

            //激活第一批怪物
            ActiveCurrentBatchMonster();

            if (cb != null)
            {
                cb();
            }
        });

        PECommon.Log("BattleMgr Init Done");
    }
Beispiel #8
0
    public void Init(int mapid, Action cb = null)
    {
        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        // 初始化各个管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();

        // 加载战场地图
        mapCfg = resSvc.GetMapCfgData(mapid);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () => {
            // 初始化地图数据
            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init(this);

            map.transform.localPosition = Vector3.zero;
            map.transform.localScale    = Vector3.one;

            Camera.main.transform.position         = mapCfg.mainCameraPos;
            Camera.main.transform.localEulerAngles = mapCfg.mainCameraRot;

            LoadPlayer(mapCfg);
            entityPlayer.Idle();

            // 激活当前批次的怪物
            ActiveCurrentBatchMonsters();

            if (cb != null)
            {
                cb();
            }

            audioSvc.PlayBGAudio(Constants.BGHuangYe);
        });

        Common.Log("BattleMgr init done");
    }
Beispiel #9
0
    public void Init(int mapId, Action cb = null)
    {
        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        // 初始化各管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();
        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();

        // 加载战场地图
        mapCfg = resSvc.GetMapCfg(mapId);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            // 初始化地图数据
            GameObject map = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr         = map.GetComponent <MapMgr>();
            mapMgr.Init(this);

            map.transform.localPosition            = Vector3.zero;
            map.transform.localScale               = Vector3.one;
            Camera.main.transform.localPosition    = mapCfg.mainCamPos;
            Camera.main.transform.localEulerAngles = mapCfg.mainCamRote;

            LoadPlayer(mapCfg);
            entitySelfPlayer.Idle();

            // 激活第一批次怪物
            ActiveCurrentBatchMonsters();

            audioSvc.PlayBGMusic(Constants.BGHuangYe);

            if (cb != null)
            {
                cb();
            }
        });
    }
Beispiel #10
0
    public void Init(int characterID, int mapId)
    {
        // TODO: 单个实体独立状态管理
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();

        skillMgr = gameObject.AddComponent <SkillMgr>();
        skillMgr.Init();

        mapCfg = ConfigSvc.Ins.GetMapCfg(mapId);
        AsyncLoadScene(mapCfg.SceneName, () =>
        {
            var go = GameObject.FindGameObjectWithTag("MapRoot");
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;

            mapMgr = go.GetComponent <MapMgr>();
            mapMgr.Init(this);

            LoadPlayer(characterID, mapCfg);
            selfPlayer.Idle(mapCfg.PlayerBornDir);
        });
    }
Beispiel #11
0
    /// <summary>
    /// 可以优化代码结构。
    /// </summary>
    /// <param name="battlePropDic"></param>
    public void Init(Dictionary <int, BattleProp> battlePropDic)
    {
        resSvc   = ResSvc.Instance;
        timerSvc = TimerSvc.Instance;

        //初始化各管理器
        stateMgr = gameObject.AddComponent <StateMgr>();
        stateMgr.Init();

        bulletParent    = GameObject.Find("Temp/Bullets").transform;
        effectParent    = GameObject.Find("Temp/Effects").transform;
        bulletPool      = gameObject.AddComponent <ObjectPool>();
        laserBulletPool = gameObject.AddComponent <ObjectPool>();
        hitEffectPool   = gameObject.AddComponent <ObjectPool>();
        fireEffectPool  = gameObject.AddComponent <ObjectPool>();
        shellEffectPool = gameObject.AddComponent <ObjectPool>();

        //找到自己的战场参数
        foreach (var item in battlePropDic)
        {
            RoleType       roleType       = (RoleType)item.Key;
            ControllerBase controllerBase = null;
            GameObject     playerGO       = null;
            if (roleType == BattleSys.Instance.GetCurrentRoleType())
            {
                playerGO = resSvc.LoadPrefab(PathDefine.PlayerPath);
                #region 设置摄像机以及添加玩家控制器
                switch (roleType)
                {
                case RoleType.Red:
                    Camera.main.transform.position         = new Vector3(0, 1f, -30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;

                case RoleType.Blue:
                    Camera.main.transform.position         = new Vector3(0, 1f, 30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 180, 0);
                    break;

                case RoleType.Yellow:
                    Camera.main.transform.position         = new Vector3(-30, 1, 30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 180, 0);
                    break;

                case RoleType.Green:
                    Camera.main.transform.position         = new Vector3(30, 1, 30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 180, 0);
                    break;

                case RoleType.Purple:
                    Camera.main.transform.position         = new Vector3(-30, 1, -30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;

                case RoleType.Black:
                    Camera.main.transform.position         = new Vector3(30, 1, -30f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;

                case RoleType.Orange:
                    Camera.main.transform.position         = new Vector3(22, 1, -5f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;

                case RoleType.White:
                    Camera.main.transform.position         = new Vector3(-25, 1, -5f);
                    Camera.main.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;
                }
                playerController = playerGO.AddComponent <PlayerController>();
                #endregion
                playerController.SetRoleType(roleType);
                controllerDic.Add(roleType, playerController);


                #region 设置实体数据
                playerEntity = new PlayerEntity(this, stateMgr);

                playerEntity.SetCtrl(playerController);
                playerEntity.SetBattleProps(battlePropDic.TryGet(item.Key));
                //考虑了扩展游戏到AI
                playerEntity.SetRoleType(roleType);
                playerEntity.Born();
                #endregion

                controllerBase = playerController;
            }
            else
            {
                //设置远程角色
                playerGO = resSvc.LoadPrefab(PathDefine.PlayerPath);
                if (playerGO.GetComponent <CharacterController>() != null)
                {
                    Destroy(playerGO.GetComponent <CharacterController>());
                }
                RemoteController remoteController = playerGO.AddComponent <RemoteController>();
                remoteController.SetRoleType(roleType);
                controllerDic.Add(roleType, remoteController);


                #region 设置实体数据
                RemoteEntity remoteEntity = new RemoteEntity(this, stateMgr);

                remoteEntity.SetCtrl(remoteController);
                remoteEntity.SetBattleProps(battlePropDic.TryGet(item.Key));
                //考虑了扩展游戏到AI
                //remoteEntity.SetRoleType(roleType);
                remoteEntity.Born();
                #endregion

                controllerBase = remoteController;
            }

            switch (roleType)
            {
            case RoleType.Red:
                playerGO.transform.position         = new Vector3(0, 0f, -30f);;
                playerGO.transform.localEulerAngles = new Vector3(0, 0, 0);
                playerGO.name = "Red";
                break;

            case RoleType.Blue:
                playerGO.transform.position         = new Vector3(0, 0, 30f);
                playerGO.transform.localEulerAngles = new Vector3(0, 180, 0);
                playerGO.name = "Blue";
                break;

            case RoleType.Yellow:
                playerGO.transform.position         = new Vector3(-30, 0, 30f);
                playerGO.transform.localEulerAngles = new Vector3(0, 180, 0);
                playerGO.name = "Yellow";
                break;

            case RoleType.Green:
                playerGO.transform.position         = new Vector3(30, 0, 30f);
                playerGO.transform.localEulerAngles = new Vector3(0, 180, 0);
                playerGO.name = "Green";
                break;

            case RoleType.Purple:
                playerGO.transform.position         = new Vector3(-30, 0, -30f);
                playerGO.transform.localEulerAngles = new Vector3(0, 0, 0);
                playerGO.name = "Purple";
                break;

            case RoleType.Black:
                playerGO.transform.position         = new Vector3(30, 0, -30f);
                playerGO.transform.localEulerAngles = new Vector3(0, 0, 0);
                playerGO.name = "Black";
                break;

            case RoleType.Orange:
                playerGO.transform.position         = new Vector3(22, 0, -5f);
                playerGO.transform.localEulerAngles = new Vector3(0, 0, 0);
                playerGO.name = "Orange";
                break;

            case RoleType.White:
                playerGO.transform.position         = new Vector3(-25, 0, -5f);
                playerGO.transform.localEulerAngles = new Vector3(0, 0, 0);
                playerGO.name = "White";
                break;
            }

            #region 添加枪支
            Transform  gunTrans = controllerBase.transform.Find(PathDefine.gunTransName).GetComponent <Transform>();
            GameObject go       = null;
            switch (battlePropDic.TryGet(item.Key).weapenType)
            {
            case WeapenType.Rifle:
                go      = resSvc.LoadPrefab(PathDefine.RiflePrefab);
                go.name = "Rifle";
                go.transform.SetParent(gunTrans);
                go.transform.localPosition    = new Vector3(0, 0, -0.1f);
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.localScale       = Vector3.one;
                break;

            case WeapenType.Sniper:
                go      = resSvc.LoadPrefab(PathDefine.SniperPrefab);
                go.name = "Sniper";
                LineRenderer line = go.AddComponent <LineRenderer>();
                line.material   = Resources.Load <Material>("ResMaterials/Gun/Lin");
                line.startWidth = 0.3f;
                line.endWidth   = 0.3f;
                line.enabled    = false;
                lineRendererDic.Add(roleType, line);
                go.transform.SetParent(gunTrans);
                go.transform.localPosition = new Vector3(0, 0, -0.1f);
                go.transform.localRotation = Quaternion.Euler(Vector3.zero);
                go.transform.localScale    = new Vector3(0.7f, 0.7f, 0.7f);
                break;
            }
            #endregion
        }

        //设置我的武器
        playerEntity.SetPlayerWeapen();

        PECommon.Log("Init BattleMgr Done.");
    }