예제 #1
0
        public void StartGame()
        {
            UserInfo user = GetPlayerSelf();

            if (null != user)
            {
                EntityManager.Instance.DestroyUserView(user.GetId());
                DestroyCharacterById(user.GetId());
            }
            user = CreatePlayerSelf(1, NetworkSystem.Instance.HeroId);
            user.SetCampId(NetworkSystem.Instance.CampId);
            Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit;

            if (null != unit)
            {
                user.GetMovementStateInfo().SetPosition(unit.m_Pos);
                user.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                user.SetHp(Operate_Type.OT_Absolute, user.GetActualProperty().HpMax);
            }
            EntityManager.Instance.CreatePlayerSelfView(1);
            UserView view = EntityManager.Instance.GetUserViewById(1);

            if (null != view)
            {
                view.Visible = true;
            }

            foreach (Data_Unit npcUnit in m_CurScene.StaticData.m_UnitMgr.GetData().Values)
            {
                if (npcUnit.m_IsEnable)
                {
                    NpcInfo npc = m_NpcMgr.GetNpcInfoByUnitId(npcUnit.GetId());
                    if (null == npc)
                    {
                        npc = m_NpcMgr.AddNpc(npcUnit);
                    }
                    if (null != npc)
                    {
                        EntityManager.Instance.CreateNpcView(npc.GetId());
                    }
                }
            }
            GfxSystem.PublishGfxEvent("ge_on_game_start", "story");
            LogSystem.Debug("start game");
        }
예제 #2
0
        public void ChangeHero()
        {
            UserInfo user = GetPlayerSelf();

            if (null != user)
            {
                Vector3 pos  = user.GetMovementStateInfo().GetPosition3D();
                float   dir  = user.GetMovementStateInfo().GetFaceDir();
                int     hp   = user.Hp;
                int     rage = user.Rage;

                EntityManager.Instance.DestroyUserView(user.GetId());
                DestroyCharacterById(user.GetId());

                NetworkSystem.Instance.HeroId = (NetworkSystem.Instance.HeroId + 1) % 4;
                if (NetworkSystem.Instance.HeroId == 0)
                {
                    NetworkSystem.Instance.HeroId = 1;
                }

                user = CreatePlayerSelf(1, NetworkSystem.Instance.HeroId);
                user.SetCampId(NetworkSystem.Instance.CampId);

                /*Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit;
                 * if (null != unit) {
                 * user.GetMovementStateInfo().SetPosition(unit.m_Pos);
                 * user.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                 * user.SetHp(Operate_Type.OT_Absolute, 1000);
                 * }*/
                user.GetMovementStateInfo().SetPosition(pos);
                user.GetMovementStateInfo().SetFaceDir(dir);
                user.SetHp(Operate_Type.OT_Absolute, hp);
                user.SetRage(Operate_Type.OT_Absolute, rage);
                EntityManager.Instance.CreatePlayerSelfView(1);
                UserView view = EntityManager.Instance.GetUserViewById(1);
                if (null != view)
                {
                    view.Visible = true;
                }
            }
        }