Exemple #1
0
    void onClick_Btnhead_Btn(GameObject caster)
    {
        BShowEnemyList = !BShowEnemyList;
        Client.IEntity entity = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();
        if (entity != null)
        {
            if (entity.GetEntityType() == EntityType.EntityType_Player)
            {
                DataManager.Instance.Sender.RequestPlayerInfoForOprate(entity.GetID(), PlayerOpreatePanel.ViewType.Normal);
            }
            else if (entity.GetEntityType() == EntityType.EntityTYpe_Robot)
            {
                ShowRobotOpreate((uint)entity.GetID(), (uint)entity.GetProp((int)RobotProp.Job),
                                 (uint)entity.GetProp((int)CreatureProp.Level), entity.GetName(), (uint)entity.GetProp((int)RobotProp.Sex));
            }
            else
            {
            }
        }

        if (BShowEnemyList)
        {
            if (entity != null)
            {
                NetService.Instance.Send(new GameCmd.stEnmityDataUserCmd_CS()
                {
                    npcid = entity.GetID()
                });
            }
        }
        else
        {
            m_transHateList.gameObject.SetActive(false);
        }
    }
Exemple #2
0
    void UpdateTargetHp(Client.IEntity entity)
    {
        if (entity == null)
        {
            return;
        }
        int   currHp = entity.GetProp((int)CreatureProp.Hp);
        float hp     = currHp / (float)entity.GetProp((int)CreatureProp.MaxHp);

        if (m_spriteTargetHp == null)
        {
            return;
        }
        m_spriteTargetHp.fillAmount = hp;

        if (m_labelHP != null)
        {
            if (entity.GetEntityType() == EntityType.EntityType_NPC)
            {
                Client.INPC npc = (Client.INPC)entity;
                if (npc.IsMonster())
                {
                    m_labelHP.alpha = 1f;
                    m_labelHP.gameObject.SetActive(true);
                    m_labelHP.text = currHp.ToString();
                    return;
                }
            }
            m_labelHP.alpha = 0f;
            m_labelHP.gameObject.SetActive(false);
        }
    }
Exemple #3
0
    void OnEvent(int nEventid, object param)
    {
        if (nEventid == (int)Client.GameEventID.ENTITYSYSTEM_CREATEENTITY)
        {
            Client.stCreateEntity createEntity = (Client.stCreateEntity)param;

            Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
            if (es != null)
            {
                Client.IEntity e = es.FindEntity(createEntity.uid);
                if (e == null)
                {
                    return;
                }
                if (e.GetEntityType() != Client.EntityType.EntityType_Box)
                {
                    return;
                }

                if (!m_dicBoxTime.ContainsKey(createEntity.uid))
                {
                    m_dicBoxTime.Add(createEntity.uid, createEntity.boxTime);
                }
                else
                {
                    Engine.Utility.Log.Error("重复添加box{0}", createEntity.uid);
                }
            }
        }
        else if (nEventid == (int)Client.GameEventID.ENTITYSYSTEM_REMOVEENTITY)
        {
            Client.stRemoveEntity removeEntiy = (Client.stRemoveEntity)param;
            Client.IEntitySystem  es          = Client.ClientGlobal.Instance().GetEntitySystem();
            if (es != null)
            {
                Client.IEntity e = es.FindEntity(removeEntiy.uid);
                if (e == null)
                {
                    return;
                }
                if (e.GetEntityType() != Client.EntityType.EntityType_Box)
                {
                    return;
                }
                if (m_dicBoxTime.ContainsKey(removeEntiy.uid))
                {
                    m_dicBoxTime.Remove(removeEntiy.uid);
                }
            }
        }
    }
Exemple #4
0
 public static bool IsNeedHpSlider(Client.IEntity entity)
 {
     if (entity.GetEntityType() == EntityType.EntityType_NPC)
     {
         INPC npc = entity as INPC;
         //是可以攻击的NPC
         if (npc.IsCanAttackNPC())
         {
             Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart;
             bool canAttack = true;
             if (skillPart != null)
             {
                 int skillerror = 0;
                 canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror);
             }
             if (npc.IsPet())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsSummon())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsMonster())
             {
                 int hp    = entity.GetProp((int)CreatureProp.Hp);
                 int maxhp = entity.GetProp((int)CreatureProp.MaxHp);
                 return(hp < maxhp);
             }
         }
         else
         {
             table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
             if (npcdb != null)
             {
                 if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT ||
                     npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Exemple #5
0
    /// <summary>
    /// 更新位置
    /// </summary>
    public void UpdatePositon()
    {
        if (!Visible)
        {
            return;
        }
        if (UID == 0)
        {
            return;
        }
        Client.IEntity entity = RoleStateBarManager.GetEntity(UID);
        if (entity == null)
        {
            return;
        }

        RoleStateBarManager mgr = DataManager.Manager <RoleStateBarManager>();
        Vector3             pos = Vector3.zero;

        if (entity.GetEntityType() == EntityType.EntityType_Player)
        {
            bool bRide = (bool)entity.SendMessage(Client.EntityMessage.EntityCommond_IsRide, null);
            if (bRide)
            {
                pos = mgr.GetNodeWorldPos(UID, "MountName", offsetY);
            }
            else
            {
                pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
            }
        }
        else
        {
            pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
        }

        Camera mainCamera = Util.MainCameraObj.GetComponent <Camera>();
        Camera uiCamera   = Util.UICameraObj.GetComponent <Camera>();

        if (null == uiCamera || null == mainCamera)
        {
            return;
        }
        pos = mainCamera.WorldToViewportPoint(pos);
        //bool isVisible = (mainCamera.orthographic || pos.z > 0f) && (/*!disableIfInvisible || */(pos.x > 0f && pos.x < 1f && pos.y > 0f && pos.y < 1f));
        //if (Visible != isVisible)
        //{
        //    SetVisible(isVisible);
        //    if (Visible)
        //    {
        //        AdjustStatusPos();
        //    }
        //}
        pos = uiCamera.ViewportToWorldPoint(pos);
        m_tsTran.position = pos;
        pos   = m_tsTran.localPosition;
        pos.x = Mathf.FloorToInt(pos.x);
        pos.y = Mathf.FloorToInt(pos.y);
        pos.z = 0f;
        m_tsTran.localPosition = pos;
    }
Exemple #6
0
    void EventCallBack(int nEventID, object param)
    {
        if (nEventID == (int)GameEventID.ENTITYSYSTEM_PROPUPDATE)
        {
            Client.stPropUpdate prop = (Client.stPropUpdate)param;
            //传过来的是Long型参数ID  强制转换不知道会不会有问题
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                Engine.Utility.Log.Error("严重错误:EntitySystem is null!");
                return;
            }
            Client.IEntity entity = es.FindEntity(prop.uid);
            if (entity != null)
            {
                if (entity.GetEntityType() != EntityType.EntityType_Player)
                {
                    return;
                }
                if (m_currShowUID == entity.GetID())
                {
                    ShowByPlayer(entity as Client.IPlayer);
                }
            }
        }
        else if (nEventID == (int)GameEventID.TITLE_WEAR)
        {
            Client.stTitleWear data = (Client.stTitleWear)param;
            if (Client.ClientGlobal.Instance().IsMainPlayer(data.uid))
            {
                SetWearTitleItem(data.titleId);

                RefreshTitleGrids(data.titleId);
            }
        }
        else if (nEventID == (int)GameEventID.TITLE_ACTIVATE)
        {
            uint titleId = (uint)param;
            SetActivateTitleItem(titleId);
            RefreshTitleGrids(titleId);
        }
        else if (nEventID == (int)GameEventID.TITLE_TIMEOUT)
        {
            uint titleId = (uint)param;
            RefreshTitleGrids(titleId);
        }
        else if (nEventID == (int)GameEventID.TITLE_NEWTITLE)
        {
            uint titleId = (uint)param;
            CreateTopTabs();
            RefreshTitleGrids(titleId);
        }
        else if (nEventID == (int)GameEventID.TITLE_DELETE)
        {
            uint titleId = (uint)param;
            CreateTopTabs();
            if (m_lstTitleData.Exists((data) => { return(data == titleId ? true : false); }))
            {
                RefreshTitleGrids(titleId);
                //InitTitleGridListUI();
            }
        }
        else if (nEventID == (int)GameEventID.TITLE_USETIMES)
        {
            uint titleId = (uint)param;
            //刷新界面使用次数
            UpdateUseTimes(titleId);
            //刷新左侧的grid  (次数为0,取消佩戴激活)
            RefreshTitleGrids(titleId);
        }
    }
        // 同步技能消息
        public void SyncSkill(uint uSkillID, Client.IEntity target, Vector3 targetPos)
        {
 
            if(uSkillID == 0)
            {
                Log.Error("SyncSkill skillid is 0");
                return;
            }
            // 填充数据
            Vector3 pos = m_Master.GetPos();

            SkillDatabase database = GetSkillDataBase(uSkillID);

            Client.IControllerSystem ctrlSys = m_ClientGlobal.GetControllerSystem();
            if (ctrlSys == null)
            {
                return;
            }

            Client.IController ctrl = ctrlSys.GetActiveCtrl();
            if (ctrl == null)
            {
                return;
            }
            if (targetPos == Vector3.zero)
            {
                int skillerror = 0;
                bool bCanUse = ctrl.FindTargetBySkillID(CurSkillID, ref targetPos, ref target, out skillerror);
                if (!bCanUse)
                {
                    Log.LogGroup("ZDY", "不符合规则 不能放技能");
                    return;
                }
            }


            var cmd = new GameCmd.stMultiAttackUpMagicUserCmd_C();
            cmd.dwAttackerID = (uint)m_ClientGlobal.MainPlayer.GetID();
            cmd.wdSkillID = uSkillID;
            cmd.byEntryType = SceneEntryType.SceneEntry_Player;

            cmd.srcx = (uint)(pos.x);
            cmd.srcy = (uint)(-pos.z);
            Vector3 rot = m_Master.GetRotate();
            cmd.byDirect = (uint)rot.y;

            Vector3 sendTargetPos = GetSendTargetPos(database, targetPos);
            cmd.x = (uint)(sendTargetPos.x * 100);
            cmd.y = (uint)(-sendTargetPos.z * 100);

            if (target != null)
            {
                stMultiAttackUpMagicUserCmd_C.Item item = new stMultiAttackUpMagicUserCmd_C.Item();
                if (target != null)
                {
                    item.byEntryType = (target.GetEntityType() == EntityType.EntityType_Player ? SceneEntryType.SceneEntry_Player : SceneEntryType.SceneEntry_NPC);
                    item.dwDefencerID = (uint)target.GetID();
                }
                else
                {
                    item.dwDefencerID = 0;
                }

                cmd.data.Add(item);
               
            }
            m_uDamageID++;
            cmd.tmpid = m_uDamageID;

            // 填充数据
            m_ClientGlobal.netService.Send(cmd);
        }
Exemple #8
0
    void RefreshClanName(Client.IEntity entity, RoleStateBar bar)
    {
        if (entity == null)
        {
            Engine.Utility.Log.Error("AddClanName entity is null");
            return;
        }
        if (bar == null)
        {
            Engine.Utility.Log.Error("AddClanName bar is null");
            return;
        }

        EntityType entityType = entity.GetEntityType();

        if (entityType == EntityType.EntityType_Player)
        {
            uint clanIdLow  = (uint)entity.GetProp((int)CreatureProp.ClanIdLow);
            uint clanIdHigh = (uint)entity.GetProp((int)CreatureProp.ClanIdHigh);
            uint clanId     = (clanIdHigh << 16) | clanIdLow;

            //int clanId = entity.GetProp((int)Client.CreatureProp.ClanId);
            if (clanId != 0)
            {
                DataManager.Manager <ClanManger>().GetClanName((uint)clanId, (namedata) =>
                {
                    string winerCityName = string.Empty;
                    string name          = string.Empty;
                    if (DataManager.Manager <CityWarManager>().GetWinerOfCityWarCityName((uint)clanId, out winerCityName))
                    {
                        //name = namedata.ClanName + winerCityName;
                        name = string.Format("{0}【{1}】", winerCityName, namedata.ClanName);
                    }
                    else
                    {
                        //name = namedata.ClanName;
                        name = string.Format("【{0}】", namedata.ClanName);
                    }

                    bool visible = m_bPlayerClanNameVisible;
                    if (entity.GetUID() == Client.ClientGlobal.Instance().MainPlayer.GetUID())
                    {
                        visible = true;
                    }
                    HeadTipData data = new HeadTipData(entity, HeadTipType.Clan, visible);
                    data.value       = name;
                    bar.UpdateWidget(data);
                });
            }
            else
            {
                bar.SetWidgetState(HeadTipType.Clan, false);
            }
        }
        else if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            CityWarTotem cityWarTotemInfo = null;
            if (DataManager.Manager <CityWarManager>().GetCityWarTotemClanName((uint)entity.GetProp((int)Client.EntityProp.BaseID), out cityWarTotemInfo))
            {
                HeadTipData data = new HeadTipData(entity, HeadTipType.Clan, m_bPlayerClanNameVisible);
                data.value = cityWarTotemInfo.clanName;
                bar.UpdateWidget(data);
            }
            else
            {
                bar.SetWidgetState(HeadTipType.Clan, false);
            }
        }
    }
Exemple #9
0
        private void OnEvent(int nEventID, object param)
        {
            GameEventID eventId = (GameEventID)nEventID;

            switch (eventId)
            {
            case GameEventID.ENTITYSYSTEM_MAINPLAYERCREATE:
            {
                SetTimer(MEDICAL_TIMEID, MEDICAL_TIME_INTERVAL);
                SetTimer(ATONCE_TIMERID, ATONCE_LEN);
            }
            break;

            case GameEventID.ENTITYSYSTEM_RELIVE:
            {
                stEntityRelive er = (stEntityRelive)param;
                if (ControllerSystem.m_ClientGlobal.IsMainPlayer(er.uid))
                {
                    SetTimer(MEDICAL_TIMEID, MEDICAL_TIME_INTERVAL);
                    SetTimer(ATONCE_TIMERID, ATONCE_LEN);
                }
            }
            break;

            case GameEventID.ENTITYSYSTEM_ENTITYDEAD:
            {
                stEntityDead ed = (stEntityDead)param;
                if (ControllerSystem.m_ClientGlobal.IsMainPlayer(ed.uid))
                {
                    KillTimer(MEDICAL_TIMEID);
                    KillTimer(ATONCE_TIMERID);
                }
            }
            break;

            case GameEventID.SKILLSYSTEM_SKILLLISTCHANE:
            case GameEventID.SKILLSYSTEM_ADDSKILL:
                InitSkill();
                break;

            case GameEventID.SKILLNONESTATE_ENTER:
            {
                NextSkill = 0;
                OnCombat();
            }
            break;

            //case GameEventID.ROBOTCOMBAT_NEXTCMD:
            //    {
            //        if (param != null)
            //        {
            //            Client.stSkillDoubleHit skillDhHit = (Client.stSkillDoubleHit)param;
            //            OnUseDoubleHitSkill(skillDhHit);
            //        }
            //    }
            //    break;
            case GameEventID.SKILLSYSTEM_STIFFTIMEOVER:
            {        //挂机状态下 硬直结束(并且没有插入技能)只处理普攻前两招,第三招释放时如果有插入 就不播放收招
                stNextSkill st = (stNextSkill)param;
                NextSkill = st.nextSkillID;
                if (m_status == CombatRobotStatus.RUNNING && NextSkill != 0)
                {
                    DoAttack();
                }
                if (m_status == CombatRobotStatus.RUNNING && NextSkill == 0 && InsertSkillID != 0)
                {
                    DoAttack();
                }
            }
            break;

            case GameEventID.SKILLGUIDE_PROGRESSBREAK:
            {
                if (param != null)
                {
                    stGuildBreak skillFailed = (stGuildBreak)param;
                    if (skillFailed.action == GameCmd.UninterruptActionType.UninterruptActionType_SkillCJ)
                    {
                        if (ControllerSystem.m_ClientGlobal.IsMainPlayer(skillFailed.uid))
                        {
                            m_nIgnoreSkillid = skillFailed.skillid;

                            // AddTips(string.Format("使用技能失败id:{0} ret{1}", skillFailed.skillid, skillFailed.msg));
                        }
                        ChangeRoleAction(RoleAction.NONE);
                    }
                }
                //ChangeRoleAction(RoleAction.USESKILL);
                //DoNextCMD();
            }
            break;

            case GameEventID.JOYSTICK_UNPRESS:
                m_fStopTime = UnityEngine.Time.realtimeSinceStartup;

                break;

            case GameEventID.JOYSTICK_PRESS:
                m_fStopTime = 0;
                OnPause(true);
                break;

            case GameEventID.ENTITYSYSTEM_CREATEENTITY:
            {
                Client.stCreateEntity createEntity = (Client.stCreateEntity)param;
                Client.IEntitySystem  es           = ControllerSystem.m_ClientGlobal.GetEntitySystem();
                Client.IEntity        entity       = es.FindEntity(createEntity.uid);
                if (entity != null)
                {
                    if (entity.GetEntityType() == EntityType.EntityType_Box)
                    {
                        ShowBoxTips(entity.GetID());
                        OnPickUpItem();
                    }
                }
            }
            break;

            case GameEventID.ENTITYSYSTEM_REMOVEENTITY:
            {
                Client.stRemoveEntity removeEntiy = (Client.stRemoveEntity)param;
                Client.IEntitySystem  es          = ControllerSystem.m_ClientGlobal.GetEntitySystem();
                Client.IEntity        entity      = es.FindEntity(removeEntiy.uid);
                if (entity != null)
                {
                    if (entity.GetEntityType() == EntityType.EntityType_Box)
                    {
                        OnPickUpItem();
                    }
                }
            }
            break;

            case GameEventID.ROBOTCOMBAT_COPYKILLWAVE:
            {
                if (param != null)
                {
                    stCopySkillWave copyWave = (stCopySkillWave)param;
                    if (m_bInCopy)
                    {
                        m_nLaskKillWave     = copyWave.waveId;
                        m_nLaskMovePosIndex = copyWave.posIndex;
                        //  AddTips(string.Format("副本wave{0} posIndex{1}", m_nLaskKillWave, m_nLaskMovePosIndex));
                        if (m_nLaskMovePosIndex != 0)
                        {
                            // SetTimer(COPYCOMBAT_TIMEID, 1600);
                            //OnPause(false);
                        }
                        //DoNextCMD();
                    }
                }
            }
            break;

            case GameEventID.NETWORK_CONNECTE_CLOSE:
            {
                m_disconnectStatus = m_status;
                if (m_disconnectStatus != CombatRobotStatus.STOP)
                {
                    Stop();
                    Engine.Utility.Log.Error("掉线了 挂机停止!!!");
                }
            }
            break;

            case GameEventID.RECONNECT_SUCESS:
            {
                if (m_disconnectStatus != CombatRobotStatus.STOP)
                {
                    Start();
                    if (m_disconnectStatus == CombatRobotStatus.PAUSE)
                    {
                        Pause();
                    }
                    m_disconnectStatus = CombatRobotStatus.STOP;
                }
            }
            break;

            default:
                break;
            }
        }