/// <summary>
 /// 预先判断该武将是否会被打死
 /// </summary>
 /// <param name="attackHero">进攻方数据</param>
 /// <param name="hurtHero">被攻击方数据</param>
 /// <returns></returns>
 public static bool checkRoleDead(HeroVo attackHero, HeroVo hurtHero)
 {
     int damage = DamageUtils.mathDamage(attackHero, hurtHero);
     hurtHero.tempHp -= damage;
     if (hurtHero.tempHp < 0) hurtHero.tempHp = 0;
     return (bool)(hurtHero.tempHp <= 0);
 }
 static public void SetHeroVo(GC_HeroData data, HeroVo vo)
 {
     vo.guid         = data.Guid;
     vo.marchId      = data.MarchId;
     vo.type         = data.Type;
     vo.level        = data.Level;
     vo.state        = data.State;
     vo.health       = data.Hp;
     vo.mana         = data.Mp;
     vo.arrangeIndex = data.Arrangeindex;
     vo.skillIdList.Clear();
     for (int j = 0; j < data.skillCount; j++)
     {
         vo.skillIdList.Add(data.GetSkill(j));
     }
     vo.cooldownList.Clear();
     for (int i = 0; i < data.cooldownCount; i++)
     {
         GC_CoolDownInfo coolDown = data.GetCooldown(i);
         CoolDownVo      cVo      = new CoolDownVo();
         cVo.cdTime  = coolDown.Cdtime;
         cVo.elapsed = coolDown.Elapsed;
         cVo.id      = coolDown.Id;
         vo.cooldownList.Add(cVo);
     }
 }
        private void SetProxy(GC_LOGIN_RET packet)
        {
            PlayerProxy proxy = GameFacade.GetProxy <PlayerProxy>();

            proxy.userid      = packet.Userid;
            proxy.oid         = packet.Oid;
            proxy.accesstoken = packet.Accesstoken;
            proxy.playername  = packet.Playername;
            proxy.level       = packet.Level;

            //城市数据
            proxy.city.cityId   = packet.City.CityId;
            proxy.city.tileId   = packet.City.TileId;
            proxy.city.level    = packet.City.Level;
            proxy.city.food     = packet.City.Food;
            proxy.city.stone    = packet.City.Stone;
            proxy.city.iron     = packet.City.Iron;
            proxy.city.WorldPos = new Coord(packet.City.Posx, packet.City.Posz);

            proxy.city.buildList.Clear();
            for (int i = 0; i < packet.City.buildlistCount; i++)
            {
                GC_BuildingData data = packet.City.GetBuildlist(i);
                BuildingVo      vo   = new BuildingVo();
                PlayerProxy.SetBuildVo(data, vo);
                proxy.city.buildList.Add(vo);
            }

            proxy.city.trainList.Clear();
            for (int i = 0; i < packet.City.trainListCount; i++)
            {
                GC_TrainData data = packet.City.GetTrainList(i);
                TrainVo      vo   = new TrainVo();
                PlayerProxy.SetTrainVo(data, vo);
                proxy.city.trainList.Add(vo);
            }

            //英雄数据
            proxy.heroList.Clear();
            for (int i = 0; i < packet.HeroList.heroListCount; i++)
            {
                GC_HeroData data = packet.HeroList.GetHeroList(i);
                HeroVo      vo   = new HeroVo();
                PlayerProxy.SetHeroVo(data, vo);
                proxy.heroList.Add(vo);
            }

            //队伍数据
            proxy.marchList.Clear();
            for (int i = 0; i < packet.Marchlist.marchlistCount; i++)
            {
                GC_MarchData data = packet.Marchlist.GetMarchlist(i);
                MarchVo      vo   = new MarchVo();
                PlayerProxy.SetMarchVo(data, vo);
                proxy.marchList.Add(vo);
            }
        }
Esempio n. 4
0
 //获取当前英雄头像
 public string GetCurHeroIcon()
 {
     if (heroIndex != -1)
     {
         HeroVo          hero         = playerProxy.heroList [heroIndex];
         List <Tab_Hero> heroTempList = TableManager.GetHeroByID(hero.type);
         return(heroTempList [0].Portrait);
     }
     return("");
 }
Esempio n. 5
0
    /// <summary>
    /// 预先判断该武将是否会被打死
    /// </summary>
    /// <param name="attackHero">进攻方数据</param>
    /// <param name="hurtHero">被攻击方数据</param>
    /// <returns></returns>
    public static bool checkRoleDead(HeroVo attackHero, HeroVo hurtHero)
    {
        int damage = DamageUtils.mathDamage(attackHero, hurtHero);

        hurtHero.tempHp -= damage;
        if (hurtHero.tempHp < 0)
        {
            hurtHero.tempHp = 0;
        }
        return((bool)(hurtHero.tempHp <= 0));
    }
 /// <summary>
 /// 计算伤害值
 /// </summary>
 /// <param name="attackHero">攻击数据</param>
 /// <param name="hurtHero">被攻击数据</param>
 /// <returns></returns>
 public static int mathDamage(HeroVo attackHero, HeroVo hurtHero)
 {
     //这里提供的是最简单的计算公式
     //伤害血量 = max((攻方.攻击力 - 守方.防御力), 1);
     return Mathf.Max((attackHero.atk - hurtHero.def), 1);
 }
    private void initTestData()
    {
        //此处为测试数据
        for (int i = 0; i < 6; ++i)
        {
            HeroVo hVo = new HeroVo();
            hVo.atk             = RandomUtil.randint(15, 35);
            hVo.atk             = 20;
            hVo.def             = RandomUtil.randint(2, 5);
            hVo.hp              = RandomUtil.randint(20, 50);
            hVo.attackType      = RandomUtil.randint(1, 2);
            hVo.attackRangeType = RandomUtil.randint(0, 2);

            hVo.id = i + 1;
            if (i == 1)
            {
                hVo.hp         = 5;
                hVo.attackType = 2;
            }
            if (i == 0)
            {
                hVo.hp         = 200;
                hVo.attackType = 2;
            }
            if (i == 2)
            {
                hVo.hp         = 200;
                hVo.attackType = 2;
            }

            BattleRole br = new BattleRole();
            br.index = i;
            br.create(Layer.Instance.battleScene.transform);
            br.createHpBar(Layer.Instance.battleUILayer.transform);
            br.initHpBarMax(hVo.hp);
            br.isMyTeam = true;
            br.heroVo   = hVo;
            this.myTeam.Add(br);
            this.myTeamAry[i] = br;
        }

        for (int i = 0; i < 4; ++i)
        {
            HeroVo hVo = new HeroVo();
            hVo.atk        = RandomUtil.randint(15, 35);
            hVo.def        = RandomUtil.randint(2, 5);
            hVo.hp         = RandomUtil.randint(20, 50);
            hVo.id         = i + 6;
            hVo.attackType = RandomUtil.randint(1, 2);

            if (i == 3)
            {
                hVo.attackType = 1;
                hVo.atk        = 80;
                hVo.hp         = 300;
            }

            BattleRole br = new BattleRole();
            br.index = i;
            br.create(Layer.Instance.battleScene.transform);
            br.createHpBar(Layer.Instance.battleUILayer.transform);
            br.initHpBarMax(hVo.hp);

            br.isMyTeam = false;
            br.heroVo   = hVo;
            this.targetTeam.Add(br);
            this.targetTeamAry[i] = br;
        }
        this.initTeamPos();
    }
Esempio n. 8
0
 /// <summary>
 /// 计算伤害值
 /// </summary>
 /// <param name="attackHero">攻击数据</param>
 /// <param name="hurtHero">被攻击数据</param>
 /// <returns></returns>
 public static int mathDamage(HeroVo attackHero, HeroVo hurtHero)
 {
     //这里提供的是最简单的计算公式
     //伤害血量 = max((攻方.攻击力 - 守方.防御力), 1);
     return(Mathf.Max((attackHero.atk - hurtHero.def), 1));
 }
    private void initTestData()
    {
        //此处为测试数据
        for (int i = 0; i < 6; ++i)
        {
            HeroVo hVo = new HeroVo();
            hVo.atk = RandomUtil.randint(15, 35);
            hVo.atk = 20;
            hVo.def = RandomUtil.randint(2, 5);
            hVo.hp = RandomUtil.randint(20, 50);
            hVo.attackType = RandomUtil.randint(1, 2);
            hVo.attackRangeType = RandomUtil.randint(0, 2);

            hVo.id = i + 1;
            if (i == 1)
            {
                hVo.hp = 5;
                hVo.attackType = 2;

            }
            if (i == 0)
            {
                hVo.hp = 200;
                hVo.attackType = 2;
            }
            if (i == 2)
            {
                hVo.hp = 200;
                hVo.attackType = 2;
            }

            BattleRole br = new BattleRole();
            br.index = i;
            br.create(Layer.Instance.battleScene.transform);
            br.createHpBar(Layer.Instance.battleUILayer.transform);
            br.initHpBarMax(hVo.hp);
            br.isMyTeam = true;
            br.heroVo = hVo;
            this.myTeam.Add(br);
            this.myTeamAry[i] = br;
        }

        for (int i = 0; i < 4; ++i)
        {
            HeroVo hVo = new HeroVo();
            hVo.atk = RandomUtil.randint(15, 35);
            hVo.def = RandomUtil.randint(2, 5);
            hVo.hp = RandomUtil.randint(20, 50);
            hVo.id = i + 6;
            hVo.attackType = RandomUtil.randint(1, 2);

            if (i == 3)
            {
                hVo.attackType = 1;
                hVo.atk = 80;
                hVo.hp = 300;
            }

            BattleRole br = new BattleRole();
            br.index = i;
            br.create(Layer.Instance.battleScene.transform);
            br.createHpBar(Layer.Instance.battleUILayer.transform);
            br.initHpBarMax(hVo.hp);

            br.isMyTeam = false;
            br.heroVo = hVo;
            this.targetTeam.Add(br);
            this.targetTeamAry[i] = br;
        }
        this.initTeamPos();
    }