Exemplo n.º 1
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);
        }
    }
Exemplo n.º 2
0
    public Client.INPC GetNPCByTraceInfo(QuestTraceInfo questInfo)
    {
        if (null == questInfo)
        {
            return(null);
        }
        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            Engine.Utility.Log.Error("实体系统为null");
            return(null);
        }

        GameCmd.TaskProcess process = questInfo.GetTaskProcess();


        uint npcid    = 0;
        uint effectID = 0;

        if (process == GameCmd.TaskProcess.TaskProcess_None)//可接
        {
            npcid = questInfo.beginNpc;
        }
        else if (process == GameCmd.TaskProcess.TaskProcess_CanDone)
        {
            npcid = questInfo.endNpc;
        }
        else if (process == GameCmd.TaskProcess.TaskProcess_Doing)
        {
            npcid = questInfo.endNpc;
        }
        Client.INPC npc = es.FindNPCByBaseId((int)npcid);
        return(npc);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 刷新npc任务状态表示
    /// </summary>
    /// <param name="taskId"></param>
    private void OnUpdateNpcTaskStatus(uint taskId, Client.GameEventID eventID)
    {
        long   uid    = 0;
        string icon   = "";
        bool   enable = false;

        switch (eventID)
        {
        case GameEventID.TASK_ACCEPT:
        case GameEventID.TASK_CANACCEPT:
        case GameEventID.TASK_DONING:
        case GameEventID.TASK_CANSUBMIT:
        {
            enable = RoleStateBarManager.TryGetQuestStatusIcon(taskId, out uid, out icon);
            if (eventID == GameEventID.TASK_ACCEPT)
            {
                table.QuestDataBase questDB = GameTableManager.Instance.GetTableItem <table.QuestDataBase>(taskId);
                if (questDB != null && questDB.dwBeginNpc != questDB.dwEndNpc)
                {
                    //交接任务不在同一个npc移除任务标示
                    Client.INPC npc = RoleStateBarManager.GetNPCByBaseID(questDB.dwBeginNpc);
                    if (null != npc)
                    {
                        UpdateNpcTaskStatus(npc.GetUID(), false);
                    }
                }
            }
        }
        break;

        case GameEventID.TASK_DELETE:
        case GameEventID.TASK_DONE:
        {
            table.QuestDataBase questDB = GameTableManager.Instance.GetTableItem <table.QuestDataBase>(taskId);
            if (questDB == null)
            {
                return;
            }
            Client.INPC npc = RoleStateBarManager.GetNPCByBaseID(questDB.dwEndNpc);
            if (null != npc)
            {
                uid = npc.GetUID();
            }
        }
        break;
        }
        if (uid != 0)
        {
            UpdateNpcTaskStatus(uid, enable, icon);
        }
    }
Exemplo n.º 4
0
    private void UpdateNpcHeadMask(Client.INPC npc)
    {
        if (null != npc)
        {
            return;
        }

        RoleStateBar bar    = GetRoleBarByUID(npc.GetUID());
        bool         enable = IsEntityHaveHeadIconMask(npc) && !NpcHeadTipsManager.Instance.IsHaveTips(npc);

        bar.SetWidgetState(HeadTipType.HeadMaskIcon, enable);
        if (enable)
        {
            bar.UpdateWidget(new HeadTipData(npc, HeadTipType.HeadMaskIcon, m_bHpSliderVisible));
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// 为采集物添加特效
    /// </summary>
    /// <param name="taskInfo"></param>
    void AddCollectNpcEffect(QuestTraceInfo taskInfo)
    {
        if (taskInfo.taskSubType != TaskSubType.Collection)
        {
            return;
        }

        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return;
        }

        Client.INPC npc = es.FindNPCByBaseId((int)taskInfo.QuestTable.collect_npc);
        if (npc == null)
        {
            return;
        }

        DataManager.Manager <TaskDataManager>().AddCollectNpcEffect(npc.GetID(), 9002);
        DataManager.Manager <TaskDataManager>().AddCollectNpcEffect(npc.GetID(), 9003);
    }
Exemplo n.º 6
0
    public static bool TryGetQuestStatusIcon(QuestTraceInfo info, out long uid, out string icon)
    {
        icon = string.Empty;
        uid  = 0;
        if (null == info)
        {
            return(false);
        }

        GameCmd.TaskProcess process = info.GetTaskProcess();

        uint npcid = 0;

        icon = GetQuestStatusIcon(process);
        if (process == GameCmd.TaskProcess.TaskProcess_CanDone)
        {
            npcid = info.endNpc;
        }
        else if (process == GameCmd.TaskProcess.TaskProcess_None)//可接
        {
            npcid = info.beginNpc;
        }
        else if (process == GameCmd.TaskProcess.TaskProcess_Doing)
        {
            npcid = info.endNpc;
        }

        Client.INPC npc = GetNPCByBaseID(npcid);
        if (npc == null)
        {
            Engine.Utility.Log.Info("查找不到npc{0}", npcid);
            return(false);
        }
        uid = npc.GetUID();
        return(true);
    }
Exemplo n.º 7
0
    void SkillEvent(int eventID, object param)
    {
        if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSSTART)
        {
            Client.stUninterruptMagic evenparam = (Client.stUninterruptMagic)param;
            if (ClientGlobal.Instance().IsMainPlayer(evenparam.uid))
            {
                if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.SliderPanel) == false)
                {
                    DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.SliderPanel, panelShowAction: (panel) =>
                    {
                        DispatchValueUpdateEvent(new ValueUpdateEventArgs()
                        {
                            key = SliderDataEnum.Begin.ToString()
                        });
                    });
                }
                float dur = (float)(evenparam.time * 1f / 1000);
                if (dur > 0)
                {
                    DataManager.Manager <SliderDataManager>().StartSliderByEvent(dur, evenparam.type);
                }
                else
                {
                    Log.Error("进度条时间小于 0");
                }
            }

            if (evenparam.type == GameCmd.UninterruptActionType.UninterruptActionType_CJ ||
                evenparam.type == GameCmd.UninterruptActionType.UninterruptActionType_CampCJ ||
                evenparam.type == GameCmd.UninterruptActionType.UninterruptActionType_SYDJ)
            {
                Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();

                if (es == null)
                {
                    return;
                }

                Client.IEntity player = es.FindEntity(evenparam.uid);

                if (player == null)
                {
                    return;
                }
                bool moving = (bool)player.SendMessage(Client.EntityMessage.EntityCommand_IsMove, null);
                if (moving)
                {
                    player.SendMessage(EntityMessage.EntityCommand_StopMove);
                }

                Client.INPC npc = es.FindNPC(evenparam.npcId);
                if (npc != null)
                {
                    player.SendMessage(EntityMessage.EntityCommand_LookTarget, npc.GetPos());
                }
                PlayAni(player, EntityAction.Collect);
            }
            else if (evenparam.type == GameCmd.UninterruptActionType.UninterruptActionType_CangBaoTuCJ)
            {
                //采集
                Log.Info("开始挖宝...");
                Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();

                if (es == null)
                {
                    return;
                }
                Client.IEntity player = es.FindEntity(evenparam.uid);

                if (player == null)
                {
                    return;
                }
                bool moving = (bool)player.SendMessage(Client.EntityMessage.EntityCommand_IsMove, null);
                if (moving)
                {
                    player.SendMessage(EntityMessage.EntityCommand_StopMove);
                }

                Client.INPC npc = es.FindNPC(evenparam.npcId);
                if (npc != null)
                {
                    player.SendMessage(EntityMessage.EntityCommand_LookTarget, npc.GetPos());
                }
                //                PlayAni(player, EntityAction.Collect);
                //播放挖宝动作
                PlayAni(player, EntityAction.Mining);

                //更换武器模型
                DataManager.Manager <SuitDataManager>().OnMiningTreasureMapToChangeWeapon(player);
            }
        }
        else if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSBREAK)
        {
            if (param != null)
            {
                stGuildBreak guildBreak = (stGuildBreak)param;
                if (ClientGlobal.Instance().IsMainPlayer(guildBreak.uid))
                {
                    DataManager.Manager <SliderDataManager>().HideSlider(guildBreak.action);
                    DataManager.Manager <SliderDataManager>().IsBreak         = true;
                    DataManager.Manager <SliderDataManager>().IsReadingSlider = false;
                    //DataManager.Manager<TaskDataManager>().IsShowSlider = false;
                }

                if (guildBreak.action == GameCmd.UninterruptActionType.UninterruptActionType_CJ ||
                    guildBreak.action == GameCmd.UninterruptActionType.UninterruptActionType_CampCJ)
                {
                    //打断采集
                    Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
                    if (es == null)
                    {
                        return;
                    }
                    Client.IEntity entity = es.FindPlayer(guildBreak.uid);
                    if (entity != null)
                    {
                        bool moving = (bool)entity.SendMessage(EntityMessage.EntityCommand_IsMove, null);
                        if (!moving)
                        {
                            PlayAni(guildBreak.uid, EntityAction.Stand);
                        }
                    }
                }
            }
        }
        else if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSEND)
        {
            DataManager.Manager <SliderDataManager>().IsReadingSlider = false;
            //DataManager.Manager<TaskDataManager>().IsShowSlider = false;
            stGuildEnd guildEnd = (stGuildEnd)param;
            if (ClientGlobal.Instance().IsMainPlayer(guildEnd.uid))
            {
                //坐骑读条完毕后上马
                if (guildEnd.action == GameCmd.UninterruptActionType.UninterruptActionType_DEMON)
                {
                    DataManager.Instance.Sender.RideUsingRide();
                }
                else
                {
                    if (guildEnd.action != GameCmd.UninterruptActionType.UninterruptActionType_SkillCJ)
                    {
                        PlayStand();
                    }
                }
            }
            else
            {
                //播站立动作
                PlayAni(guildEnd.uid, EntityAction.Stand);
            }
        }
        else if (eventID == (int)GameEventID.ENTITYSYSTEM_ENTITYDEAD)
        {
            stEntityDead ed = (stEntityDead)param;
            if (ClientGlobal.Instance().IsMainPlayer(ed.uid))
            {
                // HideSprite();
                DispatchValueUpdateEvent(new ValueUpdateEventArgs()
                {
                    key = SliderDataEnum.End.ToString(), oldValue = m_UninterruptActionType
                });
                DataManager.Manager <SliderDataManager>().IsBreak         = true;
                DataManager.Manager <SliderDataManager>().IsReadingSlider = false;
            }
        }
    }
Exemplo n.º 8
0
    private void UseMedicine()
    {
        bool canRunning = Engine.Utility.EventEngine.Instance().DispatchVote((int)GameVoteEventID.AUTORECOVER, null);

        if (!canRunning)
        {
            Engine.Utility.Log.LogGroup("ZCX", "canRunning false");
            return;
        }

        Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
        if (mainPlayer == null || mainPlayer.IsDead())
        {
            Engine.Utility.Log.LogGroup("ZCX", "player dead");
            return;
        }
        Dictionary <AutoRecoverGrid.MedicalType, UseMedicalInfo> .Enumerator iter = m_dicMedical.GetEnumerator();
        while (iter.MoveNext())
        {
            UseMedicalInfo medical = iter.Current.Value;
            if (medical != null && medical.select)
            {
                AutoRecoverGrid.MedicalType mtype = medical.Type;
                float rate = 1f;
                if (AutoRecoverGrid.MedicalType.HpAtOnce == mtype)
                {//瞬药 单独处理
                    continue;
                }
                if (AutoRecoverGrid.MedicalType.Hp == mtype || (AutoRecoverGrid.MedicalType.HpAtOnce == mtype))
                {
                    rate = mainPlayer.GetProp((int)CreatureProp.Hp) * 1f / mainPlayer.GetProp((int)CreatureProp.MaxHp);
                }
                else if (AutoRecoverGrid.MedicalType.Mp == mtype)
                {
                    rate = mainPlayer.GetProp((int)CreatureProp.Mp) * 1f / mainPlayer.GetProp((int)CreatureProp.MaxMp);
                    // string log = string.Format("rate = {0} trigger = {1} mp = {2} max= {3}", rate, medical.triggerValue, mainPlayer.GetProp((int)CreatureProp.Mp), mainPlayer.GetProp((int)CreatureProp.MaxMp));
                    //UnityEngine.Debug.LogError(log);
                }
                else if (AutoRecoverGrid.MedicalType.PetHp == mtype)
                {
                    if (DataManager.Manager <PetDataManager>().CurFightingPet == 0)
                    {
                        continue;
                    }
                    Client.INPC pet = DataManager.Manager <PetDataManager>().GetNpcByPetID(DataManager.Manager <PetDataManager>().CurFightingPet);
                    if (pet != null)
                    {
                        int a = pet.GetProp((int)CreatureProp.Hp);
                        rate = pet.GetProp((int)CreatureProp.Hp) * 1f / pet.GetProp((int)CreatureProp.MaxHp);
                    }
                }

                if (rate < medical.triggerValue)
                {
                    uint itemid = medical.itemid;
                    if (AutoRecoverGrid.MedicalType.Hp == mtype)
                    {
                        if (UnityEngine.Time.realtimeSinceStartup - m_nhpsendTime < 5f)
                        {
                            continue;
                        }
                        itemid = GetUseItemId(mtype);
                    }
                    else if (AutoRecoverGrid.MedicalType.Mp == mtype)
                    {
                        if (UnityEngine.Time.realtimeSinceStartup - m_nmpsendTime < 5f)
                        {
                            continue;
                        }
                        itemid = GetUseItemId(mtype);
                    }
                    if (itemid != 0 && CanUse(itemid))
                    {
                        List <BaseItem> itemdataList = DataManager.Manager <ItemManager>().GetItemByBaseId(itemid);
                        if (itemdataList.Count > 0)
                        {
                            if (AutoRecoverGrid.MedicalType.PetHp == mtype)
                            {
                                uint petID = DataManager.Manager <PetDataManager>().GetNpcIDByPetID(DataManager.Manager <PetDataManager>().CurFightingPet);
                                DataManager.Instance.Sender.UseItem(
                                    petID,
                                    (uint)GameCmd.SceneEntryType.SceneEntry_NPC,
                                    itemdataList[0].QWThisID, 1);
                            }
                            else
                            {
                                DataManager.Instance.Sender.UseItem(
                                    mainPlayer.GetID(),
                                    (uint)GameCmd.SceneEntryType.SceneEntry_Player,
                                    itemdataList[0].QWThisID, 1);

                                if (AutoRecoverGrid.MedicalType.Hp == mtype)
                                {
                                    m_nhpsendTime = UnityEngine.Time.realtimeSinceStartup;
                                }
                                else if (AutoRecoverGrid.MedicalType.Mp == mtype)
                                {
                                    m_nmpsendTime = UnityEngine.Time.realtimeSinceStartup;
                                }
                            }

                            //                            if (UnityEngine.Application.isEditor)
                            //                           {
                            //                               UnityEngine.Debug.Log(string.Format("使用物品 {0}" , itemid));
                            //                          }
                        }
                    }
                }
            }
        }
    }