protected override void ChannelRead0(IChannelHandlerContext ctx, CmppMessageReceiveArgs <CmppHead, CmppConnectResp> msg)
        {
            var  connectBody    = msg.Message;
            byte connectSuccess = 0;
            var  channel        = ctx.Channel;

            if (connectBody.Status.Equals(connectSuccess) && connectBody.AuthenticatorISMG != null)
            {
                var authenticatorISMG
                    = CmppTools.CreateAuthenticatorISMG(connectSuccess, authenticatorSource, config.Password);
                if (authenticatorISMG.SequenceEqual(authenticatorISMG))
                {
                    logger.Info($"login success, return:{msg.Message.Status.ToString()}", ctx.Channel.ToString());
                    var session = sessionMap.GetSessionOrDefault(ctx);
                    if (session == null)
                    {
                        ctx.Channel.CloseAsync();
                    }
                    session.Send = true;
                    connectCallBack_OK?.Invoke();
                    return;
                }
            }
            logger.Warn($"login fail, return:{msg.Message.Status.ToString()}", ctx.Channel.ToString());
            ctx.Channel.CloseAsync();
        }
Example #2
0
    public void Init(string head, string frame, long summonerExp)
    {
        SysSummonersPictureframeVo dataById = BaseDataMgr.instance.GetDataById <SysSummonersPictureframeVo>(frame);

        if (dataById != null)
        {
            this.S_HeadFrame.mainTexture = ResourceManager.Load <Texture>(dataById.pictureframe_icon, true, true, null, 0, false);
        }
        else
        {
            ClientLogger.Warn("SysSummonerPictureframeVo is NullFrameNumber is" + frame);
            this.S_HeadFrame.mainTexture = ResourceManager.Load <Texture>("pictureframe_0000", true, true, null, 0, false);
        }
        SysSummonersHeadportraitVo dataById2 = BaseDataMgr.instance.GetDataById <SysSummonersHeadportraitVo>(head);

        if (dataById2 == null)
        {
            this.S_Summoner.mainTexture = ResourceManager.Load <Texture>("headportrait_0001", true, true, null, 0, false);
        }
        else
        {
            this.S_Summoner.mainTexture = ResourceManager.Load <Texture>(dataById2.headportrait_icon, true, true, null, 0, false);
        }
        this.S_LV.text = CharacterDataMgr.instance.GetUserLevel(summonerExp).ToString();
    }
        private void L2C_UserBack(MobaMessage msg)
        {
            OperationResponse operationResponse = msg.Param as OperationResponse;
            byte b = (byte)operationResponse.Parameters[0];

            byte[]      buffer      = operationResponse.Parameters[1] as byte[];
            PlayerState playerState = (PlayerState)b;

            PvpStateBase.LogState("receive L2C_UserBack " + playerState + " ");
            Singleton <PvpManager> .Instance.LoginInfo            = null;
            Singleton <PvpManager> .Instance.ServerBattleRoomInfo = null;
            this.TargetState = PlayerState.Free;
            switch (playerState)
            {
            case PlayerState.Free:
                this.RecoverFinish(new PvpStateHome());
                return;

            case PlayerState.CheckReady:
                ClientLogger.Error("Cannot be here anymore.");
                this.RecoverFinish(new PvpStateHome());
                return;

            case PlayerState.SelectHore:
            {
                CtrlManager.CloseWindow(WindowID.PvpWaitView);
                InSelectAllInfo inSelectAllInfo = SerializeHelper.Deserialize <InSelectAllInfo>(buffer);
                Singleton <PvpManager> .Instance.SetBattleInfoWithoutJoinType(inSelectAllInfo.roomInfo.battleId);

                Singleton <PvpManager> .Instance.SetRoomInfo(inSelectAllInfo.roomInfo, inSelectAllInfo.newUid, inSelectAllInfo.playerInfos, null);

                PvpMatchMgr.Instance.SelectHeroTime = new DateTime?(DateTime.Now - TimeSpan.FromTicks(inSelectAllInfo.useTime));
                this.RecoverViewsForSelectHero();
                this.RecoverFinish(new PvpStateSelectHero());
                return;
            }

            case PlayerState.Loading:
            {
                InBattleLobbyInfo inBattleLobbyInfo = SerializeHelper.Deserialize <InBattleLobbyInfo>(buffer);
                InBattleRoomInfo  inBattleRoomInfo  = SerializeHelper.Deserialize <InBattleRoomInfo>(inBattleLobbyInfo.InBattleRoomInfoBytes);
                this.RecoverFromLoadingState(inBattleRoomInfo.roomInfo, inBattleLobbyInfo.loginInfo, inBattleRoomInfo.playerInfos, false);
                this.TargetState = PlayerState.Loading;
                return;
            }

            case PlayerState.InFight:
            {
                InBattleLobbyInfo inBattleLobbyInfo2 = SerializeHelper.Deserialize <InBattleLobbyInfo>(buffer);
                InBattleRoomInfo  inBattleRoomInfo2  = SerializeHelper.Deserialize <InBattleRoomInfo>(inBattleLobbyInfo2.InBattleRoomInfoBytes);
                this.RecoverFromLoadingState(inBattleRoomInfo2.roomInfo, inBattleLobbyInfo2.loginInfo, inBattleRoomInfo2.playerInfos, true);
                this.TargetState = PlayerState.InFight;
                return;
            }
            }
            ClientLogger.Warn("L2C_UserBack: unknown state " + playerState);
        }
 protected override void ChannelRead0(IChannelHandlerContext ctx, CmppMessageReceiveArgs <CmppHead, CmppSubmitResp> msg)
 {
     if (matchQueue.Match(ctx.Channel, msg.Header.SequenceId.ToString(), out Item <MsgEx> item))           //匹配流水号
     {
         msg.Item = item;
         CmppMessageReceiveArgs <CmppHead, CmppSubmitResp, Item <MsgEx> > msgEx
             = new CmppMessageReceiveArgs <CmppHead, CmppSubmitResp, Item <MsgEx> >(msg.Header, msg.Message, item);
         smsHandler?.Cmpp2LongSmsRespondAssembly(msgEx);
     }
     else
     {
         logger.Warn($"sms is removed from match cache{msg}", ctx.Channel.ToString());
     }
 }
        public static float GetAttrFactor(TeamType teamType, SysBattleSceneVo myScene)
        {
            float num = 1f;

            if (teamType == TeamType.BL)
            {
                num = myScene.hero2_factor;
            }
            if (num <= 1.401298E-45f)
            {
                ClientLogger.Warn("attrFactor is zero, ignore");
                num = 1f;
            }
            return(num);
        }
Example #6
0
        public ObjectRecycler(Func <T> getMethod, Action <T> delMethod = null)
        {
            this._getMethod = getMethod;
            this._delMethod = delMethod;
            GameObject gameObject = GameObject.Find("GlobalObject/recycler");

            if (!gameObject)
            {
                ClientLogger.Warn("cannot found");
            }
            else
            {
                this._recycleParent = gameObject.transform;
            }
        }
Example #7
0
        public Dictionary <string, object> GetDicByType <T>() where T : class
        {
            Dictionary <string, object> result;

            try
            {
                result = this.data[typeof(T).Name];
            }
            catch (Exception ex)
            {
                ClientLogger.Warn("warn\n" + ex.Message);
                string content = "配置文件和客户端不匹配,请装新版本,别找wcw!typeof(T).Name= " + typeof(T).Name + ",Info:" + ex.Message;
                CtrlManager.ShowMsgBox("错误", content, null, PopViewType.PopOneButton, "Shit", "取消", null);
                return(null);
            }
            return(result);
        }
        protected override MobaPeer ConnectPeer()
        {
            MobaPeer mobaPeer = this._client.GetMobaPeer(MobaPeerType.C2Lobby, true);

            mobaPeer.ServerName      = GlobalSettings.Instance.PvpSetting.LobbyServerName;
            mobaPeer.ApplicationName = "MobaServer.lobby";
            if (!mobaPeer.ServerConnected)
            {
                if (!mobaPeer.PeerConnect())
                {
                    ClientLogger.Error("PeerConnect failed for lobby");
                }
            }
            else
            {
                ClientLogger.Warn("Peer already connected");
            }
            return(mobaPeer);
        }
Example #9
0
        public Transform GetSpawnPos(TeamType team, int key)
        {
            Dictionary <int, Transform> dictionary = this._spawnPointsDict[team];
            Transform result;

            if (dictionary.TryGetValue(key, out result))
            {
                return(result);
            }
            ClientLogger.Warn(string.Concat(new object[]
            {
                "GetSpawnPos failed for: ",
                team,
                " ",
                key
            }));
            Transform transform = dictionary.Values.FirstOrDefault <Transform>();

            return(transform ? transform : this._spawnPointsDict[TeamType.LM].First <KeyValuePair <int, Transform> >().Value);
        }
Example #10
0
 private void updatashader()
 {
     if (this.mFog != null && this.mFog.enabled)
     {
         if (!this.mFog.getenabelfog())
         {
             return;
         }
         this.mInverseMVP = (this.mCam.projectionMatrix * this.mCam.worldToCameraMatrix).inverse;
         float     num       = 1f / (float)this.mFog.worldSize;
         Transform transform = this.mFog.transform;
         float     num2      = transform.position.x - (float)this.mFog.worldSize * 0.5f;
         float     num3      = transform.position.z - (float)this.mFog.worldSize * 0.5f;
         Vector4   vector    = this.mCam.transform.position;
         if (QualitySettings.antiAliasing > 0)
         {
             RuntimePlatform platform = Application.platform;
             if (platform == RuntimePlatform.WindowsEditor || platform == RuntimePlatform.WindowsPlayer || platform == RuntimePlatform.WindowsWebPlayer)
             {
                 vector.w = 1f;
             }
         }
         if (this.mMat != null)
         {
             Vector4 vector2 = new Vector4(-num2 * num, -num3 * num, num, this.mFog.blendFactor);
             this.mMat.SetVector("_CamPos", vector);
             this.mMat.SetVector("_Params", vector2);
             this.mMat.SetMatrix("_InverseMVP", this.mInverseMVP);
             this.mMat.SetTexture("_MainTex", this.mFog.texture1);
         }
         else
         {
             ClientLogger.Warn("err mMat...");
         }
     }
     else
     {
         ClientLogger.Warn("err fog..");
     }
 }
Example #11
0
 protected override void OnInit(bool isRebirth = false)
 {
     this.configMosterMainVo = BaseDataMgr.instance.GetMonsterMainData(this.npc_id);
     this.musicid            = this.configMosterMainVo.music_id;
     AudioMgr.loadSoundBank_Skill(this.musicid, true, 0);
     if (this.configMosterMainVo == null)
     {
         ClientLogger.Warn("Ignore scaling, cannot found SysMonsterMainVo: " + this.npc_id);
     }
     else
     {
         this.DoScale(this.configMosterMainVo.scale);
     }
     base.OnInit(false);
     if (!base.IsMonsterCreep())
     {
     }
     if (base.UnitType == UnitType.EyeUnit || base.IsMonsterCreep() || base.UnitType == UnitType.Soldier)
     {
         this.m_nServerVisibleState = 2;
     }
 }
    private void ReadExcel_X(string _promptId, ref int val)
    {
        SysPvpPromptVo dataById = BaseDataMgr.instance.GetDataById <SysPvpPromptVo>(_promptId);

        if (dataById != null)
        {
            string[] array = dataById.PromptCondition.Split(new char[]
            {
                '|'
            });
            if (array.Length > 1)
            {
                val = int.Parse(array[1]);
            }
            else
            {
                ClientLogger.Warn(_promptId + " data in PvpPrompt is error");
            }
        }
        else
        {
            ClientLogger.Warn(_promptId + " data in PvpPrompt is none");
        }
    }
Example #13
0
        public static ArrayList LoadFileByArray(string path, string name)
        {
            StreamReader streamReader = null;

            try
            {
                streamReader = File.OpenText(path + "//" + name);
            }
            catch (Exception ex)
            {
                ClientLogger.Warn("warn\n" + ex.Message);
                return(null);
            }
            ArrayList arrayList = new ArrayList();
            string    value;

            while ((value = streamReader.ReadLine()) != null)
            {
                arrayList.Add(value);
            }
            streamReader.Close();
            streamReader.Dispose();
            return(arrayList);
        }
Example #14
0
    public void InitData(DetailAchieveData achieveData = null, DailyTaskData dailyData = null)
    {
        if (achieveData != null)
        {
            if (Singleton <TaskView> .Instance.IsOpen)
            {
                this.getRewardEffect.panel = Singleton <TaskView> .Instance.transform.GetComponent <UIPanel>();
            }
            this.taskid            = achieveData.taskid.ToString();
            this.achievementTaskVo = BaseDataMgr.instance.GetDataById <SysAchievementTaskVo>(this.taskid);
            if (this.achievementTaskVo == null)
            {
                ClientLogger.Error("taskid=" + this.taskid + " !!在表里找不到");
                return;
            }
            this.name              = this.achievementTaskVo.name;
            this.describe          = this.achievementTaskVo.describe;
            this.parameter         = this.achievementTaskVo.parameter.ToString();
            this.icon              = this.achievementTaskVo.icon;
            this.reward            = this.achievementTaskVo.reward;
            this.achievement_point = this.achievementTaskVo.achievement_point.ToString();
            this.value             = achieveData.value.ToString();
        }
        else
        {
            if (Singleton <DailyView> .Instance.IsOpen)
            {
                this.getRewardEffect.panel = Singleton <DailyView> .Instance.transform.GetComponent <UIPanel>();
            }
            this.taskid             = dailyData.taskid.ToString();
            this.achievementDailyVo = BaseDataMgr.instance.GetDataById <SysAchievementDailyVo>(this.taskid);
            if (this.achievementDailyVo == null)
            {
                ClientLogger.Warn("daily_id=" + this.taskid + "     在SysAchievementDailyVo中找不到");
            }
            this.name      = this.achievementDailyVo.name;
            this.describe  = this.achievementDailyVo.describe;
            this.parameter = this.achievementDailyVo.parameter.ToString();
            this.icon      = this.achievementDailyVo.icon;
            this.reward    = this.achievementDailyVo.reward;
            this.value     = dailyData.value.ToString();
        }
        this.drop_items   = null;
        this.title.text   = BaseDataMgr.instance.GetLanguageData(this.name).content;
        this.content.text = BaseDataMgr.instance.GetLanguageData(this.describe).content;
        if (Singleton <TaskView> .Instance.coroutineManager == null)
        {
            Singleton <TaskView> .Instance.coroutineManager = new CoroutineManager();
        }
        Singleton <TaskView> .Instance.coroutineManager.StartCoroutine(this.GetDisPlayTexture(BaseDataMgr.instance.GetGameResData(this.icon.Split(new char[]
        {
            '|'
        })[1]).path), true);

        this.numLeft.text  = this.value;
        this.numRight.text = "/" + this.parameter;
        this.rewards       = this.reward.Split(new char[]
        {
            ','
        });
        if (achieveData != null)
        {
            this.drop_items = this.achievement_point + ",";
        }
        for (int i = 0; i < this.rewards.Length; i++)
        {
            if (i != 0)
            {
                this.drop_items += ",";
            }
            if (this.rewards[i] != "[]")
            {
                this.dropRewardsVo = BaseDataMgr.instance.GetDataById <SysDropRewardsVo>(this.rewards[i]);
                this.drop_items   += this.dropRewardsVo.drop_items;
            }
        }
        if (this.drop_items == null)
        {
            this.rewards = new string[0];
        }
        else
        {
            this.rewards = this.drop_items.Split(new char[]
            {
                ','
            });
        }
        this.offX         = 0f;
        this.havaShowItem = false;
        for (int j = 0; j < this.rewardRoot.childCount; j++)
        {
            this.rewardRoot.GetChild(j).gameObject.SetActive(false);
        }
        int k = 0;

        while (k < this.rewards.Length)
        {
            if (Singleton <TaskView> .Instance.taskRewardItem == null)
            {
                Singleton <TaskView> .Instance.taskRewardItem = (Resources.Load("Prefab/UI/Home/TaskRewardItem") as GameObject);
            }
            string[] array = null;
            if (k == 0 && dailyData == null)
            {
                goto IL_4A1;
            }
            this.dropItemsVo = BaseDataMgr.instance.GetDataById <SysDropItemsVo>(this.rewards[k]);
            array            = this.dropItemsVo.rewards.Split(new char[]
            {
                '|'
            });
            if (!this.havaShowItem || (!(array[0] == "2") && !(array[0] == "3")))
            {
                goto IL_4A1;
            }
IL_77B:
            k++;
            continue;
IL_4A1:
            if (k < this.rewardRoot.childCount)
            {
                this.rewarItem = this.rewardRoot.GetChild(k).gameObject;
                this.rewarItem.gameObject.SetActive(true);
            }
            else
            {
                this.rewarItem = NGUITools.AddChild(this.rewardRoot.gameObject, Singleton <TaskView> .Instance.taskRewardItem);
            }
            UISprite component  = this.rewarItem.transform.Find("Icon").GetComponent <UISprite>();
            UILabel  component2 = this.rewarItem.transform.Find("Label").GetComponent <UILabel>();
            this.rewarItem.transform.localPosition = new Vector3(this.offX, 0f, 0f);
            if (k == 0 && achieveData != null)
            {
                component.spriteName = "Achievement_icons_stars";
                component2.text      = "x" + this.rewards[0];
                this.offX           += (float)(component.width + component2.width + 20);
                goto IL_77B;
            }
            if (array == null)
            {
                goto IL_77B;
            }
            if (array[0] == "1")
            {
                if (array[1] == "1")
                {
                    component.spriteName = "Achievement_icons_gold";
                }
                else if (array[1] == "2")
                {
                    component.spriteName = "Achievement_icons_diamond";
                }
                else if (array[1] == "9")
                {
                    component.spriteName = "Achievement_icons_cap";
                }
            }
            else if (array[0] == "2")
            {
                this.havaShowItem    = true;
                component.spriteName = "Achievement_icons_others";
            }
            else if (array[0] == "3")
            {
                this.havaShowItem    = true;
                component.spriteName = "Achievement_icons_others";
            }
            else if (array[0] == "4")
            {
                if (array[1] == "1")
                {
                    component.spriteName = "Achievement_icons_exp_summoner";
                }
                else if (array[1] == "2")
                {
                    component.spriteName = "Achievement_icons_exp_bottle";
                }
            }
            else if (array[0] == "6")
            {
                this.havaShowItem    = true;
                component.spriteName = "Achievement_icons_others";
            }
            if (array.Length >= 3 && array[0] != "2" && array[0] != "3")
            {
                component2.text = "x" + array[2];
            }
            else
            {
                component2.text = "x1";
            }
            this.offX += (float)(component.width + component2.width + 20);
            goto IL_77B;
        }
        bool flag  = (achieveData == null) ? dailyData.isGetAward : achieveData.isGetAward;
        bool flag2 = (achieveData == null) ? dailyData.isComplete : achieveData.isComplete;

        if (flag)
        {
            this.getRewardBtn.gameObject.SetActive(false);
            if (this.achievementDailyVo != null)
            {
                if (this.achievementDailyVo.travel_to == 11)
                {
                    this.finishMark.gameObject.SetActive(false);
                    this.Travel.gameObject.SetActive(true);
                    this.doingMark.gameObject.SetActive(false);
                    this.Travel.name = this.achievementDailyVo.travel_to.ToString();
                    UIEventListener.Get(this.Travel.gameObject).onClick = new UIEventListener.VoidDelegate(this.OnClickTravel);
                }
                else
                {
                    this.finishMark.gameObject.SetActive(true);
                }
            }
            else if (this.achievementTaskVo.travel_to == 11)
            {
                this.finishMark.gameObject.SetActive(false);
                this.Travel.gameObject.SetActive(true);
                this.doingMark.gameObject.SetActive(false);
                this.Travel.name = this.achievementTaskVo.travel_to.ToString();
                UIEventListener.Get(this.Travel.gameObject).onClick = new UIEventListener.VoidDelegate(this.OnClickTravel);
            }
            else
            {
                this.finishMark.gameObject.SetActive(true);
            }
            this.bgRed.SetActive(true);
            this.bgBlue.SetActive(false);
            this.SetColor(true);
        }
        else if (flag2)
        {
            this.getRewardBtn.gameObject.SetActive(true);
            this.finishMark.gameObject.SetActive(false);
            this.bgRed.SetActive(true);
            this.bgBlue.SetActive(false);
            this.SetColor(true);
        }
        else
        {
            this.bgRed.SetActive(false);
            this.bgBlue.SetActive(true);
            if (achieveData != null)
            {
                if (this.achievementTaskVo.travel_to != 0)
                {
                    this.Travel.gameObject.SetActive(true);
                    this.doingMark.gameObject.SetActive(false);
                    this.Travel.name = this.achievementTaskVo.travel_to.ToString();
                    UIEventListener.Get(this.Travel.gameObject).onClick = new UIEventListener.VoidDelegate(this.OnClickTravel);
                }
                else
                {
                    this.doingMark.gameObject.SetActive(true);
                    this.Travel.gameObject.SetActive(false);
                }
            }
            else if (this.achievementDailyVo.travel_to != 0)
            {
                this.Travel.name = this.achievementDailyVo.travel_to.ToString();
                UIEventListener.Get(this.Travel.gameObject).onClick = new UIEventListener.VoidDelegate(this.OnClickTravel);
                this.Travel.gameObject.SetActive(true);
                this.doingMark.gameObject.SetActive(false);
            }
            else
            {
                this.Travel.gameObject.SetActive(false);
                this.doingMark.gameObject.SetActive(true);
            }
            this.SetColor(false);
        }
    }
        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);
        }
    public void Conjure_Impl(string skillId, Units target, Vector3?targetPos, bool isPvp = false)
    {
        Skill skillById = this.self.getSkillById(skillId);

        if (SkillUtility.IsBurnUnitSkill(skillById) && targetPos.HasValue)
        {
            Units touchUnit = ManualControlTarget.GetTouchUnit(targetPos.Value);
            if (touchUnit != null && (touchUnit.GetType() == typeof(Tower) || touchUnit.GetType() == typeof(Home)))
            {
                base.OnSkillFailedBeforeStart(skillById);
                ClientLogger.Warn(string.Concat(new object[]
                {
                    "不能摆蘑菇在这里",
                    touchUnit,
                    "  ",
                    targetPos.Value
                }));
                return;
            }
        }
        if (this.self.CanSkill || skillById.CheckSkillCanUseSpecial)
        {
            if (target == null && !targetPos.HasValue)
            {
                target = this.self.GetAttackTarget();
            }
            skillById.attackTarget   = target;
            skillById.attackPosition = targetPos;
            if (skillById.CheckCondition() && skillById.CheckTargets())
            {
                if (isPvp)
                {
                    UseSkillInfo useSkillInfo = new UseSkillInfo
                    {
                        unitId         = this.self.unique_id,
                        skillId        = skillById.skillMainId,
                        targetUnit     = (!(skillById.attackTarget != null)) ? 0 : skillById.attackTarget.unique_id,
                        targetPosition = (!skillById.attackPosition.HasValue) ? null : MoveController.Vector3ToSVector3(skillById.attackPosition.Value),
                        targetRotate   = this.self.transform.eulerAngles.y
                    };
                    PvpEvent.SendUseSkill(useSkillInfo);
                    this.sendUseSkills[skillId]     = true;
                    this.sendUseSkillTicks[skillId] = DateTime.Now.Ticks;
                    this.self.moveController.clearContinueMovingTarget();
                    if (GlobalSettings.Instance.ClientGoAhead)
                    {
                        List <Units> list = new List <Units>();
                        if (target != null)
                        {
                            list.Add(target);
                        }
                        ActionManager.ReadySkill(new SkillDataKey(useSkillInfo.skillId, skillById.skillLevel, 0), this.self, list, skillById.attackPosition, skillById, false);
                    }
                }
                else
                {
                    this.self.InterruptAction(SkillInterruptType.Initiative);
                    skillById.OnSkillStartCallback             = new Callback <Skill>(base.OnSkillStart);
                    skillById.OnSkillEndCallback               = new Callback <Skill>(base.OnSkillEnd);
                    skillById.OnSkillFailedBeforeStartCallback = new Callback <Skill>(base.OnSkillFailedBeforeStart);
                    skillById.Start();
                    base.currSkill = skillById;
                }
            }
            else
            {
                base.OnSkillFailedBeforeStart(skillById);
            }
        }
    }
 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);
     }
 }