Exemplo n.º 1
0
    private void OnAccountLogOnResponse(byte[] buffer)
    {
        AccountLogOnResponseProto proto = AccountLogOnResponseProto.GetProto(buffer);

        if (!proto.IsSuccess)
        {
            TipsUtil.ShowTextTips(1000111);
        }
        else
        {
            //登录成功
            //TipsUtil.ShowTextTips("用户编号 = " + proto.UserId);
            if (m_LogOnWindow != null)
            {
                Stat.LogOn(proto.UserId, m_LogOnWindow.IFAccount.text);
                PlayerPrefsUtil.SetAccountID(proto.UserId);
                PlayerPrefsUtil.SetAccountUserName(m_LogOnWindow.IFAccount.text);
                PlayerPrefsUtil.SetAccountPwd(m_LogOnWindow.IFPwd.text);
                m_LogOnWindow.CloseAndOpenNext(Window.GameServerEnter);
            }
            else
            {
                Stat.Register(proto.UserId, PlayerPrefsUtil.GetAccountUserName());
                WindowManager.Instance.OpenWindow(Window.GameServerEnter);
            }
            GlobalInit.Instance.AccountId       = proto.UserId;
            GlobalInit.Instance.AccountUserName = PlayerPrefsUtil.GetAccountUserName();
        }
    }
Exemplo n.º 2
0
 /// <summary> 开始游戏回调 </summary>
 private void OnBtnBeginGameClick()
 {
     if (m_IsSelectRoleView)
     {
         RoleCreateRequestProto proto = new RoleCreateRequestProto();
         proto.JobId    = (byte)m_SelectJobId;
         proto.RoleName = m_SelectRoleView.IFNickName.text;
         if (string.IsNullOrEmpty(proto.RoleName))
         {
             TipsUtil.ShowTextTips(1000306);
             return;
         }
         NetWorkSocket.Instance.SendMsg(proto.ToArray());
     }
     else
     {
         if (!m_IsHaveRole)
         {
             RoleCreateRequestProto proto = new RoleCreateRequestProto();
             proto.JobId    = (byte)m_SelectJobId;
             proto.RoleName = m_SelectRoleView.IFNickName.text;
             if (string.IsNullOrEmpty(proto.RoleName))
             {
                 TipsUtil.ShowTextTips(1000306);
                 return;
             }
             NetWorkSocket.Instance.SendMsg(proto.ToArray());
         }
         else
         {
             EnterGame();
         }
     }
 }
Exemplo n.º 3
0
    private void OnRegisterClick(object[] param)
    {
        if (m_RegisterWindow != null)
        {
            if (string.IsNullOrEmpty(m_RegisterWindow.IFAccount.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000101), LanguageUtil.GetStrById(1000110));
                return;
            }
            if (string.IsNullOrEmpty(m_RegisterWindow.IFPwd.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000102), LanguageUtil.GetStrById(1000110));
                return;
            }
            if (string.IsNullOrEmpty(m_RegisterWindow.IFAgainPwd.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000103), LanguageUtil.GetStrById(1000110));
                return;
            }
            if (!string.Equals(m_RegisterWindow.IFPwd.text, m_RegisterWindow.IFAgainPwd.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000104), LanguageUtil.GetStrById(1000110));
                return;
            }
        }
        AccountRegisterRequestProto proto = new AccountRegisterRequestProto();

        proto.Account          = m_RegisterWindow.IFAccount.text;
        proto.Pwd              = m_RegisterWindow.IFPwd.text;
        proto.Channel          = "0";
        proto.DeviceIdentifier = DeviceUtil.DeviceIdentifier;
        proto.DeviceModel      = DeviceUtil.DeviceModel;
        NetWorkSocket.Instance.SendMsg(proto.ToArray());
    }
Exemplo n.º 4
0
    private void OnGameEnterResponse(byte[] buffer)
    {
        GameLevelEnterResponseProto proto = GameLevelEnterResponseProto.GetProto(buffer);

        Debuger.LogError("proto.Issuccess = " + proto.IsSuccess);
        if (proto.IsSuccess)
        {
            SceneMgr.Instance.LoadToWorldMap(m_WordMapId);
        }
        else
        {
            TipsUtil.ShowTextTips(string.Format(StringUtil.GetStringById(proto.MsgCode), m_WordMapId));
        }
    }
Exemplo n.º 5
0
    private void OnRoleCreateResponse(byte[] buffer)
    {
        RoleCreateResponseProto proto = RoleCreateResponseProto.GetProto(buffer);

        if (proto.IsSuccess)
        {
            Debuger.Log("创建成功");
            LogOnGameServer();
        }
        else
        {
            TipsUtil.ShowTextTips(proto.MsgCode);
        }
    }
Exemplo n.º 6
0
    /// <summary> 服务器返回角色信息 </summary>
    /// <param name="buffer"></param>
    private void OnRoleInfoResponse(byte[] buffer)
    {
        RoleInfoResponseProto proto = RoleInfoResponseProto.GetProto(buffer);

        if (proto.IsSuccess)
        {
            GlobalInit.Instance.PlayerInfo = new RoleInfoMainPlayer(proto);
            Debuger.LogError("GlobalInit.Instance.PlayerInfo.level = " + GlobalInit.Instance.PlayerInfo.Level);
            m_LastInWorldMapId = proto.LastInWorldMapId;
        }
        else
        {
            TipsUtil.ShowTextTips(proto.MsgCode);
        }
    }
Exemplo n.º 7
0
    private void OnPhyAttack()
    {
        if (GlobalInit.Instance.SkillSlotsItem != null)
        {
            GlobalInit.Instance.SkillSlotsItem = null;
        }
        if (GlobalInit.Instance.CurrPlayer.IsRigidity)
        {
            //技能施放中
            TipsUtil.ShowTextTips(1000503);
            return;
        }
        int[] phyIdArray = JobDBModel.Instance.Get(GlobalInit.Instance.PlayerInfo.JobId).PhyAttackIdArray;
        int   id         = UnityEngine.Random.Range(phyIdArray[0], phyIdArray[phyIdArray.Length - 1]);

        GlobalInit.Instance.CurrPlayer.ToAttack(RoleAttackType.PhyAttack, id);
    }
Exemplo n.º 8
0
 private void OnMenuIconClickCallBack(string openWindowName)
 {
     Debuger.Log("需要打开" + openWindowName + "界面");
     switch (openWindowName)
     {
     case Window.GameLevelDetail:
         return;
     }
     if (openWindowName == "Pan_Tips")
     {
         TipsUtil.ShowWindowTips("需要打开" + openWindowName + "界面");
     }
     else
     {
         WindowManager.Instance.OpenWindow(openWindowName);
     }
 }
Exemplo n.º 9
0
    /// <summary> 单服点击回调 </summary>
    /// <param name="index"></param>
    private void OnRightCallBack(int index)
    {
        RightGameServerItem item = m_RightItemList[index];

        if (item.ServerState == 0 || item.ServerState > 3)
        {
            TipsUtil.ShowTextTips(StringUtil.GetStringById(1000205));
        }
        else
        {
            UpdateWin(item);
            m_GameServerEnterWin.ServerSelectWin.DOPlayBackwards();
            //m_GameServerEnterWin.NowServerText.text = item.ServerName;
            //m_GameServerEnterWin.Status.sprite = AssetBundleManager.Instance.LoadSprite("Login", "YanChi0"+item.ServerState);
            //m_GameServerEnterWin.ChangeText.text = StringUtil.RichString(1000202);
            //m_IsShowSelectWin = false;
            //m_GameServerEnterWin.Logo.SetActive(true);
        }
    }
Exemplo n.º 10
0
    private void LogOn(string userName, string pwd)
    {
        if (m_LogOnWindow != null)
        {
            if (string.IsNullOrEmpty(m_LogOnWindow.IFAccount.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000101), LanguageUtil.GetStrById(1000109));
                return;
            }
            if (string.IsNullOrEmpty(m_LogOnWindow.IFPwd.text))
            {
                TipsUtil.ShowWindowTips(LanguageUtil.GetStrById(1000102), LanguageUtil.GetStrById(1000109));
                return;
            }
        }
        AccountLogOnRequestProto proto = new AccountLogOnRequestProto();

        proto.UserName         = userName;
        proto.Pwd              = pwd;
        proto.DeviceIdentifier = DeviceUtil.DeviceIdentifier;
        proto.DeviceModel      = DeviceUtil.DeviceModel;
        NetWorkSocket.Instance.SendMsg(proto.ToArray());
    }
Exemplo n.º 11
0
 protected virtual void OnUpdate()
 {
     if (Input.GetKeyDown(KeyCode.E))
     {
         TipsUtil.ShowExpTips(10000);
     }
     if (Input.GetKeyDown(KeyCode.C))
     {
         TipsUtil.ShowCoinTips(10000);
     }
     if (Input.GetKeyDown(KeyCode.T))
     {
         TipsUtil.ShowTextTips("世事如棋 乾坤莫测");
     }
     if (Input.GetKeyDown(KeyCode.G))
     {
         TipsUtil.ShowGoldTips(666666);
     }
     if (Input.GetKeyDown(KeyCode.B))
     {
         TipsUtil.ShowGoldBindingTips(888888);
     }
 }
Exemplo n.º 12
0
 private void ToSkillAttack(UISkillSlotsItem item)
 {
     //if (GlobalInit.Instance.CurrPlayer.IsRigidity)
     //{
     //技能施放中
     //TipsUtil.ShowTextTips(1000503);
     //return;
     //}
     if (!item.IsActive)
     {
         SceneMgr.Instance.LoadToWorldMap(PlayerCtrl.Instance.LastInWorldMapId);
         //技能未开启
         TipsUtil.ShowTextTips(1000502);
         return;
     }
     if (item.LeftTime > 0)
     {
         //技能冷却中
         TipsUtil.ShowTextTips(1000501);
         return;
     }
     GlobalInit.Instance.SkillSlotsItem = item;
     GlobalInit.Instance.CurrPlayer.ToAttack(RoleAttackType.SkillAttack, item.SkillId);
 }
Exemplo n.º 13
0
    private void OnRoleDieCallBack(RoleCtrl ctrl)
    {
        GameLevelMonsterEntity entity = ((RoleInfoMonster)ctrl.CurrRoleInfo).GameLevelMonsterEntity;

        TipsUtil.ShowExpTips(entity.DropExp);
        TipsUtil.ShowCoinTips(entity.DropCoin);
        m_DropExp  += entity.DropExp;
        m_DropCoin += entity.DropCoin;
        m_CurrRegionKillMonsterCount++;
        //掉落装备/材料
        int equipNum = UnityEngine.Random.Range(1, 101);

        if (equipNum > 50)
        {
            int tempNum = UnityEngine.Random.Range(1, 101);
            int equipId = 0;
            if (tempNum < 35)
            {
                equipId = entity.DropEquip[0][0].ToInt();
            }
            else if (tempNum < 60)
            {
                equipId = entity.DropEquip[1][0].ToInt();
            }
            else if (tempNum < 80)
            {
                equipId = entity.DropEquip[2][0].ToInt();
            }
            else if (tempNum < 95)
            {
                equipId = entity.DropEquip[3][0].ToInt();
            }
            else
            {
                equipId = entity.DropEquip[4][0].ToInt();
            }
            //掉落装备
            //Debuger.Log("掉落装备Id = " + equipId);
            GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem();
            item.GoodsType  = 1;
            item.GoodsCount = 1;
            item.GoodsId    = equipId;
            m_DropGoodsList.Add(item);
        }
        int matNum = UnityEngine.Random.Range(1, 101);

        if (matNum > 50)
        {
            int tempNum2 = UnityEngine.Random.Range(1, 101);
            int matId    = 0;
            if (tempNum2 < 35)
            {
                matId = entity.DropMaterial[0][0].ToInt();
            }
            else if (tempNum2 < 60)
            {
                matId = entity.DropMaterial[1][0].ToInt();
            }
            else if (tempNum2 < 80)
            {
                matId = entity.DropMaterial[2][0].ToInt();
            }
            else if (tempNum2 < 95)
            {
                matId = entity.DropMaterial[3][0].ToInt();
            }
            else
            {
                matId = entity.DropMaterial[4][0].ToInt();
            }
            //掉落材料
            //Debuger.LogError("掉落材料Id = " + matId);
            bool isHaveMat = false;
            for (int i = 0; i < m_DropGoodsList.Count; i++)
            {
                if (m_DropGoodsList[i].GoodsId == matId)
                {
                    isHaveMat = true;
                    GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem();
                    item.GoodsType     = m_DropGoodsList[i].GoodsType;
                    item.GoodsId       = m_DropGoodsList[i].GoodsId;
                    item.GoodsCount    = m_DropGoodsList[i].GoodsCount + 1;
                    m_DropGoodsList[i] = item;
                    break;
                }
            }
            if (!isHaveMat)
            {
                GameLevelSuccessRequestProto.GoodsItem item = new GameLevelSuccessRequestProto.GoodsItem();
                item.GoodsType  = 2;
                item.GoodsCount = 1;
                item.GoodsId    = matId;
                m_DropGoodsList.Add(item);
            }
        }

        if (m_CurrRegionKillMonsterCount >= m_CurrRegionMonsterCount)
        {
            if (m_CurrRegionIndex < m_Region.Length - 1)
            {
                //进入下一区域
                m_CurrRegionIndex++;
                EnterRegion(m_CurrRegionIndex);
            }
            else
            {
                m_IsFighting = false;
                GameLevelCtrl.Instance.Result   = 1;
                GameLevelCtrl.Instance.UseTime  = m_UseTime;
                GameLevelCtrl.Instance.DropExp  = m_DropExp;
                GameLevelCtrl.Instance.DropCoin = m_DropCoin;
                //最后一击播放慢动画
                TimeManager.Instance.ChangeTimeScale(0.3f, 5f, OpenFightResultWindow);
                //战斗胜利
                Debug.Log("战斗胜利");
            }
        }
    }
Exemplo n.º 14
0
    public void ToAttack(RoleAttackType type, int skillId)
    {
        if (m_CurrRoleFSMMgr == null || m_CurrRoleFSMMgr.CurrRoleCtrl.IsRigidity)
        {
            if (type == RoleAttackType.SkillAttack)
            {
                m_NextSkillId = skillId;
            }
            return;
        }
        m_NextSkillId = -1;
        //1.角色类型只有玩家和怪才参与技能数值计算

        if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer || m_CurrRoleCtrl.CurrRoleType == RoleType.Monster)
        {
            //2.获取技能信息
            SkillEntity skillEntity = SkillDBModel.Instance.Get(skillId);
            if (skillEntity == null)
            {
                return;
            }
            int skillLevel = m_CurrRoleCtrl.CurrRoleInfo.GetSkillLevel(skillId);
            //技能所需魔法值
            int spendMP = skillEntity.SpendMP + skillEntity.SpendMPLevelUp * (skillLevel - 1);
            //3.如果是主角
            if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer && type == RoleAttackType.SkillAttack)
            {
                if (GlobalInit.Instance.SkillSlotsItem != null)
                {
                    if (spendMP > GlobalInit.Instance.PlayerInfo.CurrMP)
                    {
                        TipsUtil.ShowTextTips(1000504);
                        return;
                    }
                    GlobalInit.Instance.PlayerInfo.CurrMP -= spendMP;
                    GlobalInit.Instance.PlayerInfo.SetSkillCDEndTime(skillId);
                    if (m_CurrRoleCtrl.OnMPChange != null)
                    {
                        m_CurrRoleCtrl.OnMPChange(ValueChnageType.Reduce);
                    }
                    GlobalInit.Instance.SkillSlotsItem.AddTimer();
                    GlobalInit.Instance.SkillSlotsItem = null;
                }
            }
            m_EnemyList.Clear();
            //4.找敌人 如果是主角才找敌人 怪找敌人使用AI
            if (m_CurrRoleCtrl.CurrRoleType == RoleType.MainPlayer)
            {
                int attackTargetCount = skillEntity.AttackTargetCount;
                if (attackTargetCount == 1)
                {
                    #region ------ 单体攻击 ------
                    //单体攻击 必须有锁定敌人
                    if (m_CurrRoleCtrl.LockEnemy != null)
                    {
                        m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy);
                    }
                    else
                    {
                        m_SearchList.Clear();
                        //没有锁定敌人
                        //发射射线去找 离当前攻击者最近的 就是锁定敌人
                        Collider[] searchList = Physics.OverlapSphere(m_CurrRoleCtrl.transform.position, skillEntity.AreaAttackRadius, 1 << LayerMask.NameToLayer("Role"));
                        if (searchList != null && searchList.Length > 0)
                        {
                            for (int i = 0; i < searchList.Length; i++)
                            {
                                if (searchList[i].GetComponent <RoleCtrl>().CurrRoleType != RoleType.MainPlayer)
                                {
                                    m_SearchList.Add(searchList[i]);
                                }
                            }
                        }
                        m_SearchList.Sort((c1, c2) =>
                        {
                            int ret = 0;
                            if (Vector3.Distance(c1.transform.position, m_CurrRoleCtrl.transform.position) <
                                Vector3.Distance(c2.transform.position, m_CurrRoleCtrl.transform.position))
                            {
                                ret = -1;
                            }
                            else
                            {
                                ret = 1;
                            }
                            return(ret);
                        });
                        if (m_SearchList.Count > 0)
                        {
                            m_CurrRoleCtrl.LockEnemy = m_SearchList[0].GetComponent <RoleCtrl>();
                            m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy);
                        }
                    }
                    #endregion
                }
                else
                {
                    #region ------ 群体攻击 ------

                    int needAttackCount = attackTargetCount;
                    m_SearchList.Clear();
                    //没有锁定敌人
                    //发射射线去找 离当前攻击者最近的 就是锁定敌人
                    Collider[] searchList = Physics.OverlapSphere(m_CurrRoleCtrl.transform.position, skillEntity.AreaAttackRadius, 1 << LayerMask.NameToLayer("Role"));
                    if (searchList != null && searchList.Length > 0)
                    {
                        for (int i = 0; i < searchList.Length; i++)
                        {
                            if (searchList[i].GetComponent <RoleCtrl>().CurrRoleType != RoleType.MainPlayer)
                            {
                                m_SearchList.Add(searchList[i]);
                            }
                        }
                    }
                    m_SearchList.Sort((c1, c2) =>
                    {
                        int ret = 0;
                        if (Vector3.Distance(c1.transform.position, m_CurrRoleCtrl.transform.position) <
                            Vector3.Distance(c2.transform.position, m_CurrRoleCtrl.transform.position))
                        {
                            ret = -1;
                        }
                        else
                        {
                            ret = 1;
                        }
                        return(ret);
                    });

                    //群体攻击 如果有锁定敌人 锁定敌人必须是攻击目标之一
                    if (m_CurrRoleCtrl.LockEnemy != null)
                    {
                        m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy);
                        needAttackCount--;
                        for (int i = 0; i < m_SearchList.Count; i++)
                        {
                            RoleCtrl ctrl = m_SearchList[i].GetComponent <RoleCtrl>();
                            if (ctrl.CurrRoleInfo.RoleId != m_CurrRoleCtrl.CurrRoleInfo.RoleId)
                            {
                                if ((i + 1) > needAttackCount)
                                {
                                    break;
                                }
                                m_EnemyList.Add(m_SearchList[i].GetComponent <RoleCtrl>());
                            }
                        }
                    }
                    else
                    {
                        if (m_SearchList.Count > 0)
                        {
                            m_CurrRoleCtrl.LockEnemy = m_SearchList[0].GetComponent <RoleCtrl>();
                            for (int i = 0; i < m_SearchList.Count; i++)
                            {
                                RoleCtrl ctrl = m_SearchList[i].GetComponent <RoleCtrl>();
                                if ((i + 1) > needAttackCount)
                                {
                                    break;
                                }
                                m_EnemyList.Add(ctrl);
                            }
                        }
                    }


                    #endregion
                }
            }
            else if (m_CurrRoleCtrl.CurrRoleType == RoleType.Monster)
            {
                if (m_CurrRoleCtrl.LockEnemy != null)
                {
                    m_EnemyList.Add(m_CurrRoleCtrl.LockEnemy);
                }
            }
            //Debug.Log(m_EnemyList.Count);
            //5.让敌人受伤
            for (int i = 0; i < m_EnemyList.Count; i++)
            {
                m_EnemyList[i].ToHurt(CalculateHurtValue(m_EnemyList[i], skillEntity));
            }
        }

        #region ------ 动画特效相关 ------
        RoleAttackInfo info = GetRoleAttackInfo(type, skillId);
        if (info == null)
        {
            return;
        }

        GlobalInit.Instance.StartCoroutine(PlayerEffect(info));
        //EffectManager.Instance.DestroyEffect(trans, info.EffectLifeTime);
        //if (info.IsDoCameraShake && CameraCtrl.Instance != null)
        //{
        //    CameraCtrl.Instance.CameraShake(info.CameraShakeDelay);
        //}

        if (m_RoleStateAttack == null)
        {
            m_RoleStateAttack = m_CurrRoleFSMMgr.GetRoleState(RoleState.Attack) as RoleStateAttack;
        }

        m_RoleStateAttack.AnimatorCondition      = type == RoleAttackType.PhyAttack ? "ToPhyAttack" : "ToSkill";
        m_RoleStateAttack.AnimatorConditionValue = info.Index;
        m_RoleStateAttack.AnimatorCurrState      = GameUtil.GetRoleAnimatorState(type, info.Index);

        #endregion

        m_CurrRoleFSMMgr.ChangeState(RoleState.Attack);
    }