예제 #1
0
        /// <summary>
        /// 恢复量=
        /// </summary>
        /// <param name="attackCharacter">Attack character.</param>
        /// <param name="targetCharacter">Target character.</param>
        public int Heal(MCharacter attackCharacter, MCharacter targetCharacter, VTile tile = null, VTile targetTile = null)
        {
            MSkill skill = attackCharacter.CurrentSkill;

            App.Model.Master.MSkill skillMaster = skill.Master;
            return(1 + attackCharacter.Level + attackCharacter.Ability.MagicAttack * skillMaster.strength);
        }
예제 #2
0
        public void ShowPreview(int skillId)
        {
            int           index = System.Array.FindIndex(mCharacter.Skills, _ => _.SkillId == skillId);
            MSkill        skill = mCharacter.Skills[index];
            RectTransform trans = preview.GetComponent <RectTransform>();

            trans.anchoredPosition = new Vector2(110 * index - 190, trans.anchoredPosition.y);
            preview.SetActive(true);
            preview.transform.Find("Name").GetComponent <Text>().text     = skill.Master.name;
            preview.transform.Find("Detailed").GetComponent <Text>().text = skill.Master.explanation;
        }
예제 #3
0
파일: SSkill.cs 프로젝트: zlbsy/sh109
        public IEnumerator RequestLevelUp(int id)
        {
            var     url  = "skill/level_up";
            WWWForm form = new WWWForm();

            form.AddField("skill_id", id);
            HttpClient client = new HttpClient();

            yield return(App.Util.SceneManager.CurrentScene.StartCoroutine(client.Send(url, form)));

            ResponseLevelUp response = client.Deserialize <ResponseLevelUp>();

            this.skill = response.skill;
        }
예제 #4
0
        /// <summary>
        /// 是否在攻击范围内
        /// </summary>
        public bool IsInSkillDistance(int CoordinateX, int CoordinateY, int targetX, int targetY, MCharacter distanceCharacter, MSkill targetSkill)
        {
            //MSkill targetSkill = distanceCharacter.CurrentSkill;
            App.Model.Master.MSkill targetSkillMaster = targetSkill.Master;
            int distance = cBattlefield.mapSearch.GetDistance(CoordinateX, CoordinateY, targetX, targetY);

            if (distance >= targetSkillMaster.distance[0] && distance <= targetSkillMaster.distance[1])
            {
                return(true);
            }
            //技能攻击扩展范围
            List <int[]> distances = distanceCharacter.SkillDistances;

            if (distances.Count == 0)
            {
                return(false);
            }
            foreach (int[] child in distances)
            {
                if (distance >= child[0] && distance <= child[1])
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #5
0
        /// <summary>
        /// 攻击伤害=技能*0.3+攻击力-防御力*2
        /// </summary>
        /// <param name="attackCharacter">Attack character.</param>
        /// <param name="targetCharacter">Target character.</param>
        public int Hert(MCharacter attackCharacter, MCharacter targetCharacter, VTile tile = null, VTile targetTile = null)
        {
            //获取地形辅助
            float  tileAid       = attackCharacter.TileAid(tile);
            float  targetTileAid = targetCharacter.TileAid(targetTile);
            MSkill skill         = attackCharacter.CurrentSkill;

            App.Model.Master.MSkill skillMaster = skill.Master;
            if (tile == null)
            {
                tile = cBattlefield.mapSearch.GetTile(attackCharacter.CoordinateX, attackCharacter.CoordinateY);
            }
            if (targetTile == null)
            {
                targetTile = cBattlefield.mapSearch.GetTile(targetCharacter.CoordinateX, targetCharacter.CoordinateY);
            }
            float attack = System.Array.Exists(skillMaster.types, s => s == SkillType.attack) ? attackCharacter.Ability.PhysicalAttack : attackCharacter.Ability.MagicAttack;

            //地形辅助
            attack *= tileAid;
            if (attackCharacter.IsPike && targetCharacter.IsKnife)
            {
                //枪剑类克制刀类
                attack *= 1.2f;
            }
            else if (attackCharacter.IsKnife && targetCharacter.IsAx)
            {
                //刀类克制斧类
                attack *= 1.2f;
            }
            else if (attackCharacter.IsAx && targetCharacter.IsPike)
            {
                //斧类克制枪剑类
                attack *= 1.2f;
            }
            float defense = System.Array.Exists(skillMaster.types, s => s == SkillType.attack) ? targetCharacter.Ability.PhysicalDefense : targetCharacter.Ability.MagicDefense;

            //地形辅助
            defense *= targetTileAid;
            if (attackCharacter.IsLongWeapon && targetCharacter.IsShortWeapon)
            {
                //长兵器克制短兵器
                defense *= 0.8f;
            }
            else if (attackCharacter.IsShortWeapon && targetCharacter.IsArcheryWeapon)
            {
                //短兵器克制远程兵器
                defense *= 0.8f;
            }
            else if (attackCharacter.IsArcheryWeapon && targetCharacter.IsLongWeapon)
            {
                //远程类兵器克制长兵器
                defense *= 0.8f;
            }
            App.Model.Master.MTile mTile = TileCacher.Instance.Get(targetTile.TileId);
            //地形对技能威力的影响
            int   five_elements = (int)skillMaster.five_elements;
            float skillStrength = skillMaster.strength * mTile.strategys[five_elements];
            //抗性对技能威力的影响
            int resistance = targetCharacter.Master.resistances[five_elements];

            if (resistance > 0)
            {
                skillStrength *= ((100 - resistance) * 0.01f);
            }
            float result = skillStrength * 0.3f + attack - defense;

            //Debug.LogError("result="+result + ", skillMaster.strength="+skillMaster.strength +", attack=" + attack+", defense="+defense);
            if (attackCharacter.MoveType == MoveType.cavalry && targetCharacter.MoveType == MoveType.infantry && !targetCharacter.IsArcheryWeapon)
            {
                //骑兵克制近身步兵
                result *= 1.2f;
            }
            else if (attackCharacter.IsArcheryWeapon && targetCharacter.MoveType == MoveType.cavalry && !targetCharacter.IsArcheryWeapon)
            {
                //远程类克制近身类骑兵
                result *= 1.2f;
            }
            else if (attackCharacter.MoveType == MoveType.infantry && targetCharacter.WeaponType != WeaponType.archery && targetCharacter.IsArcheryWeapon)
            {
                //近身步兵克制远程类
                result *= 1.2f;
            }
            if (targetCharacter.MoveType == MoveType.cavalry && skillMaster.effect.special == App.Model.Master.SkillEffectSpecial.horse_hert)
            {
                //对骑兵技能伤害加成
                result *= (1f + skillMaster.effect.special_value * 0.01f);
            }
            else if (skillMaster.effect.special == App.Model.Master.SkillEffectSpecial.move_and_attack && attackCharacter.roadLength > 0)
            {
                //移动攻击
                result *= (1f + attackCharacter.roadLength * skillMaster.effect.special_value * 0.01f);
            }
            result = result > 1 ? result : 1;
            result = result > targetCharacter.Hp ? targetCharacter.Hp : result;
            return((int)result);
        }
예제 #6
0
파일: AIManager.cs 프로젝트: lufy001/Sgj-MZ
        public IEnumerator Execute()
        {
            BattleCalculateManager  calculateManager  = Global.battleManager.calculateManager;
            BattleCharactersManager charactersManager = Global.charactersManager;
            TileMap mapSearch = Global.mapSearch;
            //行动顺序
            List <MCharacter> characters = charactersManager.mCharacters.FindAll((c) => {
                return(c.belong == this.belong && c.hp > 0 && !c.isHide && !c.actionOver);
            });

            characters.Sort((a, b) => {
                VTile aTile = mapSearch.GetTile(a.coordinate);
                VTile bTile = mapSearch.GetTile(b.coordinate);
                App.Model.Master.MTile aMTile = TileCacher.Instance.Get(aTile.tileId);
                App.Model.Master.MTile bMTile = TileCacher.Instance.Get(bTile.tileId);
                //恢复地形
                if (aMTile.heal > bMTile.heal)
                {
                    return(1);
                }
                else if (aMTile.heal > bMTile.heal)
                {
                    return(-1);
                }
                bool aPant = a.isPant;
                bool bPant = b.isPant;
                //残血状态
                if (aPant && !bPant)
                {
                    return(1);
                }
                else if (!aPant && bPant)
                {
                    return(-1);
                }
                bool aMagic = a.weaponType == WeaponType.magic;
                bool bMagic = b.weaponType == WeaponType.magic;
                bool aHeal  = a.canHeal;
                bool bHeal  = b.canHeal;
                //攻击型法师
                if (aMagic && !bMagic && !aHeal)
                {
                    return(1);
                }
                else if (!aMagic && bMagic && !bHeal)
                {
                    return(-1);
                }
                bool aArchery = a.isArcheryWeapon;
                bool bArchery = b.isArcheryWeapon;
                //远程类
                if (aArchery && !bArchery)
                {
                    return(1);
                }
                else if (!aArchery && bArchery)
                {
                    return(-1);
                }
                //近战类
                if (!aMagic && bMagic)
                {
                    return(1);
                }
                else if (aMagic && !bMagic)
                {
                    return(-1);
                }
                //恢复型法师
                return(0);
            });
            mCharacter = characters[0];
            Debug.LogError("mCharacter = " + mCharacter.name);
            MSkill attackSkill = System.Array.Find(mCharacter.skills, (MSkill skill) => {
                Model.Master.MSkill skillMaster = skill.master;
                return(System.Array.Exists(skillMaster.types, s => (s == SkillType.attack || s == SkillType.magic)) &&
                       System.Array.IndexOf(skillMaster.weaponTypes, mCharacter.weaponType) >= 0);
            });

            mCharacter.currentSkill = attackSkill;
            Global.battleManager.ClickNoneNode(mCharacter.coordinate);
            //VTile tile = mapSearch.GetTile(mCharacter.coordinate);
            //Global.battleManager.ClickNoneNode(tile.coordinate);
            yield return(new WaitForEndOfFrame());

            FindAttackTarget();
            Debug.LogError("targetTile=" + targetTile);
            bool canKill = false;

            if (targetTile != null)
            {
                canKill = calculateManager.Hert(mCharacter, attackTarget, targetTile) - attackTarget.hp >= 0;
            }
            Debug.LogError("canKill=" + canKill);
            if (canKill)
            {
                yield return(AppManager.CurrentScene.StartCoroutine(Attack()));
            }
            else
            {
                bool   needHeal  = false;
                MSkill healSkill = System.Array.Find(mCharacter.skills, (MSkill skill) => {
                    App.Model.Master.MSkill skillMaster = skill.master;
                    return(System.Array.Exists(skillMaster.types, s => s == SkillType.heal) &&
                           System.Array.IndexOf(skillMaster.weaponTypes, mCharacter.weaponType) >= 0);
                });
                Debug.LogError("healSkill=" + healSkill);
                if (healSkill != null)
                {
                    mCharacter.currentSkill = healSkill;
                    Global.battleManager.CharacterReturnNone();
                    Global.battleManager.ClickNoneNode(mCharacter.coordinate);
                    yield return(new WaitForEndOfFrame());

                    MCharacter healTarget = null;
                    VTile      healTile   = null;
                    FindHealTarget(out healTarget, out healTile);
                    if (healTarget != null)
                    {
                        attackTarget = healTarget;
                        targetTile   = healTile;
                        needHeal     = true;
                    }
                }
                if (needHeal)
                {
                    yield return(AppManager.CurrentScene.StartCoroutine(Heal()));

                    mCharacter.currentSkill = attackSkill;
                }
                else
                {
                    if (healSkill != null)
                    {
                        Global.battleManager.CharacterReturnNone();
                        Global.battleManager.ClickNoneNode(mCharacter.coordinate);
                        yield return(new WaitForEndOfFrame());

                        mCharacter.currentSkill = attackSkill;
                    }
                    yield return(AppManager.CurrentScene.StartCoroutine(Attack()));
                }
            }
        }
예제 #7
0
파일: CharacterAI.cs 프로젝트: zlbsy/sh109
        public IEnumerator Execute()
        {
            //行动顺序
            MCharacter[] characters = System.Array.FindAll(mBaseMap.Characters, c => c.Belong == this.belong && c.Hp > 0 && !c.IsHide && !c.ActionOver);
            System.Array.Sort(characters, (a, b) => {
                VTile aTile = cBattlefield.mapSearch.GetTile(a.CoordinateX, a.CoordinateY);
                VTile bTile = cBattlefield.mapSearch.GetTile(b.CoordinateX, b.CoordinateY);
                App.Model.Master.MTile aMTile = TileCacher.Instance.Get(aTile.TileId);
                App.Model.Master.MTile bMTile = TileCacher.Instance.Get(bTile.TileId);
                //恢复地形
                if (aMTile.heal > bMTile.heal)
                {
                    return(1);
                }
                else if (aMTile.heal > bMTile.heal)
                {
                    return(-1);
                }
                bool aPant = a.IsPant;
                bool bPant = b.IsPant;
                //残血状态
                if (aPant && !bPant)
                {
                    return(1);
                }
                else if (!aPant && bPant)
                {
                    return(-1);
                }
                bool aMagic = a.WeaponType == WeaponType.magic;
                bool bMagic = b.WeaponType == WeaponType.magic;
                bool aHeal  = a.CanHeal;
                bool bHeal  = b.CanHeal;
                //攻击型法师
                if (aMagic && !bMagic && !aHeal)
                {
                    return(1);
                }
                else if (!aMagic && bMagic && !bHeal)
                {
                    return(-1);
                }
                bool aArchery = a.IsArcheryWeapon;
                bool bArchery = b.IsArcheryWeapon;
                //远程类
                if (aArchery && !bArchery)
                {
                    return(1);
                }
                else if (!aArchery && bArchery)
                {
                    return(-1);
                }
                //近战类
                if (!aMagic && bMagic)
                {
                    return(1);
                }
                else if (aMagic && !bMagic)
                {
                    return(-1);
                }
                //恢复型法师
                return(0);
            });
            mCharacter = characters[0];
            MSkill attackSkill = System.Array.Find(mCharacter.Skills, delegate(MSkill skill){
                App.Model.Master.MSkill skillMaster = skill.Master;
                return(System.Array.Exists(skillMaster.types, s => (s == SkillType.attack || s == SkillType.magic)) &&
                       System.Array.IndexOf(skillMaster.weapon_types, mCharacter.WeaponType) >= 0);
            });

            mCharacter.CurrentSkill = attackSkill;
            int index = cBattlefield.mapSearch.GetTile(mCharacter.CoordinateX, mCharacter.CoordinateY).Index;

            cBattlefield.manager.ClickNoneNode(index);
            yield return(new WaitForEndOfFrame());

            FindAttackTarget();
            //yield return cBattlefield.StartCoroutine();
            bool canKill = false;

            if (targetTile != null)
            {
                canKill = cBattlefield.calculateManager.Hert(mCharacter, attackTarget, targetTile) - attackTarget.Hp >= 0;
            }
            if (canKill)
            {
                yield return(cBattlefield.StartCoroutine(Attack()));
            }
            else
            {
                bool   needHeal  = false;
                MSkill healSkill = System.Array.Find(mCharacter.Skills, delegate(MSkill skill){
                    App.Model.Master.MSkill skillMaster = skill.Master;
                    return(System.Array.Exists(skillMaster.types, s => s == SkillType.heal) &&
                           System.Array.IndexOf(skillMaster.weapon_types, mCharacter.WeaponType) >= 0);
                });
                if (healSkill != null)
                {
                    mCharacter.CurrentSkill = healSkill;
                    cBattlefield.manager.CharacterReturnNone();
                    cBattlefield.manager.ClickNoneNode(index);
                    yield return(new WaitForEndOfFrame());

                    MCharacter healTarget = null;
                    VTile      healTile   = null;
                    FindHealTarget(out healTarget, out healTile);
                    if (healTarget != null)
                    {
                        attackTarget = healTarget;
                        targetTile   = healTile;
                        needHeal     = true;
                    }
                }
                if (needHeal)
                {
                    yield return(cBattlefield.StartCoroutine(Heal()));

                    mCharacter.CurrentSkill = attackSkill;
                }
                else
                {
                    if (healSkill != null)
                    {
                        cBattlefield.manager.CharacterReturnNone();
                        cBattlefield.manager.ClickNoneNode(index);
                        yield return(new WaitForEndOfFrame());

                        mCharacter.CurrentSkill = attackSkill;
                    }
                    yield return(cBattlefield.StartCoroutine(Attack()));
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 是否在攻击范围内
        /// </summary>
        public bool IsInSkillDistance(Vector2Int coordinate, Vector2Int targetCoordinate, MCharacter distanceCharacter, MSkill targetSkill)
        {
            //MSkill targetSkill = distanceCharacter.CurrentSkill;
            App.Model.Master.MSkill targetSkillMaster = targetSkill.master;
            int distance = Global.mapSearch.GetDistance(coordinate, targetCoordinate);

            if (distance >= targetSkillMaster.distance[0] && distance <= targetSkillMaster.distance[1])
            {
                return(true);
            }
            //技能攻击扩展范围
            List <int[]> distances = distanceCharacter.skillDistances;

            if (distances.Count == 0)
            {
                return(false);
            }
            foreach (int[] child in distances)
            {
                if (distance >= child[0] && distance <= child[1])
                {
                    return(true);
                }
            }
            return(false);
        }