Ejemplo n.º 1
0
 private void BindSkill(string skill, ObserveHeroSkill skillComp)
 {
     try
     {
         SysSkillMainVo skillData   = SkillUtility.GetSkillData(skill, -1, -1);
         string         skill_icon  = skillData.skill_icon;
         Texture        mainTexture = ResourceManager.Load <Texture>(skill_icon, true, true, null, 0, false);
         skillComp.Texture.mainTexture = mainTexture;
         if (skillComp.Level)
         {
             int skillLevel = this._hero.skillManager.GetSkillLevel(skill);
             skillComp.Level.text = skillLevel.ToString();
         }
         float num         = 0f;
         float skillCDTime = this._hero.GetSkillCDTime(skill);
         if (skillCDTime > 0f)
         {
             num = this._hero.GetCDTime(skill) / skillCDTime;
         }
         skillComp.Mask.fillAmount = num;
         this.SetMaskEnableStatus(skillComp.Mask, num);
     }
     catch (Exception e)
     {
         ClientLogger.LogException(e);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 打开指定窗口,使用指定视图控制器
 /// </summary>
 /// <param name="winId"></param>
 /// <param name="ctrl"></param>
 public static void OpenWindow(WindowID winId, IView ctrl = null)
 {
     try
     {
         if (CtrlManager.mDicOpenCtrls.ContainsKey(winId))
         {
             if (winId == WindowID.TipView)
             {
                 CtrlManager.OnOpenWindow(new OpenWindowEventArgs(true, winId.ToString(), CtrlManager.mDicOpenCtrls[winId].uiWindow));
             }
         }
         else
         {
             IView view = ctrl;
             if (view == null)
             {
                 view = CtrlManager.GetViewInstance(winId);
             }
             view.WinId = winId;
             CtrlManager.mDicWindCtrls[winId] = view;
             UIManager.Instance.OpenWindow(view.WinId.ToString(), view.WinResCfg);
         }
     }
     catch (Exception e)
     {
         ClientLogger.LogException(e);
     }
 }
Ejemplo n.º 3
0
 public void UpdateFriendState(string content)
 {
     try
     {
         if (!string.IsNullOrEmpty(content))
         {
             string[] stateStrs = content.Split(new char[]
             {
                 '|'
             });
             if (stateStrs.Length >= 3)
             {
                 long userIdBySummId = ToolsFacade.Instance.GetUserIdBySummId(long.Parse(stateStrs[1]));
                 FriendItemInHomeChat friendItemInHomeChat = this.FriendLst.transform.Find("Grid/" + userIdBySummId.ToString()).TryGetComp(null);
                 if (!(friendItemInHomeChat == null))
                 {
                     friendItemInHomeChat.SetGameState((GameStatus)int.Parse(stateStrs[2]));
                     List <FriendData> list       = ModelManager.Instance.Get_FriendDataList_X();
                     FriendData        friendData = list.Find((FriendData _obj) => _obj.TargetId.ToString() == stateStrs[1]);
                     if (friendData != null)
                     {
                         friendData.GameStatus = (sbyte)int.Parse(stateStrs[2]);
                     }
                     this._friendChat.CreateList(list);
                 }
             }
         }
     }
     catch (Exception e)
     {
         ClientLogger.LogException(e);
     }
 }
Ejemplo n.º 4
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (this._tasks.Count == 0)
            {
                return;
            }
            float         now  = Time.realtimeSinceStartup;
            List <Action> list = new List <Action>();

            list.AddRange(from x in this._tasks
                          where now > x.happenTime
                          select x.action);
            this._tasks.RemoveAll((PvpServer.RunOnceTask x) => now > x.happenTime);
            list.ForEach(delegate(Action x)
            {
                try
                {
                    x();
                }
                catch (Exception e)
                {
                    ClientLogger.LogException(e);
                }
            });
        }
Ejemplo n.º 5
0
        private void RefreshSummaryInfo()
        {
            try
            {
                PvpStatisticMgr.GroupData groupData = Singleton <PvpManager> .Instance.StatisticMgr.GetGroupData(0);

                if (groupData != null)
                {
                    this._components.LmTowerCount.text = groupData.TeamTowerDestroy.ToString();
                    this._components.LmKillCount.text  = groupData.TeamKill.ToString();
                    this._components.LmGold.text       = Singleton <PvpManager> .Instance.StatisticMgr.GetTotalMeney(TeamType.LM).ToString();
                }
                PvpStatisticMgr.GroupData groupData2 = Singleton <PvpManager> .Instance.StatisticMgr.GetGroupData(1);

                if (groupData2 != null)
                {
                    this._components.BlTowerCount.text = groupData2.TeamTowerDestroy.ToString();
                    this._components.BlKillCount.text  = groupData2.TeamKill.ToString();
                    this._components.BlGold.text       = Singleton <PvpManager> .Instance.StatisticMgr.GetTotalMeney(TeamType.BL).ToString();
                }
                this._components.ObserverCount.text = Singleton <PvpManager> .Instance.ObserverCount.ToString();

                DateTime?gameStartTime = Singleton <PvpManager> .Instance.GameStartTime;
                TimeSpan timeSpan      = default(TimeSpan);
                if (gameStartTime.HasValue)
                {
                    timeSpan = DateTime.Now - gameStartTime.Value;
                }
                this._components.Time.text = StringUtils.FormatTimeInMinutes((int)timeSpan.TotalSeconds, true);
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
            }
        }
Ejemplo n.º 6
0
    private void RefreshBasicInfo()
    {
        try
        {
            this.HeroName.text = Singleton <PvpManager> .Instance.GetSummonerName(-this.UniqueId);

            this.Level.text = UtilManager.Instance.GetHerolv(this.UniqueId).ToString();
            this.Hp.value   = this._hero.hp / this._hero.hp_max;
            this.Mp.value   = this._hero.mp / this._hero.mp_max;
            this.Xp.value   = UtilManager.Instance.GetHeroExpRatio(this.UniqueId);
        }
        catch (Exception e)
        {
            ClientLogger.LogException(e);
        }
    }
Ejemplo n.º 7
0
 private void TryStopThread()
 {
     if (this._thread != null)
     {
         this._threadDone = true;
         Thread thread = this._thread;
         this._thread = null;
         try
         {
             thread.Join();
         }
         catch (Exception e)
         {
             ClientLogger.LogException(e);
         }
     }
 }
 public static void ExecuteMsg(MobaMessage msg)
 {
     if (msg.MessageType < (MobaMessageType)MobaMessageManager.mMessageFuncList.Length)
     {
         if (msg.MessageType == MobaMessageType.PvpCode)
         {
         }
         Dictionary <int, MobaMessageFunc> dictionary = MobaMessageManager.mMessageFuncList[(int)msg.MessageType];
         MobaMessageFunc mobaMessageFunc;
         if (dictionary != null && dictionary.TryGetValue(msg.ID, out mobaMessageFunc))
         {
             if (mobaMessageFunc == null)
             {
                 return;
             }
             if (msg.MessageType == MobaMessageType.PvpCode)
             {
             }
             try
             {
                 Stopwatch stopwatch = new Stopwatch();
                 if (msg.MessageType == MobaMessageType.PvpCode)
                 {
                     stopwatch.Start();
                 }
                 mobaMessageFunc(msg);
                 if (msg.MessageType == MobaMessageType.PvpCode)
                 {
                     stopwatch.Stop();
                 }
             }
             catch (Exception e)
             {
                 ClientLogger.LogException(e);
             }
             if (msg.MessageType == MobaMessageType.PvpCode)
             {
             }
         }
     }
 }
Ejemplo n.º 9
0
    public static void PromptFormat(string id, params object[] args)
    {
        SysPromptVo dataById = BaseDataMgr.instance.GetDataById <SysPromptVo>(id);

        if (dataById != null)
        {
            try
            {
                string mess = string.Format(LanguageManager.Instance.GetStringById(dataById.prompt_text), args);
                UIMessageBox.ShowMessage(mess, dataById.text_time, 0);
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
            }
            AudioMgr.PlayUI(dataById.sound, null, false, false);
        }
        else
        {
            ClientLogger.Error("PromptHelper.Prompt: cannot found #" + id);
        }
    }
Ejemplo n.º 10
0
        private static void TryRecoverUnit(UnitRuntimeInfo info)
        {
            UnitInfo baseUnitInfo = info.baseUnitInfo;
            Units    units        = MapManager.Instance.GetUnit(baseUnitInfo.unitId);

            try
            {
                UnitType unitType = baseUnitInfo.unitType;
                if (unitType != UnitType.Hero)
                {
                    if (unitType != UnitType.Monster)
                    {
                        if (unitType != UnitType.Tower && unitType != UnitType.Home)
                        {
                            if (unitType == UnitType.MapItem)
                            {
                                if (!units)
                                {
                                    PvpProtocolTools.CreateMapItem(info, UnitControlType.None);
                                }
                                goto IL_179;
                            }
                            if (unitType != UnitType.Soldier)
                            {
                                if (unitType == UnitType.FenShenHero)
                                {
                                    if (!units)
                                    {
                                        units = PvpProtocolTools.CreateHeroByUnitInfo(info.baseUnitInfo);
                                    }
                                    PvpProtocolTools.SetUnitState(units, info);
                                    goto IL_179;
                                }
                                if (unitType != UnitType.EyeUnit && unitType != UnitType.SummonMonster && unitType != UnitType.Pet && unitType != UnitType.LabisiUnit)
                                {
                                    goto IL_179;
                                }
                            }
                        }
                        else
                        {
                            units = MapManager.Instance.GetUnit(baseUnitInfo.unitId);
                            if (!units)
                            {
                                ClientLogger.Error("TryCreateUnit: tower not found - " + StringUtils.DumpObject(baseUnitInfo));
                                return;
                            }
                            PvpProtocolTools.SetUnitState(units, info);
                            goto IL_179;
                        }
                    }
                    if (!units)
                    {
                        units = PvpProtocolTools.CreateMonsterByUnitInfo(info.baseUnitInfo);
                    }
                    PvpProtocolTools.SetUnitState(units, info);
                }
                else
                {
                    if (!units)
                    {
                        units = MapManager.Instance.TryFetchRecycledUnit(baseUnitInfo.unitId);
                        if (!units)
                        {
                            ClientLogger.Error("TryCreateUnit: hero not found - " + StringUtils.DumpObject(baseUnitInfo));
                            return;
                        }
                    }
                    PvpProtocolTools.SetUnitState(units, info);
                }
IL_179:
                if (units)
                {
                    units.UpdateVisible();
                    units.RefreshSyncState();
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
            }
        }
Ejemplo n.º 11
0
        private static void SyncHeroSkills(Units unit, UnitInfo unitInfo)
        {
            if (!unit.isHero)
            {
                return;
            }
            if (unitInfo.heroInfo == null)
            {
                ClientLogger.Error("heroInfo is null");
                return;
            }
            try
            {
                PvpStatisticMgr.HeroData heroData = Singleton <PvpManager> .Instance.StatisticMgr.GetHeroData(unitInfo.unitId);

                heroData.CurGold   = unitInfo.heroInfo.money;
                heroData.TotalGold = unitInfo.heroInfo.totalMoney;
                heroData.CurLv     = unitInfo.level;
                heroData.CurExp    = unitInfo.heroInfo.exp;
                if (unit.mCmdRunningController != null)
                {
                    unit.mCmdRunningController.Reset();
                }
                unit.level = unitInfo.level;
                unit.skillManager.SkillPointsLeft = unitInfo.heroInfo.skillPoint;
                if (unitInfo.heroInfo.skillInfo != null)
                {
                    Dictionary <int, string> skills_index = unit.skillManager.skills_index;
                    int num = 0;
                    foreach (string current in unitInfo.heroInfo.skillInfo.Keys)
                    {
                        int num2 = -1;
                        foreach (int current2 in skills_index.Keys)
                        {
                            if (skills_index[current2] == current)
                            {
                                num2 = current2;
                                break;
                            }
                        }
                        if (num2 >= 0)
                        {
                            string text      = skills_index[num2];
                            Skill  skillById = unit.skillManager.getSkillById(text);
                            if (skillById != null)
                            {
                                skillById.BulletIndex = unitInfo.heroInfo.skillInfo[current].index;
                            }
                            int level = (int)unitInfo.heroInfo.skillInfo[current].level;
                            num += level;
                            int skillIdx = unitInfo.heroInfo.skillInfo[current].skillIdx;
                            unit.skillManager.UpgradeSkillLevel(text, level);
                            unit.skillManager.ResetSkillSubIndex(text, skillIdx);
                            float num3    = (float)unitInfo.heroInfo.skillInfo[current].cd / 1000f;
                            float cd_time = unitInfo.heroInfo.skillInfo[current].chargeCD / 1000f;
                            unit.SetCDTime(text, num3);
                            unit.SetChargeTime(text, cd_time);
                            unit.OnSkillSynced(text, unitInfo.heroInfo.skillInfo[current].useState);
                            if (unit.isPlayer)
                            {
                                Singleton <SkillView> .Instance.SetSkillUILevel(text, level);

                                Singleton <SkillView> .Instance.UpdateSkillItemCDTime(num3, text);

                                Singleton <SkillView> .Instance.UpdateSkillView(text, false);
                            }
                        }
                    }
                    if (num == 0 && unit.level == 1 && unit.skillManager.SkillPointsLeft == 0 && unit.isPlayer)
                    {
                        unit.skillManager.SkillPointsLeft = 1;
                    }
                }
                if (unit.isPlayer)
                {
                    Singleton <SkillView> .Instance.SetSkillPointLeft(unitInfo.heroInfo.skillPoint);
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
            }
        }
Ejemplo n.º 12
0
 private static void SyncUnitLifeState(Units unit, UnitInfo unitInfo, long reliveLeftTime)
 {
     try
     {
         PvpLifeState lifeState = (PvpLifeState)unitInfo.lifeState;
         if (lifeState == PvpLifeState.Dead || lifeState == PvpLifeState.WaitRelive)
         {
             PvpProtocolTools.ToDie(unit, null, reliveLeftTime);
         }
         else
         {
             if (!unit.isLive)
             {
                 if (unit.isHero)
                 {
                     SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
                     spawnUtility.RespawnPvpHero(unit);
                 }
                 else
                 {
                     ClientLogger.Error(string.Concat(new object[]
                     {
                         "SetUnitState: cannot relive non-hero unit #",
                         unit.unique_id,
                         " ",
                         unit.name,
                         " to state ",
                         lifeState
                     }));
                 }
             }
             if (unit.IsMonsterCreep())
             {
                 Monster monster = unit as Monster;
                 if (lifeState == PvpLifeState.Unactive)
                 {
                     monster.Sleep();
                 }
                 else if (lifeState == PvpLifeState.Live)
                 {
                     if (monster.Sleeping.IsInState)
                     {
                         monster.Wakeup(false);
                     }
                     else
                     {
                         monster.Appear();
                     }
                 }
                 else
                 {
                     ClientLogger.Warn(string.Concat(new object[]
                     {
                         "don't know how to treat ",
                         unit.name,
                         " with life state ",
                         lifeState
                     }));
                 }
             }
         }
     }
     catch (Exception e)
     {
         ClientLogger.LogException(e);
     }
 }
Ejemplo n.º 13
0
        public static Units CreateHeroByUnitInfo(UnitInfo info)
        {
            Units result;

            try
            {
                if (info == null)
                {
                    result = null;
                }
                else
                {
                    EntityVo entityVo = new EntityVo(EntityType.Hero, info.typeId, 0, 0, string.Empty, "Default", 0)
                    {
                        uid      = info.unitId,
                        level    = info.level,
                        hp       = 99999f,
                        mp       = 99999f,
                        effectId = string.Empty
                    };
                    Units unit = MapManager.Instance.GetUnit(info.mainHeroId);
                    if (unit != null)
                    {
                        if (unit.npc_id == "Jiansheng")
                        {
                            entityVo.effectId = "1|Perform_jsbirth_fenshen";
                        }
                        else if (unit.npc_id == "Houzi")
                        {
                        }
                    }
                    SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
                    Vector3      vector       = MoveController.SVectgor3ToVector3(info.position);
                    string       userName     = (!(unit == null)) ? unit.summonerName : "1";
                    string       summerId     = "1";
                    Units        units        = spawnUtility.SpawnPvpHero(entityVo, "Hero", (TeamType)info.group, 0, userName, summerId, new Vector3?(vector), UnitType.FenShenHero);
                    if (units != null && unit != null)
                    {
                        units.level = unit.level;
                        units.data.SetMaxHp(unit.hp_max);
                        units.data.SetMaxMp(unit.mp_max);
                        units.data.SetHp(unit.hp);
                        units.data.SetMp(unit.mp);
                        units.SetParentUnit(unit);
                        units.SetMirrorState(true);
                        if (unit.npc_id == "Jiansheng")
                        {
                            units.SetCanAIControl(true);
                            units.SetCanSkill(false);
                            units.effect_id = "2|Perform_jsdead_fenshen";
                        }
                        else if (unit.npc_id == "Houzi")
                        {
                            units.effect_id = "2|FenShenDeath,2|DashengS2";
                            units.SetCanAIControl(false);
                            units.SetCanAction(false);
                            units.trans.rotation = unit.trans.rotation;
                        }
                        Units selectedTarget = PlayerControlMgr.Instance.GetSelectedTarget();
                        if (selectedTarget != null && unit.unique_id == selectedTarget.unique_id)
                        {
                            PlayerControlMgr.Instance.GetPlayer().SetSelectTarget(null);
                            PlayerControlMgr.Instance.GetPlayer().SetAttackTarget(null);
                            PlayerControlMgr.Instance.SetSelectedTarget(null);
                        }
                        units.SetPosition(vector, true);
                    }
                    result = units;
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
                result = null;
            }
            return(result);
        }
Ejemplo n.º 14
0
        public static Units CreateMonsterByUnitInfo(UnitInfo info)
        {
            Units result;

            try
            {
                if (info == null)
                {
                    ClientLogger.Error("CreateMonsterByUnitInfo: info is null");
                    result = null;
                }
                else if (MapManager.Instance == null)
                {
                    ClientLogger.Error("MapManager.Instance is null");
                    result = null;
                }
                else if (GlobalSettings.TestCreep)
                {
                    Singleton <CreepSpawner> .Instance.CreateCreeps(new List <string>
                    {
                        "101"
                    }, info.unitId);

                    result = null;
                }
                else if (GlobalSettings.NoMonster)
                {
                    ClientLogger.Warn("P2C_CreateUnits create monster ignored");
                    result = null;
                }
                else if (info.unitType == UnitType.EyeItem)
                {
                    result = PvpProtocolTools.CreateEyeItemByUnitInfo(info);
                }
                else
                {
                    TeamType  teamType  = PvpProtocolTools.GroupToTeam((int)info.group);
                    int       num       = -1;
                    Transform transform = null;
                    if (StringUtils.CheckValid(info.burnValue))
                    {
                        string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|');
                        UnitType unitType    = info.unitType;
                        if (unitType != UnitType.Monster)
                        {
                            if (unitType != UnitType.Soldier)
                            {
                                ClientLogger.Error("cannot be here");
                            }
                            else
                            {
                                num = int.Parse(stringValue[2]);
                            }
                        }
                        else
                        {
                            num       = int.Parse(stringValue[1]);
                            transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num);
                        }
                        if (num < 0)
                        {
                            ClientLogger.Error("burnValue is invalid, use position #" + info.typeId + "  " + info.burnValue);
                        }
                    }
                    else if (info.unitType == UnitType.EyeUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.SummonMonster || info.unitType == UnitType.BoxUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.Pet)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.LabisiUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else
                    {
                        ClientLogger.Error(string.Concat(new object[]
                        {
                            "burnValue is invalid, use default position #",
                            info.typeId,
                            "  utype:",
                            info.unitType
                        }));
                    }
                    Units unit = MapManager.Instance.GetUnit(info.mainHeroId);
                    int   skin = 0;
                    if (unit != null && info.unitType == UnitType.SummonMonster)
                    {
                        skin = HeroSkins.GetRealHeroSkin((TeamType)unit.teamType, unit.model_id);
                    }
                    EntityVo npcinfo = new EntityVo(EntityType.Monster, info.typeId, num, 0, string.Empty, "Default", 0)
                    {
                        uid  = info.unitId,
                        skin = skin
                    };
                    if (null == GameManager.Instance)
                    {
                        Debug.LogError("null == GameManager.Instance");
                        result = null;
                    }
                    else if (GameManager.Instance.Spawner == null)
                    {
                        Debug.LogError("null == GameManager.Instance.Spawner");
                        result = null;
                    }
                    else
                    {
                        SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
                        Units        units        = spawnUtility.SpawnInstance(npcinfo, "Monster", teamType, num, "[]", transform, UnitControlType.None, info.unitType);
                        if (units == null)
                        {
                            ClientLogger.Error(string.Concat(new object[]
                            {
                                "P2C_CreateUnits create monster failed, creepId=",
                                info.creepId,
                                " typeid= ",
                                info.typeId,
                                " burnValue=",
                                info.burnValue ?? "null"
                            }));
                            result = null;
                        }
                        else
                        {
                            if (units.UnitType == UnitType.EyeUnit)
                            {
                            }
                            if (unit != null)
                            {
                                units.ParentUnit = unit;
                            }
                            if (units.UnitType == UnitType.EyeUnit || units.UnitType == UnitType.SummonMonster)
                            {
                                units.m_fLiveTime = info.liveTime;
                                units.m_fLeftTime = info.liveTime;
                            }
                            units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId);
                            units.TryAddBirthEffect();
                            units.SetIsMonsterCreep(info.unitType == UnitType.Monster || info.unitType == UnitType.CreepBoss);
                            PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L);
                            if (units.isMonster && units.skillManager != null)
                            {
                                units.skillManager.EnableSkills(true);
                            }
                            if (units != null && transform != null)
                            {
                                units.SetPosition(transform.position, true);
                            }
                            result = units;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
                result = null;
            }
            return(result);
        }