Esempio n. 1
0
    void SetRolePkModel(Client.IEntity entity)
    {
        if (entity == null)
        {
            return;
        }
        if (!ClientGlobal.Instance().IsMainPlayer(entity.GetUID()))
        {
            return;
        }


        if (m_lableBtnTop != null)
        {
            int model = entity.GetProp((int)PlayerProp.PkMode);
            if (model != 0)
            {
                m_lableBtnTop.text = GetPkModeDes(model);
            }
            else
            {
                m_lableBtnTop.text = GetPkModeDes(1);
            }
        }
    }
Esempio n. 2
0
    void MainUsePanelItemOnClick()
    {
        Client.IEntity player = Client.ClientGlobal.Instance().MainPlayer;
        if (player == null)
        {
            return;
        }

        bool ismoving = (bool)player.SendMessage(Client.EntityMessage.EntityCommand_IsMove, null);

        if (ismoving)
        {
            player.SendMessage(Client.EntityMessage.EntityCommand_StopMove, player.GetPos());
        }

        List <BaseItem> lstItems = DataManager.Manager <ItemManager>().GetItemByBaseId(this.usecommitItemID);

        if (lstItems.Count > 0)
        {
            uint m_nitemThisId = lstItems[0].QWThisID;

            DataManager.Manager <RideManager>().TryUnRide(
                (obj) =>
            {
                Protocol.Instance.RequestUseItem(m_nitemThisId);
            },
                null);
        }
    }
Esempio n. 3
0
    public void Excute(GameCmd.stSetSPDataUserCmd_S cmd)
    {
        Client.IEntity en = EntitySystem.EntityHelper.GetEntity(GameCmd.SceneEntryType.SceneEntry_Player, cmd.id);
        if (en == null)
        {
            return;
        }

        stPropUpdate prop = new stPropUpdate();

        prop.uid        = en.GetUID();
        prop.nPropIndex = (int)CreatureProp.Mp;
        prop.oldValue   = en.GetProp((int)CreatureProp.Mp);
        prop.newValue   = (int)cmd.sp;

        en.SetProp((int)CreatureProp.Mp, (int)cmd.sp);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_MPUPDATE, prop);

        prop.uid        = en.GetUID();
        prop.nPropIndex = (int)CreatureProp.MaxMp;
        prop.oldValue   = en.GetProp((int)CreatureProp.MaxMp);
        prop.newValue   = (int)cmd.maxsp;

        en.SetProp((int)CreatureProp.MaxMp, (int)cmd.maxsp);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_MPUPDATE, prop);
    }
Esempio n. 4
0
    void DoDie()
    {
        Engine.Utility.Log.Info("主角死亡............");
        //客户端自己设置血量为0
        Client.IEntity en = ClientGlobal.Instance().MainPlayer;
        if (en == null)
        {
            return;
        }
        stPropUpdate prop = new stPropUpdate();

        prop.uid        = en.GetUID();
        prop.nPropIndex = (int)CreatureProp.Hp;
        prop.oldValue   = en.GetProp((int)CreatureProp.Hp);
        prop.newValue   = 0;
        en.SetProp((int)CreatureProp.Hp, prop.newValue);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_HPUPDATE, prop);
        //清空选中目标
        ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().UpdateTarget(null);

        if (Client.ClientGlobal.Instance().MainPlayer.IsDead())
        {
            if (DataManager.Manager <NvWaManager>().EnterNvWa == false)//女娲无复活弹框
            {
                float waitTime = 1f;
                DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ReLivePanel, data: waitTime);
            }
        }
    }
Esempio n. 5
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);
        }
    }
Esempio n. 6
0
    void OnEeventAddBuff(int eventID, Client.stAddBuff state)
    {
        BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(state.buffid);

        if (db != null)
        {
            if (db.dwShield == 1)
            {//不显示的直接跳过
                return;
            }
        }
        if (ClientGlobal.Instance().IsMainPlayer(state.uid))
        {
            mainRoleBuffList.Insert(0, state);
            stShowBuffInfo info = new stShowBuffInfo();
            info.IsMainRole = true;
            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
        }
        else
        {
            Client.IEntity target = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();
            if (target != null)
            {
                if (target.GetUID() == state.uid)
                {
                    targetBuffList.Insert(0, state);
                    stShowBuffInfo info = new stShowBuffInfo();
                    info.IsMainRole = false;
                    DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MainPanel, UIMsgID.stShowBuff, info);
                }
            }
        }
    }
Esempio n. 7
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);
        }
    }
Esempio n. 8
0
    public void ShowDamage(uint damageValue, uint damType, uint roleid, EntityType type, uint curHp, uint skillid = 1, uint attackerid = 0)
    {//伤害包
        // Log.LogGroup("ZDY", "show damage damagevalue is {0}", damageValue);
        Client.IEntity entity = GetEntity(roleid, type);
        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到实体roleid:{0},type :{1}", roleid, type);
            return;
        }
        SetEntityCurHP(entity, curHp);
        table.SkillDatabase skillData = GameTableManager.Instance.GetTableItem <table.SkillDatabase>(skillid);
        uint damageTimes  = 1;
        uint hurtinterval = 0;

        if (skillData != null)
        {
            damageTimes  = skillData.damagetimes;
            hurtinterval = skillData.hurtinterval;
        }


        DamageType dt = GetDamageType(damType);

        if (testType != DamageType.None)
        {
            dt = testType;
        }
        if (entity != null)
        {
            //if (damageTimes == 1 || dt == DamageType.Doge)
            {
                FlyFont font = GetFlyFont(dt);
                if (font == null)
                {
                    return;
                }
                font.InitDamageType(dt);
                AddFlyFont(entity, type, dt, font, damageValue);
            }
            //else
            //{
            //    uint damage = damageValue / damageTimes;
            //    List<int> damageList = new List<int>();
            //    int totalHurt = 0;
            //    uint averageValue = damage - damage / 4;
            //    for (int i = 0; i < damageTimes - 1; i++)
            //    {
            //        int hurt = UnityEngine.Random.Range((int)averageValue, (int)damage);
            //        damageList.Add(hurt);
            //        totalHurt += hurt;
            //    }

            //    int lastHurt = (int)damageValue - totalHurt;
            //    damageList.Add(lastHurt);
            //    StartCoroutine(AddDamage(roleid, damType, type, damageList, hurtinterval));
            //}
        }
    }
Esempio n. 9
0
    public void OnTimer(uint uTimerID)
    {
        if (uTimerID == MAIN_TIMER_ID)
        {
            RefreshTime();
            if (ClientGlobal.Instance().MainPlayer == null)
            {
                return;
            }

            //Vector3 pos = ClientGlobal.Instance().MainPlayer.GetPos();

            //m_label_coordinate.text = string.Format("{0},{1}", (int)(pos.x + 0.5f), (int)(-pos.z + 0.5f));
            //ping值要被动触发 时间60s更新一次 不然 DateTime.Now.ToShortTimeString()频繁触发gc modify by dianyu


            if (m_effctSelect != null)
            {
                if (m_effctSelect.GetNode() == null)
                {
                    return;
                }
                if (m_effctSelect.GetNode().GetTransForm() == null)
                {
                    return;
                }
                if (m_effctSelect.GetNode().GetTransForm().gameObject.activeSelf)
                {
                    SetSelectTargetEffectPos();
                }
            }
        }
        if (uTimerID == m_uUseSkillTimerID)
        {
            UseSkill(nPrePareSkillID);
        }
        else if (uTimerID == m_uSkillLongPressTimerID)
        {
            Log.LogGroup("ZDY", "long attack ......");
            //长按事件
            //Debug.LogError("long attack");
            ReqUseSkill(m_uCommonAttackSkillID);
        }
        else if (uTimerID == m_uRefreshEnemyTimerID)
        {
            Client.IEntity entity = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();
            if (entity != null)
            {
                NetService.Instance.Send(new GameCmd.stEnmityDataUserCmd_CS()
                {
                    npcid = entity.GetID()
                });
            }
        }
    }
Esempio n. 10
0
    private void UpdateProprty(object param)
    {
        stPropUpdate prop = (stPropUpdate)param;

        //更新目标血条
        if (prop.nPropIndex == (int)CreatureProp.Hp)
        {
            Client.IEntity target = ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl().GetCurTarget();
            if (target != null && target.GetUID() == prop.uid)
            {
                Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
                UpdateTargetHp(entity);
                return;
            }
        }
        //更新自己信息
        if (!ClientGlobal.Instance().IsMainPlayer(prop.uid))
        {
            return;
        }
        if (prop.nPropIndex == (int)CreatureProp.Hp || prop.nPropIndex == (int)CreatureProp.MaxHp)
        {
            Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
            if (entity != null)
            {
                SetRoleHp(entity);
            }
        }
        if (prop.nPropIndex == (int)CreatureProp.Mp || prop.nPropIndex == (int)CreatureProp.MaxMp)
        {
            Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
            if (entity != null)
            {
                SetRoleMp(entity);
            }
        }
        else if (prop.nPropIndex == (int)PlayerProp.Exp)
        {
            Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
            if (entity != null)
            {
                SetRoleExp(entity);
            }
        }
        else if (prop.nPropIndex == (int)PlayerProp.PkMode)
        {
            SetRolePkModel(ClientGlobal.Instance().MainPlayer);
        }
        else if (prop.nPropIndex == (int)CreatureProp.Level)
        {
            int level = MainPlayerHelper.GetPlayerLevel();
            m_label_Level.text        = level.ToString();
            m_label_mainroleName.text = UserData.CurrentRole.name;
        }
    }
Esempio n. 11
0
        private bool IsMoving()
        {
            Client.IEntity player = ControllerSystem.m_ClientGlobal.MainPlayer;
            if (player == null)
            {
                return(false);
            }
            bool moving = (bool)player.SendMessage(EntityMessage.EntityCommand_IsMove, null);

            return(moving);
        }
Esempio n. 12
0
 void SetRoleHpMpExpPkPower(Client.IEntity entity)
 {
     SetRoleHp(entity);
     SetRoleMp(entity);
     SetRoleExp(entity);
     SetRolePkModel(entity);
     if (m_label_lablePower != null)
     {
         m_label_lablePower.text = entity.GetProp((int)FightCreatureProp.Power).ToString();
     }
 }
Esempio n. 13
0
        public override void OnEvent(int nEventID, object param)
        {
            IEntity casetr = skillPart.GetMaster();

            if (casetr == null)
            {
                return;
            }

            if (nEventID == (int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE)
            {
                Client.stEntityStopMove stopEntity = (Client.stEntityStopMove)param;
                if (m_skillDatabase != null && stopEntity.uid == skillPart.GetMaster().GetUID())
                {
                    if (m_skillDatabase.dwMoveType == (uint)SkillMoveType.FastMove) // 冲锋类技能
                    {
                        PlayerSkillPart playerSkill = skillPart as PlayerSkillPart;
                        if (playerSkill != null)
                        {
                            if (playerSkill.gotoPos != Vector3.zero)
                            {
                                playerSkill.Master.SendMessage(EntityMessage.EntityCommand_SetPos, (object)playerSkill.gotoPos);
                                Client.IEntity target = playerSkill.SkillTarget;
                                if (target != null)
                                {
                                    if (m_skillDatabase.targetType != (int)SkillTargetType.TargetForwardPoint)
                                    {
                                        playerSkill.Master.SendMessage(EntityMessage.EntityCommand_LookTarget, target.GetPos());
                                    }
                                }
                            }
                        }

                        m_Statemachine.ChangeState((int)SkillState.Over, null);
                        // 接冲锋动作后半段
                        //PlayAni anim_param = new PlayAni();
                        //string strAniName = m_caster.GetAniState().name;
                        //anim_param.strAcionName = strAniName + "_Over";
                        //anim_param.fSpeed = 1;
                        //anim_param.nStartFrame = 0;
                        //anim_param.nLoop = 1;
                        //anim_param.fBlendTime = 0.2f;
                        //anim_param.aniCallback = OnAnimationPlayEnd;
                        //anim_param.callbackParam = casetr.GetUID();
                        //// 播放攻击动作
                        //playerSkill.Player.SendMessage( EntityMessage.EntityCommand_PlayAni , anim_param );
                    }
                }
            }
            else if (nEventID == (int)Client.GameEventID.ENTITYSYSTEM_ENTITYBEGINMOVE)
            {
                // 攻击状态中收到移动事件,则切换到OVer状态
            }
        }
Esempio n. 14
0
    void SetRoleMp(Client.IEntity entity)
    {
        if (entity == null || m_slider_mpSpritebg == null)
        {
            return;
        }
        int   mp    = entity.GetProp((int)CreatureProp.Mp);
        float maxmp = (float)entity.GetProp((int)CreatureProp.MaxMp);

        m_slider_mpSpritebg.value = mp / maxmp;
        //   m_sprite_mpSprite.fillAmount =
    }
Esempio n. 15
0
    void SetRoleHp(Client.IEntity entity)
    {
        if (entity == null || m_slider_hpSpritebg == null)
        {
            return;
        }
        int   hp    = entity.GetProp((int)CreatureProp.Hp);
        float maxhp = (float)entity.GetProp((int)CreatureProp.MaxHp);

        m_slider_hpSpritebg.value = hp / maxhp;
        // m_sprite_hpSprite.fillAmount =
    }
Esempio n. 16
0
    /// <summary>
    /// 获取NPC头顶标识数据
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    public static table.NpcHeadMaskDataBase GetNPCHeadMaskDB(Client.IEntity entity)
    {
        table.NpcHeadMaskDataBase db = null;
        if (null != entity
            //&& entity.GetEntityType() == EntityType.EntityType_NPC
            )
        {
            db = GetNPCHeadMaskDB((uint)entity.GetProp((int)Client.EntityProp.BaseID));
        }

        return(db);
    }
Esempio n. 17
0
 void OnChangeName(long uid)
 {
     Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(uid);
     if (entity != null)
     {
         RoleStateBar bar = GetRoleBarByUID(uid);
         if (bar != null)
         {
             HeadTipData data = new HeadTipData(entity, HeadTipType.Name, GetNameVisible(entity));
             bar.UpdateWidget(data);
         }
     }
 }
Esempio n. 18
0
    void SetRoleExp(Client.IEntity entity)
    {
        if (entity == null || m_slider_expSprite_bg == null)
        {
            return;
        }
        //经验值exp显示
        table.UpgradeDataBase data = GameTableManager.Instance.GetTableItem <table.UpgradeDataBase>((uint)entity.GetProp((int)CreatureProp.Level));
        ulong maxExp = data.qwExp;

        m_label_Labelexp.text       = string.Format("经验{0}%", Mathf.Floor((entity.GetProp((int)PlayerProp.Exp) + 0.0f) / (int)maxExp * 100));
        m_slider_expSprite_bg.value = (entity.GetProp((int)PlayerProp.Exp) + 0.0f) / (int)maxExp;
    }
Esempio n. 19
0
        private void FindMonsterAddAttack()
        {
            IEntity target = GetNearestMonster();

            if (target != null)
            {
                //目标没死亡
                ICreature c = (target as ICreature);
                if (c != null && !c.IsDead())
                {
                    m_ActiveCtrl.UpdateTarget(target);

                    uint skillid = GetNextSkillID();
                    if (skillid != 0 && m_skillPart.IsSkillCanUse(skillid))
                    {
                        AddAttackCmd(target, skillid);
                    }
                    else
                    {
                        ChangeRoleAction(RoleAction.NONE);
                        //  AddTips(string.Format("CombatRobot->FindMonsterAddAttack 技能{0} 不可使用 {1}", skillid, UnityEngine.Time.realtimeSinceStartup));
                    }
                }
            }
            else
            {
                if (m_RoleAction != RoleAction.NONE)
                {
                    if (m_bInCopy)
                    {
                        MoveToWavePos();
                    }
                    else
                    {
                        Engine.Utility.Log.LogGroup("ZCX", "找不到攻击目标");
                        Client.IEntity player = ControllerSystem.m_ClientGlobal.MainPlayer;
                        if (player != null)
                        {
                            PlayAni anim_param = new PlayAni();
                            anim_param.strAcionName = EntityAction.Stand;
                            anim_param.fSpeed       = 1;
                            anim_param.nStartFrame  = 0;
                            anim_param.nLoop        = -1;
                            anim_param.fBlendTime   = 0.2f;
                            player.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param);
                        }
                        ChangeRoleAction(RoleAction.NONE);
                    }
                }
            }
        }
Esempio n. 20
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);
                }
            }
        }
    }
Esempio n. 21
0
    public void Execute(GameCmd.stLevelUpMagicUserCmd_S cmd)
    {
        Client.IEntity en = EntitySystem.EntityHelper.GetEntity(GameCmd.SceneEntryType.SceneEntry_Player, cmd.dwUserTempID);
        if (en == null)
        {
            return;
        }

        stPropUpdate prop = new stPropUpdate();

        prop.uid        = en.GetUID();
        prop.nPropIndex = (int)CreatureProp.Level;
        prop.oldValue   = en.GetProp((int)CreatureProp.Level);
        prop.newValue   = (int)cmd.dwLevel;

        stEntityLevelUp levelup = new stEntityLevelUp();

        levelup.uid        = en.GetUID();
        levelup.nLastLevel = en.GetProp((int)CreatureProp.Level);
        levelup.nLevel     = (int)cmd.dwLevel;

        en.SetProp((int)CreatureProp.Level, (int)cmd.dwLevel);
        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_PROPUPDATE, prop);

        // 等级提升
        if (levelup.nLevel > levelup.nLastLevel)
        {
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_LEVELUP, levelup);

            //IEntity mainPlayer = EntitySystem.EntityHelper.GetEntity(MainPlayerHelper.GetPlayerUID());


            if (ClientGlobal.Instance().IsMainPlayer(en))
            {
                //主角实体加特效

                EntitySystem.EntityHelper.AddEffect(en, 9001);
                //统计
                DataManager.Manager <LoginDataManager>().UserUpLevel(levelup.nLevel);
            }
        }


        // 飘字提示 升级成功
        //         if(ClientGlobal.Instance().IsMainPlayer(en))
        //         {
        //             string strTips = string.Format("角色等级提升");
        //             TipsManager.Instance.ShowTips(strTips);
        //         }
    }
Esempio n. 22
0
    public void OnUpdate(IEntity entity, object param = null)
    {
        Client.IEntity mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
        if (mainPlayer == null || mainPlayer.IsDead() || entity == null)
        {
            return;
        }

        UnityEngine.Vector3 dis = mainPlayer.GetPos() - entity.GetPos();

        uint npcid = (uint)entity.GetProp((int)Client.EntityProp.BaseID);

        if (npcid != m_nNpcID || SQRMagnitude <= 0f)
        {
            m_nNpcID = npcid;
            table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>(m_nNpcID);
            if (npcdb != null)
            {
                SQRMagnitude = npcdb.dwCallDis * npcdb.dwCallDis * 0.01f * 0.01f;
            }
        }

        if (dis.sqrMagnitude < SQRMagnitude)
        {
            if (IsTrigger)
            {
                return;
            }
            IsTrigger = true;
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.CAMP_ADDCOLLECTNPC,
                                                                new stCampCollectNpc()
            {
                npcid = entity.GetUID(), enter = true
            });
        }
        else
        {
            if (IsTrigger)
            {
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.CAMP_ADDCOLLECTNPC,
                                                                    new stCampCollectNpc()
                {
                    npcid = entity.GetUID(), enter = false
                });
            }
            IsTrigger = false;
        }
    }
Esempio n. 23
0
    public void Excute(GameCmd.stSetHpSpDataUserCmd_CS cmd)
    {
        Client.IEntity en = ClientGlobal.Instance().MainPlayer;
        if (en == null)
        {
            return;
        }

        stPropUpdate prop = new stPropUpdate();

        prop.uid        = en.GetUID();
        prop.nPropIndex = (int)CreatureProp.Mp;
        prop.oldValue   = en.GetProp((int)CreatureProp.Mp);
        prop.newValue   = (int)cmd.sp;

        en.SetProp((int)CreatureProp.Mp, (int)cmd.sp);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_MPUPDATE, prop);

        if (en.GetProp((int)CreatureProp.MaxMp) != (int)cmd.maxsp)
        {
            prop.nPropIndex = (int)CreatureProp.MaxMp;
            prop.oldValue   = en.GetProp((int)CreatureProp.MaxMp);
            prop.newValue   = (int)cmd.maxsp;

            en.SetProp((int)CreatureProp.MaxMp, (int)cmd.maxsp);

            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_MPUPDATE, prop);
        }

        prop.nPropIndex = (int)CreatureProp.Hp;
        prop.oldValue   = en.GetProp((int)CreatureProp.Hp);
        prop.newValue   = (int)cmd.hp;

        en.SetProp((int)CreatureProp.Hp, (int)cmd.hp);

        Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_HPUPDATE, prop);

        if (en.GetProp((int)CreatureProp.MaxHp) != (int)cmd.maxhp)
        {
            prop.nPropIndex = (int)CreatureProp.MaxHp;
            prop.oldValue   = en.GetProp((int)CreatureProp.MaxHp);
            prop.newValue   = (int)cmd.maxhp;
            en.SetProp((int)CreatureProp.MaxHp, (int)cmd.maxsp);
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_HPUPDATE, prop);
        }
    }
Esempio n. 24
0
 /// <summary>
 /// 属性变更
 /// </summary>
 /// <param name="prop"></param>
 private void OnPropUpdate(ref stPropUpdate prop)
 {
     Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
     if (prop.nPropIndex == (int)CreatureProp.Hp || prop.nPropIndex == (int)CreatureProp.MaxHp)
     {
         UpdateHeadStaus(prop.uid, HeadStatusType.Hp);
     }
     else if (prop.nPropIndex == (int)PlayerProp.GoodNess ||
              prop.nPropIndex == (int)CreatureProp.Camp)
     {
         UpdateHeadStaus(prop.uid, HeadStatusType.Name);
         if (prop.nPropIndex == (int)Client.CreatureProp.Camp)
         {
             UpdateHeadStaus(prop.uid, HeadStatusType.CampMask);
         }
     }
 }
Esempio n. 25
0
    void PlayAni(Client.IEntity player, string entityAction)
    {
        if (player == null)
        {
            return;
        }

        //处理
        PlayAni anim_param = new PlayAni();

        anim_param.strAcionName = entityAction;
        anim_param.fSpeed       = 1;
        anim_param.nStartFrame  = 0;
        anim_param.nLoop        = -1;
        anim_param.fBlendTime   = 0.2f;
        player.SendMessage(EntityMessage.EntityCommand_PlayAni, anim_param);
    }
Esempio n. 26
0
    public void OnUpdate(IEntity entity, object param = null)
    {
        if (IsTrigger)
        {
            //如果过了2秒还存在 说明没有捡起
            if (UnityEngine.Time.realtimeSinceStartup - m_fTriggerTime > 2.5f)
            {
                IsTrigger = false;
            }
            return;
        }

        Client.IEntity mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
        if (mainPlayer == null || mainPlayer.IsDead() || entity == null)
        {
            return;
        }


        IBox box = entity as IBox;

        if (box == null)
        {
            return;
        }

        UnityEngine.Vector3 dis = mainPlayer.GetPos() - entity.GetPos();
        if (dis.sqrMagnitude < SQRMagnitude)
        {
            IsTrigger = true;
            if (box.CanPick())
            {
                m_fTriggerTime = UnityEngine.Time.realtimeSinceStartup;
                NetService.Instance.Send(new GameCmd.stPickUpItemPropertyUserCmd_C()
                {
                    qwThisID = entity.GetID()
                });
//                 if (box.CanAutoPick())
//                 {
//                     Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_PICKUPITEM,
//                         new Client.stPickUpItem() { itemid = entity.GetID(), state = 1 });
//                 }
                // UnityEngine.Debug.Log("捡起道具 " + entity.GetID());
            }
        }
    }
Esempio n. 27
0
    void RefreshHpSlider(Client.IEntity entity, RoleStateBar bar)
    {
        if (entity == null)
        {
            Engine.Utility.Log.Error("RefreshHpSlider entity is null");
            return;
        }
        if (bar == null)
        {
            Engine.Utility.Log.Error("RefreshHpSlider bar is null");
            return;
        }
        bool        addHpSlider = IsNeedHpSlider(entity);
        HeadTipData data        = null;

        if (addHpSlider)
        {
            bool    visible = true;
            IPlayer player  = ClientGlobal.Instance().MainPlayer;
            if (player == null)
            {
                return;
            }
            if (entity.GetUID() == player.GetUID())
            {
                visible = true;
            }
            else
            {
                visible = m_bHpSliderVisible;
            }
            data = new HeadTipData(entity, HeadTipType.Hp, visible);
        }
        else
        {
            data = new HeadTipData(entity, HeadTipType.Hp, addHpSlider);
        }
        if (data != null)
        {
            bar.UpdateWidget(data);
        }
    }
Esempio n. 28
0
    public void ShowBuffDamage(stBuffDamage damage)
    {
        Client.IEntity entity = GetEntity(damage.uid);
        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到实体roleid:{0}", damage.uid);
            return;
        }

        SetEntityCurHP(entity, damage.curHp);

        if (damage.uid != MainPlayerHelper.GetPlayerUID())
        {
            return;
        }

        EntityType entype = damage.entityType == (int)EntityType.EntityType_Player ? EntityType.EntityType_Player : EntityType.EntityType_NPC;

        DamageType dt = DamageType.Normal;

        if (damage.changeValue > 0)
        {
            dt = DamageType.AddHp;
        }
        if (testType != DamageType.None)
        {
            dt = testType;
        }
        if (entity != null)
        {
            if (damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Buff || damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Imme)
            {
                FlyFont font = GetFlyFont(dt);
                if (font == null)
                {
                    return;
                }
                font.InitDamageType(dt);
                AddFlyFont(entity, entype, dt, font, damage.changeValue);
            }
        }
    }
Esempio n. 29
0
 private void OnPropUpdate(ref stPropUpdate prop)
 {
     Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
     if (prop.nPropIndex == (int)CreatureProp.Hp || prop.nPropIndex == (int)CreatureProp.MaxHp)
     {
         if (entity != null)
         {
             RoleStateBar bar = GetRoleBarByUID(prop.uid);
             if (bar != null)
             {
                 HeadTipData data = new HeadTipData(entity, HeadTipType.Hp, m_bHpSliderVisible);
                 bar.UpdateWidget(data);
             }
         }
     }
     else if (prop.nPropIndex == (int)PlayerProp.GoodNess || prop.nPropIndex == (int)CreatureProp.Camp)
     {
         OnChangeName(prop.uid);
     }
 }
Esempio n. 30
0
    public void Excute(stUnTransfigurationScriptUserCmd_S cmd)
    {
        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return;
        }

        Client.IEntity player = es.FindPlayer(cmd.userid);
        if (player != null)
        {
            player.SetProp((int)Client.PlayerProp.TransModelResId, 0);
            player.SendMessage(Client.EntityMessage.EntityCommand_Restore, new Client.ChangeBody()
            {
                param      = cmd.taskid,
                callback   = null,
                modleScale = 1
            });
        }
    }