/// <summary>
        /// 创建角色
        /// </summary>
        /// <param name="heroId"></param>
        /// <param name="heroStar"></param>
        /// <returns></returns>
        public HeroInfo CreateHero(int heroId, int heroStar = 1)
        {
            PlayerInfo.SimpleHeroInfo heroInfo = new PlayerInfo.SimpleHeroInfo();
            heroInfo.RoleId    = DateTime.Now.Ticks;
            heroInfo.HeroId    = heroId;
            heroInfo.HeroLevel = PlayerInfo.Level;
            heroInfo.HeroStar  = heroStar;
            HeroEntity heroEntity = HeroDBModel.Instance.Get(heroId);

            heroInfo.SkillInfoList = new List <PlayerInfo.SimpleSkillInfo>();
            string[] skillArr = heroEntity.UesSkill.Split('|');
            for (int i = 0; i < skillArr.Length; i++)
            {
                PlayerInfo.SimpleSkillInfo skillInfo = new PlayerInfo.SimpleSkillInfo();
                skillInfo.SkillId    = skillArr[i].ToInt();
                skillInfo.SkillLevel = 1;
                heroInfo.SkillInfoList.Add(skillInfo);
            }
            HeroInfo info = PrepareHeroInfo(heroInfo);

            info.RoleId = heroInfo.RoleId;
            PlayerInfo.HeroList.Add(heroInfo);
            PlayerInfo.ToJson();
            return(info);
        }
        //在平台上创建英雄
        public void CreateHero(long roleId, Vector2 screenPos)
        {
            HeroInfo info = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (info != null)
            {
                HeroEntity heroEntity = HeroDBModel.Instance.Get(info.HeroID);
                GameObject go         = RoleMgr.Instance.LoadRole(RoleType.Hero, heroEntity.PrefabName);
                RoleCtrl   ctrl       = go.GetComponent <RoleCtrl>();
                ctrl.Init(RoleType.Hero, info, null);
                HeroPlatform platform = GetHeroPlatformByScreenPos(screenPos);
                platform.RefreshRoleId(ctrl.CurRoleInfo.RoleId);
                ctrl.RefreshPlatfrom(platform);
                ctrl.StandOnPlatfrom();
                go.transform.position = platform.transform.TransformPoint(platform.StandPos);
                bool inFoward = ForwardHeroPlatformList.Contains(platform);
                if (inFoward)
                {
                    AddHero(ctrl, true);
                }
                else
                {
                    AddHero(ctrl, false);
                }
                ctrl.OnRoleDestory += OnRoleDestoryCallBack;
                ctrl.OnRoleDie     += OnRoleDieCallBack;
                return;
            }
            Debug.Log("错误:在模拟服务器上找不到持有的英雄信息");
        }
        private HeroInfo PrepareHeroInfo(PlayerInfo.SimpleHeroInfo simpInfo)
        {
            HeroEntity      heroEntity      = HeroDBModel.Instance.Get(simpInfo.HeroId);
            HeroLevelEntity heroLevelEntity = HeroLevelDBModel.Instance.GetList().Find(x => x.Level == simpInfo.HeroLevel);
            JobEntity       jobEntity       = JobDBModel.Instance.Get(heroEntity.Job);
            HeroStarEntity  heroStarEntity  = HeroStarDBModel.Instance.GetList().Find(x => x.Star == simpInfo.HeroStar);

            if (heroLevelEntity != null || heroLevelEntity != null || jobEntity != null || heroStarEntity != null)
            {
                HeroInfo info = new HeroInfo();
                info.RoleId       = simpInfo.RoleId;
                info.RoleNickName = heroEntity.Name;
                info.Level        = heroLevelEntity.Level;
                info.MaxHP        = (int)(heroLevelEntity.Hp * heroEntity.Hp * jobEntity.Hp * heroStarEntity.Hp);
                info.CurrentHP    = info.MaxHP;
                info.PhyAtk       = (int)(heroLevelEntity.PhyAtk * heroEntity.PhyAtk * jobEntity.PhyAtk * heroStarEntity.PhyAtk);
                info.MgicAtk      = (int)(heroLevelEntity.MgicAtk * heroEntity.MgicAtk * jobEntity.MgicAtk * heroStarEntity.MgicAtk);
                info.Cri          = (int)(heroLevelEntity.Cri * heroEntity.Cri * jobEntity.Cri * heroStarEntity.Cri);
                info.CriValue     = (int)(heroLevelEntity.CriValue * heroEntity.CriValue * jobEntity.CriValue * heroStarEntity.CriValue);
                info.PhyDef       = (int)(heroLevelEntity.PhyDef * heroEntity.PhyDef * jobEntity.PhyDef * heroStarEntity.PhyDef);
                info.MgicDef      = (int)((heroLevelEntity.MgicDef * heroEntity.MgicDef * jobEntity.MgicDef * heroStarEntity.MgicDef));
                info.HeroID       = heroEntity.Id;
                info.JobID        = jobEntity.Id;
                info.HeroStar     = simpInfo.HeroStar;
                for (int j = 0; j < simpInfo.SkillInfoList.Count; j++)
                {
                    RoleInfoSkill skillInfo = new RoleInfoSkill();
                    skillInfo.SkillId    = simpInfo.SkillInfoList[j].SkillId;
                    skillInfo.SKillLevel = simpInfo.SkillInfoList[j].SkillLevel;
                    info.SkillList.Add(skillInfo);
                }
                return(info);
            }
            return(null);
        }
        /// <summary>
        /// 更新我获取的卡牌的状态
        /// </summary>
        public void UpdateAllHeroInfo()
        {
            UIAllHeroInfoTransfer t = new UIAllHeroInfoTransfer();

            for (int i = 0; i < Global.HeroInfoList.Count; i++)
            {
                HeroInfo info = Global.HeroInfoList[i];
                if (info == null)
                {
                    Debug.LogError("错啦,全错啦,菜逼!");
                    return;
                }
                UIAllHeroInfoTransfer.UIHeroInfo uinfo = PrepareUIHeroInfo(info);
                long roleId = Global.FightHeroList.Find(x => x == Global.HeroInfoList[i].RoleId);
                if (roleId != 0)
                {
                    uinfo.IsFight = true;
                }
                else
                {
                    uinfo.IsFight = false;
                }
                //配置拥有的所有英雄
                t.HeroInfoList.Add(uinfo);
            }
            ((UIGameSceneView)UISceneCtrl.Instance.CurrentUIScene).SetUI(t);
        }
        private void OnHPChangeCallBcak(ValueChangeType type)
        {
            int totalCurHp = 0;
            int totalMaxHp = 0;

            for (int i = 0; i < Global.FightHeroList.Count; i++)
            {
                HeroInfo info = GameSceneCtrl.Instance.HeroInfoList.Find(x => x.RoleId == Global.FightHeroList[i]);
                totalCurHp += info.CurrentHP;
                totalMaxHp += info.MaxHP;
            }
            //UIPlayerInfoView.Instance.SetHp(totalCurHp, totalMaxHp);
        }
        /// <summary>
        /// 英雄升星
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public HeroInfo UpgradeHeroStart(long roleId)
        {
            PlayerInfo.SimpleHeroInfo simpleHeroInfo = PlayerInfo.HeroList.Find(x => x.RoleId == roleId);
            PlayerInfo.HeroList.Remove(simpleHeroInfo);
            if (simpleHeroInfo.HeroStar < 5)
            {
                simpleHeroInfo.HeroStar++;
            }
            PlayerInfo.HeroList.Add(simpleHeroInfo);
            HeroInfo heroInfo = PrepareHeroInfo(simpleHeroInfo);

            PlayerInfo.ToJson();
            return(heroInfo);
        }
        public List <HeroInfo> GetHeroInfoList()
        {
            if (PlayerInfo == null)
            {
            }
            List <HeroInfo> lst = new List <HeroInfo>();

            for (int i = 0; i < PlayerInfo.HeroList.Count; i++)
            {
                HeroInfo info = PrepareHeroInfo(PlayerInfo.HeroList[i]);
                if (info != null)
                {
                    lst.Add(info);
                }
            }
            return(lst);
        }
 public void ShowDragHeroItem(int heroId)
 {
     if (m_DragHeroView == null)
     {
         GameObject DragHeroItem = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.UIWindowChild, "DragHeroItem");
         DragHeroItem.transform.SetParent(UISceneCtrl.Instance.CurrentUIScene.MainCanvans.transform);
         DragHeroItem.transform.localScale = Vector3.one;
         m_DragHeroView = DragHeroItem.GetComponent <UIDragHeroView>();
         HeroInfo info = Global.HeroInfoList.Find(x => x.HeroID == heroId);
         if (info == null)
         {
             Debug.LogError("错啦,全错啦,菜逼!");
             return;
         }
         UIAllHeroInfoTransfer.UIHeroInfo uinfo = PrepareUIHeroInfo(info);
         m_DragHeroView.SetUI(uinfo.HeroIcon, uinfo.AttackArea, uinfo.AttackRange, uinfo.JobIcon, uinfo.HeroName);
     }
     m_DragHeroView.gameObject.SetActive(true);
 }
        private UIAllHeroInfoTransfer.UIHeroInfo PrepareUIHeroInfo(HeroInfo info)
        {
            UIAllHeroInfoTransfer.UIHeroInfo uinfo = new UIAllHeroInfoTransfer.UIHeroInfo();

            uinfo.RoleId = info.RoleId;
            uinfo.HeroId = info.HeroID;
            HeroEntity heroEntity = HeroDBModel.Instance.Get(uinfo.HeroId);

            uinfo.HeroIcon = heroEntity.HeadPic;
            uinfo.HeroName = heroEntity.Name;
            SkillEntity skillEntity = SkillDBModel.Instance.Get(info.SkillList[0].SkillId);

            uinfo.AttackArea  = skillEntity.AttackArea;
            uinfo.AttackRange = skillEntity.AttackRange;
            JobEntity jobEntity = JobDBModel.Instance.Get(heroEntity.Job);

            uinfo.JobIcon = jobEntity.Icon;

            return(uinfo);
        }
Ejemplo n.º 10
0
        private void OnClickHeroUpgradeStarCallBack(object[] p)
        {
            long     roleId   = (long)p[0];
            HeroInfo heroInfo = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (heroInfo == null)
            {
                Debug.LogError("错误:没有英雄信息");
                return;
            }
            if (heroInfo.HeroStar >= 5)
            {
                //提示
                //TODO
                Debug.Log("此英雄已经是最高星级");
                return;
            }
            HeroStarEntity heroStarEntity = HeroStarDBModel.Instance.GetList().Find((x) => x.Star == heroInfo.HeroStar);

            if (heroStarEntity == null)
            {
                Debug.LogError("错误:找不到英雄星级实体");
                return;
            }
            if (SimulatedDatabase.Instance.GetDebris() >= heroStarEntity.NeedHeroDebris)
            {
                SimulatedDatabase.Instance.UpgradeHeroStart(roleId);
                SimulatedDatabase.Instance.ReduceDebris(heroStarEntity.NeedHeroDebris);
                DataTransfer data = GetHeroInfoData(roleId);
                if (data != null)
                {
                    m_HeroInfoView.RefreshAfterUpgradeStar(data);
                }
            }
            else
            {
                //提示
                //TODO
                Debug.Log("英雄残魂不够");
            }
        }
Ejemplo n.º 11
0
        //开始技能拖拽
        private void OnBeginDragTheSkillCallBack(object[] p)
        {
            long    roleId  = (long)p[0];
            Vector2 rolePos = (Vector3)p[1];
            Vector2 minPos  = Vector2.zero;
            float   minDis  = Mathf.Infinity;

            //从第一列中找最近的点
            for (int i = 0; i < GridManager.Instance.NumOfRow; i++)
            {
                Node  n   = GridManager.Instance.GetNode(i, 0);
                float dis = Vector2.Distance(rolePos, n.Position);
                if (dis < minDis)
                {
                    minDis = dis;
                    minPos = n.Position;
                }
            }
            if (m_DragSkillItem == null)
            {
                m_DragSkillItem = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Scene, "Items/DragSkillItem").GetComponent <DragSkillItem>();
                m_DragSkillItem.transform.SetParent(null);
                m_DragSkillItem.transform.localScale = Vector3.one;
            }
            m_DragSkillStartRelaticvePos       = minPos - rolePos;
            m_DragSkillItem.transform.position = minPos;
            RoleCtrl role = GameSceneCtrl.Instance.GetHero(roleId);

            if (role == null)
            {
                Debug.LogError("错误:");
                return;
            }
            HeroInfo heroInfo = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            SkillEntity skillEntity = SkillDBModel.Instance.Get((role.IsRage ? heroInfo.SkillList[1] : heroInfo.SkillList[0]).SkillId);

            m_DragSkillItem.Init(role, skillEntity.AttackArea, skillEntity.AttackRange);
        }
Ejemplo n.º 12
0
        private DataTransfer GetHeroInfoData(long roldID)
        {
            long       roleId = roldID;
            GameObject go     = UIViewUtil.Instance.OpenWindow(UIViewType.HeroInfoView);

            m_HeroInfoView = go.GetComponent <UIHeroInfoView>();
            if (m_HeroInfoView == null)
            {
                Debug.LogError("错误:没有这个界面");
                return(null);
            }
            HeroInfo heroInfo = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (heroInfo == null)
            {
                Debug.LogError("错误:没有英雄信息");
                return(null);
            }
            HeroEntity heroEntity = HeroDBModel.Instance.Get(heroInfo.HeroID);

            if (heroEntity == null)
            {
                Debug.LogError("错误:找不到英雄实体");
                return(null);
            }
            string heroName    = heroInfo.RoleNickName;
            int    heroStar    = heroInfo.HeroStar;
            int    heroQuality = heroEntity.Quality;
            int    heroLevel   = SimulatedDatabase.Instance.GetLevel();
            int    hp          = heroInfo.MaxHP;
            int    mgicAtk     = heroInfo.MgicAtk;
            int    phyAtk      = heroInfo.PhyAtk;
            int    cri         = heroInfo.Cri;
            float  criValue    = heroInfo.CriValue;
            int    phyDef      = heroInfo.PhyDef;
            int    mgicDef     = heroInfo.MgicDef;

            DataTransfer data = new DataTransfer();

            data.SetData(ConstDefine.UI_HeroInfo_RoleId, roleId);
            data.SetData(ConstDefine.UI_HeroInfo_HeroName, heroName);
            data.SetData(ConstDefine.UI_HeroInfo_HeroStar, heroStar);
            data.SetData(ConstDefine.UI_HeroInfo_HeroQuality, heroQuality);
            data.SetData(ConstDefine.UI_HeroInfo_HeroLevel, heroLevel);

            data.SetData(ConstDefine.UI_HeroInfo_HeroHp, hp);
            data.SetData(ConstDefine.UI_HeroInfo_MgicAtk, mgicAtk);
            data.SetData(ConstDefine.UI_HeroInfo_PhyAtk, phyAtk);
            data.SetData(ConstDefine.UI_HeroInfo_Cri, cri);
            data.SetData(ConstDefine.UI_HeroInfo_CriValue, criValue);
            data.SetData(ConstDefine.UI_HeroInfo_PhyDef, phyDef);
            data.SetData(ConstDefine.UI_HeroInfo_MgicDef, mgicDef);

            List <DataTransfer> skillDatas = new List <DataTransfer>();

            for (int i = 0; i < heroInfo.SkillList.Count; i++)
            {
                DataTransfer skillData   = new DataTransfer();
                SkillEntity  skillEntity = SkillDBModel.Instance.Get(heroInfo.SkillList[i].SkillId);
                skillData.SetData(ConstDefine.UI_HeroInfo_SkillName, skillEntity.SkillName);
                string skillIcno = Global.Instance.GetSkillIconByRanggeAndType(skillEntity.AttackRange, skillEntity.AttackArea);
                skillData.SetData(ConstDefine.UI_HeroInfo_SkillIcon, skillIcno);
                skillData.SetData(ConstDefine.UI_HeroInfo_SkillDesc, skillEntity.SkillDesc);
                skillDatas.Add(skillData);
            }
            data.SetData(ConstDefine.UI_HeroInfo_SkillContent, skillDatas);

            HeroStarEntity heroStarEntity = HeroStarDBModel.Instance.GetList().Find((x) => x.Star == heroStar);

            data.SetData(ConstDefine.UI_HeroInfo_NeedDebris, heroStarEntity.NeedHeroDebris);
            data.SetData(ConstDefine.UI_HeroInfo_OwnedDebris, SimulatedDatabase.Instance.GetDebris());
            return(data);
        }
Ejemplo n.º 13
0
        private SummonInfoTransfer Summon()
        {
            ConfigEntity      configEntity = ConfigDBModel.Instance.GetList()[0];
            float             randomRange  = UnityEngine.Random.Range(0, 1f);
            List <HeroEntity> heroList     = null;
            HeroInfo          info         = null;
            HeroEntity        heroEntity   = null;
            int heroStar = 1;

            if (randomRange <= configEntity.TheProbabilityOfLegendHero)
            {
                //抽取传奇英雄
                heroStar = 3;
                heroList = HeroDBModel.Instance.GetList().FindAll(x => x.Quality == 2);
            }
            else if (randomRange <= configEntity.TheProbabilityOfLegendHero + configEntity.TheProbabilityOfeliteHero)
            {
                //抽取精英英雄
                heroStar = 2;
                heroList = HeroDBModel.Instance.GetList().FindAll(x => x.Quality == 1);
            }
            else if (randomRange <= configEntity.TheProbabilityOfLegendHero + configEntity.TheProbabilityOfeliteHero + configEntity.TheProbabilityOfNormalHero)
            {
                //抽取普通英雄
                heroList = HeroDBModel.Instance.GetList().FindAll(x => x.Quality == 0);
            }
            else
            {
                Debug.LogError("错误:配置表填错了");
                return(SummonInfoTransfer.Empty());
            }
            if (heroList.Count > 0)
            {
                heroEntity = heroList[UnityEngine.Random.Range(0, heroList.Count)];
            }
            else
            {
                Debug.Log("没有英雄哦");
                return(SummonInfoTransfer.Empty());
            }

            SummonInfoTransfer transfer = new SummonInfoTransfer();

            //有没有这个英雄
            if (Global.HeroInfoList.Find(x => x.HeroID == heroEntity.Id) != null)
            {
                transfer.IsDebris = true;
                if (heroEntity.Quality == 0)
                {
                    transfer.DebrisCount = configEntity.TheDebrisOfNormalHero;
                }
                else if (heroEntity.Quality == 1)
                {
                    transfer.DebrisCount = configEntity.TheDebrisOfEliteHero;
                }
                else if (heroEntity.Quality == 2)
                {
                    transfer.DebrisCount = configEntity.TheDebrisOfLegendHero;
                }
                SimulatedDatabase.Instance.AddDebris(transfer.DebrisCount);
            }
            else
            {
                info = SimulatedDatabase.Instance.CreateHero(heroEntity.Id, heroStar);
                transfer.IsDebris = false;
            }
            transfer.NickName = heroEntity.Name;
            transfer.Quality  = heroEntity.Quality;
            transfer.HeroPic  = heroEntity.RolePic;
            return(transfer);
        }
Ejemplo n.º 14
0
        //显示英雄简介
        private void ShowHeroIntro(long roleId)
        {
            if (m_HeroIntroView == null)
            {
                GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.UIWindowChild, "HeroIntro");
                m_HeroIntroView = go.GetComponent <UIHeroIntroView>();
                go.transform.SetParent(UISceneCtrl.Instance.CurrentUIScene.MainCanvans.transform);
                go.transform.localScale    = Vector3.one;
                go.transform.localPosition = Vector3.zero;
            }
            m_HeroIntroView.gameObject.SetActive(true);
            DataTransfer data     = new DataTransfer();
            HeroInfo     heroInfo = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (heroInfo != null)
            {
                if (heroInfo != null)
                {
                    HeroEntity heroEntity = HeroDBModel.Instance.Get(heroInfo.HeroID);
                    data.SetData <string>("HeroName", heroEntity.Name);
                    data.SetData <string>("HeroDesc", heroEntity.Desc);
                    for (int i = 0; i < heroInfo.SkillList.Count; i++)
                    {
                        SkillEntity skill1Entity = SkillDBModel.Instance.Get(heroInfo.SkillList[i].SkillId);
                        data.SetData <string>("Skill" + (i + 1) + "Name", skill1Entity.SkillName);
                        data.SetData <string>("Skill" + (i + 1) + "Desc", skill1Entity.SkillDesc);
                    }
                }
            }
            else
            {
                //敌人
                RoleInfoBase monsterInfo = GameSceneCtrl.Instance.MonsterList.Find(x => x.CurRoleInfo.RoleId == roleId).CurRoleInfo;
                if (monsterInfo != null)
                {
                    SpriteEntity spriteEntity = SpriteDBModel.Instance.GetList().Find(x => x == ((MonsterInfo)monsterInfo).SpriteEntity);
                    if (spriteEntity == null)
                    {
                        Debug.LogError("错误:找不到精灵实体,请查看是否有没有赋值,或者GameSceneCtrl的MonsterList 移除,添加出错了");
                        return;
                    }
                    else
                    {
                        data.SetData <string>("HeroName", spriteEntity.Name);
                        data.SetData <string>("HeroDesc", "");
                        for (int j = 0; j < ((MonsterInfo)monsterInfo).GetSkillList().Count; j++)
                        {
                            SkillEntity skill1Entity = SkillDBModel.Instance.Get(((MonsterInfo)monsterInfo).GetSkillList()[j]);
                            data.SetData <string>("Skill" + (j + 1) + "Name", skill1Entity.SkillName);
                            data.SetData <string>("Skill" + (j + 1) + "Desc", skill1Entity.SkillDesc);
                        }
                    }
                }
                else
                {
                    Debug.Log("错误:没找到英雄信息");
                    return;
                }
            }
            m_HeroIntroView.SetUI(data);
        }
Ejemplo n.º 15
0
 public HeroAI(RoleCtrl roleCtrl, HeroInfo info)
 {
     CurRoleCtrl = roleCtrl;
     RoleInfo    = info;
 }