예제 #1
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();
        });
    }
예제 #2
0
    //加载玩家
    private void LoadPlayer(MapCfg mapData)
    {
        GameObject player = resSvc.LoadPrefab(PathDefine.AssassinBattlePlayerPrefab);

        player.transform.position         = mapData.playerBornPos;
        player.transform.localEulerAngles = mapData.playerBornRote;
        player.transform.localScale       = Vector3.one;

        PlayerController playerCtrl = player.GetComponent <PlayerController>();

        playerCtrl.Init();

        PlayerData  pd    = GameRoot.instance.playerData;
        BattleProps props = new BattleProps()
        {
            hp       = pd.hp,
            ad       = pd.ad,
            ap       = pd.ap,
            addef    = pd.addef,
            apdef    = pd.apdef,
            dodge    = pd.dodge,
            pierce   = pd.pierce,
            critical = pd.critical,
        };

        //生成角色赋予 状态管理器
        entityPlayer = new EntityPlayer();
        entityPlayer.SetBattleProps(props);
        entityPlayer.SetBattleMgr(this);         //添加战斗管理器
        entityPlayer.SetStateMgr(this.stateMgr); //添加状态管理器
        entityPlayer.SetSkillMgr(this.skillMgr); //添加技能管理器
        entityPlayer.SetController(playerCtrl);  //添加角色控制器
        entityPlayer.Idle();
    }
예제 #3
0
    private void LoadPlayer()
    {
        PlayerEntityData playerEntityData = new PlayerEntityData(GameEntry.Entity.GenerateSerialId(), PathDefine.AssissnBattlePlayerId, ActorType.Player)
        {
            Name       = "BattlePlayer",
            Position   = m_MapCfg.playerBornPos,
            Rotation   = Quaternion.Euler(m_MapCfg.playerBornRote),
            LocalScale = Vector3.one
        };

        GameEntry.Entity.ShowMyPlayer(playerEntityData);
        PlayerData  pd    = PECommon.PlayerData;
        BattleProps props = new BattleProps {
            hp       = pd.Hp,
            ad       = pd.Ad,
            ap       = pd.Ap,
            addef    = pd.Addef,
            apdef    = pd.Apdef,
            dodge    = pd.Dodge,
            pierce   = pd.Pierce,
            critical = pd.Critical
        };

        EntitySelfPlayer = new EntityPlayer {
            BattleMgr = this,
            StateMgr  = m_StateMgr,
            SkillMgr  = m_SkillMgr
        };
        EntitySelfPlayer.Name = "AssassinBattle";
        EntitySelfPlayer.SetBattleProps(props);
        EntitySelfPlayer.Idle();
    }
예제 #4
0
    public void Init(int chapterId, Action callback = null)
    {
        CommonTools.Log("BattleManager Init.....");

        resSvc   = ResSvc.Instance;
        audioSvc = AudioSvc.Instance;

        battleStateMgr = gameObject.AddComponent <BattleStateManager>();
        battleStateMgr.Init();

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

        //加载战场地图
        mapCfg = resSvc.GetMapCfgData(chapterId);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            //初始化地图数据
            GameObject objMap = GameObject.FindGameObjectWithTag("MapRoot");
            mapMgr            = objMap.GetComponent <MapManager>();
            mapMgr.Init(this);
            objMap.transform.localPosition = Vector3.zero;
            objMap.transform.localScale    = Vector3.one;

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

            LoadPlayer(mapCfg);
            entityPlayer.Idle();

            audioSvc.PlayBGM(Constants.cFightBGM);
            BattleSys.Instance.SetPlayerControlWndState();

            ActiveCurrentBatchMonsters();

            if (callback != null)
            {
                callback();
            }
        });
    }
예제 #5
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");
    }
예제 #6
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();
            }
        });
    }
예제 #7
0
    void LoadPlayer(int characterId, MapConfig mapCfg)
    {
        var characterCfg = ConfigSvc.Ins.GetCharacterCfg(characterId);
        var player       = ObjSvc.Ins.InsObj(PathDefine.PlayerDir + characterCfg.PrefabPath);

        var ctrl = player.GetComponent <PlayerController>();

        selfPlayer = new EntityPlayer();
        selfPlayer.Init(this, stateMgr, skillMgr, ctrl, characterCfg.Attribute, mapCfg.PlayerBornPos, mapCfg.PlayerBornDir);
        selfPlayer.SetupSkill(new List <int> {
            201, 202, 203, 204, 205, 206
        });
        selfPlayer.Idle(mapCfg.PlayerBornDir);
    }
예제 #8
0
    public void Init(int mapId, Action action = null)
    {
        resSvc   = ResSvc.instance;
        audioSvc = AudioSvc.instance;
        //初始化管理器
        stateMg = gameObject.AddComponent <StateManager>();
        stateMg.Init();
        skillMg = gameObject.AddComponent <SkillManager>();
        skillMg.Init();

        //加载地图
        mapCfg = resSvc.GetMapCfgData(mapId);
        resSvc.AsyncLoadScene(mapCfg.sceneName, () =>
        {
            //初始化地图
            GameObject map = GameObject.FindWithTag("MapRoot");
            mapMg          = map.GetComponent <MapManager>();
            //在地图管理器里面注入战斗管理器
            mapMg.Init(this);

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

            LoadPlayer(mapCfg);
            entitySelfPlayer.Idle();
            //激活第一批怪物
            ActiveCurrentBatchMonster();

            audioSvc.PlayBGMusic(Constants.BGFuben);
            //地图加载完成以后开始计时
            if (action != null)
            {
                action();
            }
        });
    }
예제 #9
0
    public void SetSelfPlayerMoveDir(Vector2 dir)
    {
        if (entitySelfPlayer.canControl == false)
        {
            return;
        }

        if (dir == Vector2.zero)
        {
            entitySelfPlayer.Idle();
        }
        else
        {
            entitySelfPlayer.Move();
        }
        entitySelfPlayer.SetDir(dir);
    }
예제 #10
0
    public void SetSelfPlayerMoveDir(Vector2 dir)
    {
        if (entityPlayer.currentAnimState == AniState.Attack)
        {
            return;
        }


        if (dir == Vector2.zero)
        {
            entityPlayer.Idle();
        }
        else
        {
            entityPlayer.SetDir(dir);
            entityPlayer.Move();
        }
    }
예제 #11
0
    private void LoadPlayer(MapCfg mapData)
    {
        GameObject player = resSvc.LoadPrefab(PathDefine.AssissnBattlePlayerPrefab);

        player.transform.position         = mapData.playerBornPos;
        player.transform.localEulerAngles = mapData.playerBornRote;
        player.transform.localScale       = Vector3.one;

        entitySelfPlayer = new EntityPlayer()
        {
            battleMgr = this,
            stateMgr  = stateMgr,
            skillMgr  = skillMgr
        };
        PlayerController playerCtrl = player.GetComponent <PlayerController>();

        playerCtrl.Init();
        entitySelfPlayer.controller = playerCtrl;
        entitySelfPlayer.Idle();
    }
예제 #12
0
 public void SetMoveDir(Vector2 dir)
 {
     if (entityPlayer.canControl == false)
     {
         return;
     }
     //playerController.Dir = dir;
     if (entityPlayer.currentAniState == AniState.Idle || entityPlayer.currentAniState == AniState.Move)
     {
         if (dir == Vector2.zero)
         {
             entityPlayer.SetDir(dir);
             entityPlayer.Idle();
         }
         else
         {
             entityPlayer.SetDir(dir);
             entityPlayer.Move();
         }
     }
 }
예제 #13
0
    public void SetMoveDir(Vector2 dir)
    {
        if (entityPlayer == null || !entityPlayer.CanControl)
        {
            return;
        }
        if (entityPlayer.curState != AnimState.Idle && entityPlayer.curState != AnimState.Move)
        {
            return;
        }

        if (dir == Vector2.zero)
        {
            entityPlayer.Idle();
            entityPlayer.SetDir(Vector2.zero);
        }
        else
        {
            entityPlayer.Move();
            entityPlayer.SetDir(dir);
        }
    }
예제 #14
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);
        });
    }
예제 #15
0
    private void LoadPlayer(MapCfg mapCfg)
    {
        GameObject player = resSev.LoadGoPrefab(PathDefine.AssissBattlePlayerPrefab, true, mapCfg.playerBornPos, Quaternion.Euler(mapCfg.playerBornRote));

        player.transform.localScale = Vector3.one;

        entityPlayer = new EntityPlayer();
        PlayerController playerCtrl = player.GetComponent <PlayerController>();

        playerCtrl.BattleInit();

        PlayerData  pd    = GameRoot.Instance.PlayerData;
        BattleProps props = new BattleProps(pd.critical, pd.pierce, pd.dodge, pd.apdef, pd.addef, pd.ap, pd.ad, pd.hp);

        entityPlayer.SetBattleMgr(this);
        entityPlayer.SetLv(pd.lv);
        entityPlayer.SetController(playerCtrl);
        entityPlayer.SetStateMgr(stateMgr);
        entityPlayer.SetSkillMgr(skillMgr);
        entityPlayer.SetBattlePorps(props);

        entityPlayer.Idle();
    }