public void OnGfxHitTarget(int id, int impactId, int targetId, int hitCount)
        {
            UserInfo playerSelf = WorldSystem.Instance.GetPlayerSelf();

            if (id == WorldSystem.Instance.PlayerSelfId && playerSelf != null)
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (hitCount > 0)
                {
                    long lastHitTime = playerSelf.LastHitTime;
                    if (lastHitTime + 1500 > curTime)
                    {
                        playerSelf.MultiHitCount = playerSelf.MultiHitCount + hitCount;
                    }
                }
                WorldSystem.Instance.GetPlayerSelf().LastHitTime = curTime;
                GfxSystem.PublishGfxEvent("ge_hitcount", "ui", playerSelf.MultiHitCount);
            }
            CharacterInfo src    = WorldSystem.Instance.GetCharacterById(id);
            CharacterInfo target = WorldSystem.Instance.GetCharacterById(targetId);

            if (null != src && null != target)
            {
                ImpactSystem.Instance.SendImpactToCharacter(src, impactId, targetId);
            }
        }
Exemple #2
0
        private void TickUsers()
        {
            for (LinkedListNode <UserInfo> linkNode = m_UserMgr.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    LogSystem.Debug("UserAttrCalculate LevelChanged:{0} WeaponChanged:{1} BuffChanged:{2} EquipmentChanged:{3}", info.LevelChanged, info.GetShootStateInfo().WeaponChanged, info.GetSkillStateInfo().BuffChanged, info.GetEquipmentStateInfo().EquipmentChanged);
                    UserAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetShootStateInfo().WeaponChanged        = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                }
            }
            UserInfo player = WorldSystem.Instance.GetPlayerSelf();

            if (null != player && player.Hp <= 0)
            {
                if (player.DeadTime <= 0)
                {
                    GfxSystem.PublishGfxEvent("ge_show_relive", "ui", null);
                    player.DeadTime = TimeUtility.GetServerMilliseconds();
                }
            }
        }
Exemple #3
0
        private void InteractObject(int key_code, int what)
        {
            UserInfo myself = WorldSystem.Instance.GetPlayerSelf();

            if (myself != null && myself.IsDead())
            {
                GfxSystem.PublishGfxEvent("ge_move_camera_to_next_friend", "script", -1, -1);
            }
            WorldSystem.Instance.InteractObject();
        }
Exemple #4
0
 private void TickPve()
 {
     if (null != m_PlayerSelf)
     {
         long curTime = TimeUtility.GetLocalMilliseconds();
         if (m_PlayerSelf.LastHitTime + 1500 < curTime)
         {
             m_PlayerSelf.MultiHitCount = 0;
             GfxSystem.PublishGfxEvent("ge_hitcount", "ui", 0);
         }
     }
 }
Exemple #5
0
 public void SwitchObserver()
 {
     if (m_IsObserver)
     {
         m_IsFollowObserver = !m_IsFollowObserver;
         if (m_IsFollowObserver)
         {
             LinkedListNode <UserInfo> node = null;
             for (node = UserManager.Users.FirstValue; null != node; node = node.Next)
             {
                 if (node.Value == m_PlayerSelf)
                 {
                     continue;
                 }
                 if (node.Value.GetId() == m_FollowTargetId)
                 {
                     break;
                 }
             }
             if (null == node)
             {
                 for (node = UserManager.Users.FirstValue; null != node; node = node.Next)
                 {
                     if (node.Value == m_PlayerSelf)
                     {
                         continue;
                     }
                     else
                     {
                         break;
                     }
                 }
             }
             if (null != node)
             {
                 m_FollowTargetId = node.Value.GetId();
                 GfxSystem.PublishGfxEvent("ge_pvpSelfCombatInfo", "ui", node.Value.GetCombatStatisticInfo());
                 if (!node.Value.IsDead())
                 {
                     UserView view = EntityManager.Instance.GetUserViewById(m_FollowTargetId);
                     if (null != view)
                     {
                         GfxSystem.SendMessage("GfxGameRoot", "CameraFollow", view.Actor);
                     }
                 }
             }
         }
     }
 }
Exemple #6
0
 void UserManager_OnDamage(int receiver, int caster, bool /*isShootDamage*/ isOrdinaryDamage, bool isCritical, int hpDamage, int npDamage)
 {
     if (receiver == PlayerSelfId)
     {
         UserInfo charObj = GetPlayerSelf();
         if (null != charObj)
         {
             Vector3 pos = charObj.GetMovementStateInfo().GetPosition3D();
             if (hpDamage != 0)
             {
                 GfxSystem.PublishGfxEvent("ge_hero_blood", "ui", pos.X, pos.Y, pos.Z, hpDamage);
             }
         }
     }
 }
Exemple #7
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");
        }
Exemple #8
0
        void NpcManager_OnDamage(int receiver, int caster, bool /*isShootDamage*/ isOrdinaryDamage, bool isCritical, int hpDamage, int npDamage)
        {
            if (caster == PlayerSelfId)
            {
                CharacterInfo charObj = GetCharacterById(receiver);

                if (null != charObj)
                {
                    Vector3 pos = charObj.GetMovementStateInfo().GetPosition3D();
                    if (isOrdinaryDamage)
                    {
                        GfxSystem.PublishGfxEvent("ge_npc_odamage", "ui", pos.X, pos.Y, pos.Z, hpDamage);
                    }
                    if (isCritical)
                    {
                        GfxSystem.PublishGfxEvent("ge_npc_cdamage", "ui", pos.X, pos.Y, pos.Z, hpDamage);
                    }
                }
                GfxSystem.PublishGfxEvent("ge_small_monster_healthbar", "ui", charObj.Hp, charObj.GetActualProperty().HpMax, hpDamage);
            }
        }
Exemple #9
0
        private void OnLoadFinish()
        {
            if (WorldSystem.Instance.IsObserver)
            {
                UserInfo myself = WorldSystem.Instance.CreatePlayerSelf(0x0ffffffe, 1);
                if (null != myself)//观战客户端创建一个虚拟玩家(不关联view,血量不要为0,主要目的是为了适应客户端代码里对主角的判断)
                {
                    myself.SetLevel(16);
                    myself.SetHp(Operate_Type.OT_Absolute, 999999);
                }
                NotifyUserEnter();
            }

            if (WorldSystem.Instance.IsObserver)
            {
                DashFireMessage.Msg_CR_Observer build = new DashFireMessage.Msg_CR_Observer();
                NetworkSystem.Instance.SendMessage(build);
                LogSystem.Debug("send Msg_CR_Observer to roomserver");
            }
            else if (WorldSystem.Instance.IsPveScene())
            {
                //单机游戏逻辑启动
                WorldSystem.Instance.StartGame();
                NotifyUserEnter();
            }
            else
            {
                DashFireMessage.Msg_CRC_Create build = new DashFireMessage.Msg_CRC_Create();
                NetworkSystem.Instance.SendMessage(build);
                LogSystem.Debug("send Msg_CRC_Create to roomserver");
            }
            GfxSystem.GfxLog("SceneResource.OnLoadFinish");
            m_IsWaitSceneLoad = false;

            GfxSystem.PublishGfxEvent("ge_loading_finish", "ui");
        }
Exemple #10
0
        private void TickNpcs()
        {
            List <NpcInfo> deletes = new List <NpcInfo>();

            for (LinkedListNode <NpcInfo> linkNode = m_NpcMgr.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    NpcAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetShootStateInfo().WeaponChanged        = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                }

                // 约定npc的高度低于140时,直接判定npc死亡。
                if (140.0f > info.GetMovementStateInfo().GetPosition3D().Y)
                {
                    info.SetHp(Operate_Type.OT_Absolute, 0);
                }
                if (info.NeedDelete)
                {
                    deletes.Add(info);
                }
                else if (info.Hp <= 0)
                {
                    if (!info.LogicDead)
                    {
                        GfxSystem.PublishGfxEvent("ge_on_npc_dead", "story", info.GetUnitId());
                        info.LogicDead = true;
                    }
                    if (info.DeadTime <= 0)
                    {
                    }
                    else if (TimeUtility.GetServerMilliseconds() - info.DeadTime > info.ReleaseTime)
                    {
                        deletes.Add(info);
                    }
                }
                if (info.IsBorning && IsNpcBornOver(info))
                {
                    info.IsBorning = false;
                    info.SetAIEnable(true);
                    info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                }
            }
            if (deletes.Count > 0)
            {
                foreach (NpcInfo ni in deletes)
                {
                    CharacterView view = EntityManager.Instance.GetCharacterViewById(ni.GetId());
                    if (null != view)
                    {
                        GfxSystem.SendMessage(view.Actor, "OnDead", null);
                    }
                    EntityManager.Instance.DestroyNpcView(ni.GetId());
                    WorldSystem.Instance.DestroyCharacterById(ni.GetId());
                    return;
                }
            }
        }
Exemple #11
0
        public bool ChangeNextScene(int sceneId)
        {
            GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            /*==========================
             * 登录场景Loading的ID为6
             * 游戏结束时跳回该场景
             */
            if (sceneId == 6)
            {
                UserInfo user = GetPlayerSelf();
                if (null != user)
                {
                    EntityManager.Instance.DestroyUserView(user.GetId());
                    DestroyCharacterById(user.GetId());
                }
                if (null != m_CurScene)
                {
                    /*
                     * if (m_CurScene.ResId == sceneId) {
                     * return true;
                     * }
                     */
                    m_CurScene.Release();
                    m_CurScene = null;
                }
                Data_SceneConfig sceneConfig = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);
                GfxSystem.LoadScene(sceneConfig.m_ClientSceneFile, OnLoadFinish);
                return(true);
            }
            //==============================

            //GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            if (null != m_CurScene)
            {
                /*
                 * if (m_CurScene.ResId == sceneId) {
                 * return true;
                 * }
                 */
                m_CurScene.Release();
                m_CurScene = null;
            }
            m_CurScene = new SceneResource();
            if (null != m_CurScene)
            {
                m_CurScene.Init(sceneId);
                if (null != m_CurScene.SceneConfig)
                {
                    Data_SceneConfig scene_config = SceneConfigProvider.Instance.GetSceneConfigById(m_CurScene.ResId);
                    m_SpatialSystem.Init(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile, scene_config.m_ReachableSet);
                    m_SpatialSystem.LoadPatch(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile + ".patch");
                    m_SpatialSystem.LoadObstacle(FilePathDefine_Client.C_RootPath + scene_config.m_ObstacleFile, 1 / scene_config.m_TiledDataScale);

                    LogSystem.Debug("init SpatialSystem:{0}", FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile);
                    LogSystem.Debug("GameSystem.ChangeNextScene:{0}", m_CurScene.ResId);
                    if (sceneId == 6)
                    {
                        UserInfo user = GetPlayerSelf();
                        if (null != user)
                        {
                            EntityManager.Instance.DestroyUserView(user.GetId());
                            DestroyCharacterById(user.GetId());
                        }
                    }
                    return(true);
                }
            }


            return(false);
        }
Exemple #12
0
 private void OnLoadFinish()
 {
     GfxSystem.PublishGfxEvent("ge_loading_finish", "ui");
 }
Exemple #13
0
 private void UserAttack(UserInfo user, float x, float y, float z)
 {
     GfxSystem.PublishGfxEvent("Ai_InputAttackCmd", "Input", user.GetId(), x, y, z);
 }
Exemple #14
0
        public void HighlightPrompt(int id, params object[] args)
        {
            var str = StrDictionaryProvider.Instance.Format(id, args);

            GfxSystem.PublishGfxEvent("ge_cdbar", "ui", str);
        }
Exemple #15
0
 private void UserSkill(UserInfo user)
 {
     GfxSystem.PublishGfxEvent("Ai_InputSkillCmd", "Input", user.GetId());
 }
Exemple #16
0
        public bool InteractObject()
        {
            if (m_IsObserver)
            {
                if (m_IsFollowObserver)
                {
                    LinkedListNode <UserInfo> node = null;
                    for (node = UserManager.Users.FirstValue; null != node; node = node.Next)
                    {
                        if (node.Value == m_PlayerSelf)
                        {
                            continue;
                        }
                        if (node.Value.GetId() == m_FollowTargetId)
                        {
                            node = node.Next;
                            break;
                        }
                    }
                    if (null == node)
                    {
                        for (node = UserManager.Users.FirstValue; null != node; node = node.Next)
                        {
                            if (node.Value == m_PlayerSelf)
                            {
                                continue;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if (null != node)
                    {
                        m_FollowTargetId = node.Value.GetId();
                        GfxSystem.PublishGfxEvent("ge_pvpSelfCombatInfo", "ui", node.Value.GetCombatStatisticInfo());

                        /*if (!node.Value.IsDead())
                         * GfxSystemExt.GfxSystem.Instance.MainCamera.FollowCharacter(m_FollowTargetId, GetCharacterPosition);*/
                    }
                }
                return(true);
            }
            bool sendMsg = false;

            if (null != m_PlayerSelf)
            {
                int initiator = m_PlayerSelf.GetId();
                int receiver  = 0;

                //释放控制为低优先级操作
                if (!sendMsg && null != m_PlayerSelf.ControlledObject)
                {
                    receiver = m_PlayerSelf.ControlledObject.GetId();
                    sendMsg  = true;
                }

                if (sendMsg)
                {
                    Msg_CRC_InteractObject builder = new Msg_CRC_InteractObject();
                    //builder.InitiatorId = initiator;
                    builder.receiver_id = receiver;
                    NetworkSystem.Instance.SendMessage(builder);
                }
            }
            return(sendMsg);
        }
Exemple #17
0
        private void TouchHandle(int what, GestureArgs e)
        {
            UserInfo playerself = WorldSystem.Instance.GetPlayerSelf();

            if (null == playerself || null == e)
            {
                return;
            }
            if ((int)TouchEvent.Cesture == what)
            {
                string ename = e.name;
                if (GestureEvent.OnSingleTap.ToString() == ename)
                {
                    if (EnableMoveInput)
                    {
                        if (WorldSystem.Instance.IsPveScene())
                        {
                            if (e.selectedObjID < 0)
                            {
                                FindPath(playerself, new Vector3(e.airWelGamePosX, e.airWelGamePosY, e.airWelGamePosZ), e.towards);
                            }
                            else
                            {
                                Combat(playerself, e.selectedObjID, e.attackRange);
                            }
                            m_lastSelectObjId = e.selectedObjID;
                            ///
                            GfxSystem.PublishGfxEvent("Op_InputEffect", "Input", GestureEvent.OnSingleTap, e.airWelGamePosX, e.airWelGamePosY, e.airWelGamePosZ, e.selectedObjID < 0 ? false : true, true);
                        }
                        else
                        {
                            Vector3 world_pos = new Vector3(GfxSystem.GetTouchRayPointX(), GfxSystem.GetTouchRayPointY(), GfxSystem.GetTouchRayPointZ());
                            NetworkSystem.Instance.SyncPlayerFindPath(world_pos);
                        }
                    }
                }
                else if (GestureEvent.OnFingerMove.ToString() == ename)
                {
                    if (EnableMoveInput)
                    {
                        if (TouchType.Attack == e.moveType)
                        {
                            UpdateTowards(playerself, e.towards);
                        }
                    }
                }
                else if (GestureEvent.OnSkillStart.ToString() == ename)
                {
                    if (null != playerself)
                    {
                        UserAiStateInfo info = playerself.GetAiStateInfo();
                        if ((int)AiStateId.Move == info.CurState)
                        {
                            StopFindPath(playerself, info);
                        }
                    }
                }
                else if (GestureEvent.OnEasyGesture.ToString() == ename)
                {
                    Vector3 targetpos = new Vector3(e.startGamePosX, e.startGamePosY, e.startGamePosZ);
                    if (Vector3.Zero != targetpos)
                    {
                        PushSkill(playerself, targetpos, e.attackRange);
                    }
                }

                //LogSystem.Debug("userid:{0}, input event:{1}", playerself.GetId(), e.name);
            }
        }
Exemple #18
0
 private void OnSkillPursuit(UserInfo user)
 {
     GfxSystem.PublishGfxEvent("Ai_InputSkillPursuitCmd", "Input", user.GetId());
 }