public void SelectHero(BaseHero hero) { if (_heroes != null) { for (int i = 0; i < _heroes.Length; i++) { if (_heroes[i] == hero) { SelectHero(i); return; } } } }
public IActionOutputParameter Action(ActionParameter actionParameter) { UC uc = GameActivator <UC> .CreateInstance(); var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter)); foreach (UserContext user in users) { BaseHero hero = actionParameter.GameContext.DeskCards.GetHeroByIsFirst(user.IsFirst); hero.Ammo += GameActivator <Q> .CreateInstance().GetNumber(actionParameter); } return(null); }
public void AddHeroes(BaseHero[] heroesList) { if(_heroes == null) { _heroes = heroesList; } else if(heroesList.Length > 0) { BaseHero[] newHeroes = new BaseHero[_heroes.Length + heroesList.Length]; Array.Copy(_heroes, newHeroes, _heroes.Length); for (int i = _heroes.Length, j = 0; i < newHeroes.Length; i++, j++) { newHeroes[i] = heroesList[j]; } _heroes = newHeroes; } _heroesRO = new ArrayRO<BaseHero>(_heroes); }
/// <summary> /// 英雄攻击进行阶段 /// </summary> /// <param name="servant"></param> /// <param name="target"></param> public void HeroAttack(BaseHero hero, int target) { ActionParameter para = new ActionParameter() { PrimaryCard = hero, GameContext = GameContext, SecondaryCard = GameContext.DeskCards[target] }; CardActionFactory.CreateAction(hero, ActionType.攻击).Action(para); // GameContext.AddEndOfPlayerActionEvent(); GameContext.Settlement(); _gameCache.SetContext(GameContext); }
public void ImportHeroList(List <BaseHero> updatedHeroes) { if (updatedHeroes == null) { return; } for (int i = 0; i < updatedHeroes.Count; i++) { BaseHero updatedHero = updatedHeroes[i]; updatedHero.currHP = updatedHero.currHP > 1 ? updatedHero.currHP : 1; UpdateLevel(updatedHero); heroList[i].GetComponent <HeroState>().hero = updatedHero; } }
public PartyAdventureState Initialized(BaseHero one, BaseHero two, BaseHero three) { heroes = party.Initialized(one, two, three).Heroes.Select(h => new Hero(h, CreateDeck(h.Deck))).ToArray(); credits = heroes.Sum(h => h.Character.StartingCredits); numShopRestocks = 2; var allStartingCards = Decks.SelectMany(d => d.Cards).ToList(); cards.Initialized(allStartingCards); allStartingCards.Distinct().ForEach(c => cards.EnsureHasAtLeast(c, 4)); equipment = new PartyEquipmentCollection(); return(this); }
// Token: 0x06000848 RID: 2120 RVA: 0x00025FC4 File Offset: 0x000241C4 public OldAbilityGroup(BaseHero baseHero) { foreach (Type type in from x in Assembly.GetExecutingAssembly().GetTypes() where !x.IsAbstract && x.IsClass && typeof(TAbility).IsAssignableFrom(x) select x) { foreach (AbilityIdAttribute abilityIdAttribute in type.GetCustomAttributes <AbilityIdAttribute>()) { this.UniqueAbilities.Add(abilityIdAttribute.AbilityId, type); } } this.AbilitySleeper = baseHero.AbilitySleeper; this.OrbwalkSleeper = baseHero.OrbwalkSleeper; }
public IActionOutputParameter Action(ActionParameter actionParameter) { foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter))) { BaseHero hero = biology as BaseHero; if (hero.Equip != null) { hero.Equip.Damage += GameActivator <Damage> .CreateInstance().GetNumber(actionParameter); hero.Equip.Durable += GameActivator <Durable> .CreateInstance().GetNumber(actionParameter); } } return(null); }
public void Run() { List <BaseHero> heroes = new List <BaseHero>(); int countOfHeroes = int.Parse(Console.ReadLine()); for (int i = 0; i < countOfHeroes; i++) { string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); try { BaseHero hero = null; if (SearchHero(heroType) == Heroes.Druid) { heroes.Add(new Druid(heroName)); } else if (SearchHero(heroType) == Heroes.Paladin) { heroes.Add(new Paladin(heroName)); } else if (SearchHero(heroType) == Heroes.Rogue) { heroes.Add(new Rogue(heroName)); } else if (SearchHero(heroType) == Heroes.Warrior) { heroes.Add(new Warrior(heroName)); } } catch (Exception ex) { Console.WriteLine(ex.Message); i--; } } int powerOfBoss = int.Parse(Console.ReadLine()); int totalPowerOfHeroes = 0; totalPowerOfHeroes = PrintHeroes(heroes, totalPowerOfHeroes); string result = totalPowerOfHeroes >= powerOfBoss ? "Victory!" : "Defeat..."; Console.WriteLine(result); }
public void Run() { var n = int.Parse(Console.ReadLine()); while (this.heroes.Count < n) { var heroName = Console.ReadLine(); var heroType = Console.ReadLine(); BaseHero hero = null; if (heroType == "Druid") { hero = new Druid(heroName); } else if (heroType == "Paladin") { hero = new Paladin(heroName); } else if (heroType == "Rogue") { hero = new Rogue(heroName); } else if (heroType == "Warrior") { hero = new Warrior(heroName); } else { Console.WriteLine("Invalid hero!"); continue; } if (hero != null) { this.heroes.Add(hero); } } var bossPower = int.Parse(Console.ReadLine()); var raidPower = 0; foreach (var hero in this.heroes) { raidPower += hero.Power; Console.WriteLine(hero.CastAbility()); } Console.WriteLine(raidPower >= bossPower ? "Victory!" : "Defeat..."); }
protected void UpdateHeroTarget() { //select hero based on current health //TODO: if mutiple heroes has same lowest health, give priority to DPS GameObject[] heroes = GameObject.FindGameObjectsWithTag(heroTag); float lowestHealthPercent = Mathf.Infinity; GameObject heroToHeal = null; foreach (GameObject heroGO in heroes) { BaseHero baseHero = heroGO.GetComponent <BaseHero>(); float curHealth = baseHero.CurHP, maxHealth = baseHero.MaxHPValue; float currentHealthPercent = curHealth / maxHealth; float distanceToHero = Vector3.Distance(transform.position, heroGO.transform.position); if (currentHealthPercent < lowestHealthPercent && distanceToHero <= RangeValue) { lowestHealthPercent = currentHealthPercent; heroToHeal = heroGO; } } GameObject[] knights = GameObject.FindGameObjectsWithTag(knightTag); foreach (GameObject knightGO in knights) { BaseHero baseHero = knightGO.GetComponent <BaseHero>(); float curHealth = baseHero.CurHP, maxHealth = baseHero.MaxHPValue; float currentHealthPercent = curHealth / maxHealth; float distanceToHero = Vector3.Distance(transform.position, knightGO.transform.position); if (currentHealthPercent < lowestHealthPercent && distanceToHero <= RangeValue) { lowestHealthPercent = currentHealthPercent; heroToHeal = knightGO; } } if (heroToHeal != null) { targetHeroTransform = heroToHeal.transform; targetHero = heroToHeal.GetComponent <BaseHero>(); } else { targetHeroTransform = null; } //update property this.Target = targetHeroTransform; this.TargetHero = targetHero; }
public UnitManager(BaseHero main, Unit unit) { Main = main; Unit = unit; Handle = unit.Handle.Handle; Ability = unit.Spellbook.Spells.Count(x => x.Name != "lone_druid_spirit_bear_return" && !x.AbilityBehavior.HasFlag(AbilityBehavior.Passive)) > 0 ? unit.Spellbook.SpellQ : null; Ability2 = unit.Spellbook.Spells.Count(x => !x.Name.StartsWith("special_") && !x.AbilityBehavior.HasFlag(AbilityBehavior.Passive)) > 1 ? unit.Spellbook.SpellW : null; Ability3 = unit.Spellbook.Spells.Count(x => !x.Name.StartsWith("special_") && !x.AbilityBehavior.HasFlag(AbilityBehavior.Passive)) > 2 ? unit.Spellbook.SpellE : null; Ability4 = unit.Spellbook.Spells.Count(x => !x.Name.StartsWith("special_") && !x.AbilityBehavior.HasFlag(AbilityBehavior.Passive)) > 3 ? unit.Spellbook.SpellR : null; if (unit.Name != "npc_dota_templar_assassin_psionic_trap") { UnitMovementManager = new UnitMovementManager(new EnsageServiceContext(unit)); } }
public void ShowNewStats(BaseHero oldHero, BaseHero newhero) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($@"***Level Up*** Level {oldHero.Level} --> {newhero.Level} Damage {oldHero.Damage} --> {newhero.Damage} Health {oldHero.Health} --> {newhero.Health} Armour {oldHero.Armour} --> {newhero.Armour} Your exp {newhero.OwnExperience}/{newhero.NeededExperience} "); Console.ResetColor(); Console.Write("Press any key..."); Console.ReadKey(); }
public IActionOutputParameter Action(ActionParameter actionParameter) { ActionParameter para = actionParameter as ActionParameter; BaseHero baseHero = para.PrimaryCard as BaseHero; GameContext gameContext = para.GameContext; int heal = para.DamageOrHeal; baseHero.Life += heal; if (baseHero.Life > baseHero.BuffLife) { baseHero.Life = baseHero.BuffLife; } return(null); }
public override bool Attack(BaseHero from) { if (CanAttack(15000)) { if (!InitData()) { return(false); } AttackToAll(from); return(true); } return(false); }
void Start() { hero = this.GetComponent <BaseHero>(); startPosition = transform.position; Selector.SetActive(false); BSM = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>(); currentState = TurnState.PROCESSING; cur_AP = 0; ApplyLevels(); AdvantageEffects(); this.gameObject.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(hero.spritePath); this.gameObject.GetComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(hero.animatorPath); animator = this.gameObject.GetComponent <Animator>(); abilityVisualsAnimator = this.gameObject.transform.Find("AbilityVisuals").GetComponent <Animator>(); combatText = GameObject.Find("CombatText").GetComponent <Text>(); }
public void Run() { int numberOfInput = int.Parse(Console.ReadLine()); while (true) { if (this.baseHeroes.Count == numberOfInput) { break; } string heroName = Console.ReadLine(); string heroType = Console.ReadLine(); string baseNamespace = "Raiding.Models"; Type type = Type.GetType($"{baseNamespace}.{heroType}"); if (type == null) { Console.WriteLine("Invalid hero!"); continue; } BaseHero hero = (BaseHero)Activator.CreateInstance(type, heroName); this.baseHeroes.Add(hero); } int bossPower = int.Parse(Console.ReadLine()); if (this.baseHeroes.Any()) { foreach (var hero in this.baseHeroes) { bossPower -= hero.Power; Console.WriteLine(hero.CastAbility()); } } string finalMessage = bossPower > 0 ? "Defeat..." : "Victory!"; Console.WriteLine(finalMessage); }
public void Run() { HeroFactory heroFactory = new HeroFactory(); List <BaseHero> raidGroup = new List <BaseHero>(); int countOfNeededlHeroes = int.Parse(Console.ReadLine()); while (raidGroup.Count < countOfNeededlHeroes) { string name = Console.ReadLine(); string type = Console.ReadLine(); try { BaseHero newHero = heroFactory.CreateHero(name, type); raidGroup.Add(newHero); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } long bossPower = long.Parse(Console.ReadLine()); long raidGroupPower = default; if (raidGroup.Count > 0) { raidGroupPower = GetAllHeroesPowers(raidGroup); } if (raidGroup.Count > 0) { if (raidGroupPower >= bossPower) { Console.WriteLine(VICTORY_MSG); } else { Console.WriteLine(DEFEAT_MSG); } } else { Console.WriteLine(DEFEAT_MSG); } }
void ChangeTo(BaseHero from) { UnityTools.Log(from.name + " 对 " + from.name + " 使用 " + name); HeroAction treatAction1 = new HeroAction(); treatAction1.action = HeroActionType.Skill; treatAction1.args = new object[] { from, null, this }; from.AddAction(treatAction1); Buff buff = new Buff(); buff.type = BuffType.Change1; buff.start = now; buff.duration = changeDuration; from.AddBuff(buff); }
public IActionOutputParameter Action(ActionParameter actionParameter) { ActionParameter para = actionParameter as ActionParameter; BaseHero baseHero = para.PrimaryCard as BaseHero; GameContext gameContext = para.GameContext; if (((baseHero.Equip != null && baseHero.Equip.Damage > 0) || baseHero.Damage > 0) && baseHero.CanAttack) { baseHero.RemainAttackTimes += 1; if (baseHero.Equip != null && baseHero.Equip.HasWindfury) { baseHero.RemainAttackTimes += 1; } } return(null); }
public void WhenNoneCombo() { Tinker_sSharpswordOil tinker_sSharpswordOil = SetTestedCardInHand <Tinker_sSharpswordOil>(); PilotedShredder pilotedShredder = gameContext.GetActivationUserContext().AllCards.First(c => c.GetType() == typeof(PilotedShredder)) as PilotedShredder; SetCardInDesk(pilotedShredder); BaseHero baseHero = gameContext.GetHeroByActivation(); GameResult <GameContextOutput> res = proxy.CastHeroPower(gameContext.GameCode, gameContext.GetActivationUserContext().UserCode, -1) as GameResult <GameContextOutput>; Xunit.Assert.True(res.code == (int)OperateResCodeEnum.成功); res = proxy.CastSpell(gameContext.GameCode, gameContext.GetActivationUserContext().UserCode, tinker_sSharpswordOil.CardInGameCode, -1) as GameResult <GameContextOutput>; Xunit.Assert.True(res.code == (int)OperateResCodeEnum.成功); Xunit.Assert.True(baseHero.Equip.Damage == 4); Xunit.Assert.True(pilotedShredder.Damage == 4); Xunit.Assert.True(gameContext.GetActivationUserContext().ComboSwitch); }
/// <summary> /// 英雄发起攻击 /// </summary> /// <param name="gameCode"></param> /// <param name="userCode"></param> /// <param name="cardInGameCode"></param> /// <param name="target"></param> /// <returns></returns> public APIResultBase HeroAttack(string gameCode, string userCode, int target) { string res = JsonStringResult.VerifyFail(); Controler_Base ctl = Validate(gameCode, userCode); if (ctl == null) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } if (VictoryValidate(ctl.GameContext)) { return(JsonModelResult.PackageFail(OperateResCodeEnum.游戏已经结束)); } var player = ctl.GameContext.GetActivationUserContext(); if (player == null || player.UserCode != userCode) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } if (player.IsFirst && target < 8) { return(JsonModelResult.PackageFail(OperateResCodeEnum.参数错误)); } else if (player.IsFirst == false && target > 7) { return(JsonModelResult.PackageFail(OperateResCodeEnum.参数错误)); } BaseHero hero = ctl.GameContext.GetHeroByActivation(player.IsActivation); if (hero.RemainAttackTimes < 1) { return(JsonModelResult.PackageFail(OperateResCodeEnum.查询不到需要的数据)); } List <BaseBiology> taunts = ctl.GameContext.DeskCards.GetDeskCardsByIsFirst(player.IsFirst ? false : true).Where(c => c != null && c.HasTaunt).ToList(); if (taunts != null && taunts.Count > 0 && taunts.Any(c => c.DeskIndex == target) == false) { return(JsonModelResult.PackageFail(OperateResCodeEnum.你必须先攻击有嘲讽技能的随从)); } ctl.HeroAttack(hero, target); return(JsonModelResult.PackageSuccess(_gameCache.GetContext(ctl.GameContext.GameCode).Output())); }
public override bool Attack(BaseHero from) { if (CanAttack(10000)) { if (!InitData()) { return(false); } BaseHero slowHero = FindSlowHero(from); if (slowHero != null) { SlowTo(from, slowHero); return(true); } } return(false); }
public override bool Attack(BaseHero from) { if (CanAttack(Duration())) { if (!InitData()) { return(false); } BaseHero converHero = FindCoverHero(from); if (converHero != null) { CoverTo(from, converHero); return(true); } } return(false); }
public override bool Attack(BaseHero from) { if (from.hp < from.maxHp * (Fix64)20 / 100 && CanAttackFrom(lastAttackTimer, Duration())) { lastAttackTimer = now; if (!InitData()) { return(false); } if (from != null) { ChangeTo(from); return(true); } } return(false); }
public void AttackedAndCastSpell() { BladeFlurry bladeFlurry = SetTestedCardInHand <BladeFlurry>(); proxy.CastHeroPower(gameContext.GameCode, gameContext.GetActivationUserContext().UserCode, -1); BaseHero enemyHero = gameContext.DeskCards[8] as BaseHero; GameResult <GameContextOutput> res = proxy.HeroAttack(gameContext.GameCode, gameContext.GetActivationUserContext().UserCode, 8) as GameResult <GameContextOutput>; Xunit.Assert.True(res.code == (int)OperateResCodeEnum.成功); Xunit.Assert.True(enemyHero.Life == 29); res = proxy.CastSpell(gameContext.GameCode, gameContext.GetActivationUserContext().UserCode, bladeFlurry.CardInGameCode, -1) as GameResult <GameContextOutput>; BaseHero hero = gameContext.DeskCards[0] as BaseHero; Xunit.Assert.True(hero.Equip == null && gameContext.GetActivationUserContext().GraveyardCards.Any(c => c.CardInGameCode == bladeFlurry.CardInGameCode)); Xunit.Assert.True(enemyHero.Life == 28); }
public override bool Attack(BaseHero from) { if (CanAttack(10000)) { if (!InitData()) { return(false); } BaseHero attackHero = FindAttackHero(from); if (attackHero != null) { AttackTo(from, attackHero); return(true); } } return(false); }
public void Run() { List <BaseHero> heroes = new List <BaseHero>(); int numberOfHeroes = int.Parse(Console.ReadLine()); while (heroes.Count != numberOfHeroes) { string name = Console.ReadLine(); string type = Console.ReadLine(); try { BaseHero hero = this.heroFactory.ProduceHero(name, type); heroes.Add(hero); } catch (Exception ex) { Console.WriteLine(ex.Message); } } int bossPower = int.Parse(Console.ReadLine()); int herosPowerSum = 0; if (heroes.Any()) { foreach (var hero in heroes) { Console.WriteLine(hero.CastAbility()); herosPowerSum += hero.Power; } if (herosPowerSum >= bossPower) { Console.WriteLine("Victory!"); } else { Console.WriteLine("Defeat..."); } } }
private void LoadAllyUnitsResources() { //check if this is first map if (_allyUnitsGraphicsResources.Count > 0) { return; } ArrayRO <BaseSoldier> playerSoldiersList = Global.Instance.CurrentMission.SelectedSoldiers; BaseUnitData bud = null; BaseUnitBehaviour bub = null; //load unique soldiers for (int i = 0; i < playerSoldiersList.Length; i++) { if (_allyUnitsGraphicsResources.ContainsKey(playerSoldiersList[i].Data.Key)) { continue; } bud = UnitsConfig.Instance.GetSoldierData(playerSoldiersList[i].Data.Key); if (bud != null && !bud.PrefabName.Equals(string.Empty)) { bub = LoadUnitResource <BaseUnitBehaviour>(string.Format("{0}/{1}", GameConstants.Paths.UNIT_RESOURCES, bud.PrefabName)); _allyUnitsGraphicsResources.Add(playerSoldiersList[i].Data.Key, bub); } else { Debug.LogError("Can't load unit graphics: " + playerSoldiersList[i].Data.Key); } } //load hero BaseHero playerHero = Global.Instance.Player.Heroes.Current; if (playerHero == null || playerHero.Data.PrefabName.Equals(string.Empty)) { Debug.LogError("Can't load unit graphics for player hero"); } bub = LoadUnitResource <BaseUnitBehaviour>(string.Format("{0}/{1}", GameConstants.Paths.UNIT_RESOURCES, playerHero.Data.PrefabName)); _allyUnitsGraphicsResources.Add(playerHero.Data.Key, bub); }
private void CreateHeroes() { int n = int.Parse(this.reader.ReadLine()); while (this.heroes.Count != n) { string heroName = this.reader.ReadLine(); string heroType = this.reader.ReadLine(); try { BaseHero hero = heroFactory.CreateHero(heroType, heroName); this.heroes.Add(hero); } catch (InvalidHeroTypeException iht) { this.writer.WriteLine(iht.Message); } } }
public BaseHero Create(string strType, string name) { Assembly assembly = Assembly.GetExecutingAssembly(); bool isHeroValid = assembly.GetTypes().Select(b => b.Name).Contains(strType); if (!isHeroValid) { throw new InvalidOperationException(string.Format("Invalid hero!")); } Type type = assembly.GetTypes().FirstOrDefault(a => a.Name == strType); object[] ctorParams = new object[] { name }; BaseHero hero = (BaseHero)Activator.CreateInstance(type, ctorParams); return(hero); }
public void Unequip(BaseHero hero, int slotId) { hero.Inventory.Equip(slotId, EItemKey.None); }
public void Equip(BaseHero hero, int slotId, EItemKey itemKey) { hero.Inventory.Equip(slotId, itemKey); }
public PlayerHeroes(BaseHero[] heroes, int currentHeroIndex) { AddHeroes(heroes); SelectHero(currentHeroIndex); }