public void DoHeal(Base target, float hl) { HealAction heal = new HealAction(target, hl); heal.owner = gameObject; actionQueue.Add(heal); }
IEnumerator HealAction(HealAction action) { foreach (IDestructable target in action.targets) { target.HitPoints = Math.Min(target.HitPoints + action.amount, target.MaxHitPoints); yield return(null); } }
private static HealAction ParseHealAction(MapController mapController, Dictionary <string, string> fields) { HealAction healAction = ParseAction <HealAction>(mapController, fields); healAction.healAmount = Int32.Parse(fields[nameof(HealAction) + "." + nameof(HealAction.healAmount)]); healAction.range = Int32.Parse(fields[nameof(HealAction) + "." + nameof(HealAction.range)]); return(healAction); }
public void HealAction_CheckCoins_AreNotEnough() { GameState state = new GameState(); state.CurrentPlayer = new Player(); state.CurrentPlayer.Initialize(10, 10, 10, 9); IAction healAction = new HealAction(); Assert.AreEqual(healAction.CanApply(state, config), false); }
public void HealAction_CheckMaxHealth_Correct() { GameState state = new GameState(); state.CurrentPlayer = new Player(); state.CurrentPlayer.Initialize(10, 15, 10, 10); IAction healAction = new HealAction(); healAction.Process(state, config); Assert.AreEqual(state.CurrentPlayer.Health, 15); }
public static Entity ParseEntity(Dictionary <string, string> fields) { EntityParser entity = ScriptableObject.CreateInstance <EntityParser>(); entity.name = fields[nameof(name)]; entity.m_Type = GetOrCreateEntityType(fields[nameof(name)], fields[nameof(entity.Type.EntityClass)]); entity.m_MaxActionPoints = Int32.Parse(fields[nameof(ActionPoints)]); entity.m_MaxHp = Int32.Parse(fields[nameof(Hp)]); entity.m_Hp = entity.m_MaxHp; entity.m_Defense = Int32.Parse(fields[nameof(Defense)]); entity.m_Cost = ParseCost(fields); AssetDatabase.CreateAsset(entity.Cost, "Assets/ScriptableObjects/Costs/Entities/" + entity.name + "Cost.asset"); MapController mapController = AssetDatabase.LoadAssetAtPath <MapController>("Assets/ScriptableObjects/MapController.asset"); if (fields.Keys.Any(field => field.Contains(nameof(MoveAction)))) { MoveAction moveAction = ParseMoveAction(mapController, fields); AssetDatabase.CreateAsset(moveAction, "Assets/ScriptableObjects/Actions/MoveActions/" + entity.name + "MoveAction.asset"); entity.AddAction(moveAction); } if (fields.Keys.Any(field => field.Contains(nameof(AttackAction)))) { AttackAction attackAction = ParseAttackAction(mapController, fields); AssetDatabase.CreateAsset(attackAction, "Assets/ScriptableObjects/Actions/AttackActions/" + entity.name + "AttackAction.asset"); entity.AddAction(attackAction); } if (fields.Keys.Any(field => field.Contains(nameof(BuildAction)))) { BuildAction buildAction = ParseBuildAction(mapController, fields); AssetDatabase.CreateAsset(buildAction, "Assets/ScriptableObjects/Actions/BuildActions/" + entity.name + "BuildAction.asset"); entity.AddAction(buildAction); } if (fields.Keys.Any(field => field.Contains(nameof(HarvestAction)))) { HarvestAction harvestAction = ParseHarvestAction(entity, mapController, fields); AssetDatabase.CreateAsset(harvestAction, "Assets/ScriptableObjects/Actions/HarvestActions/" + entity.name + "HarvestAction.asset"); entity.AddAction(harvestAction); } if (fields.Keys.Any(field => field.Contains(nameof(HealAction)))) { HealAction healAction = ParseHealAction(mapController, fields); AssetDatabase.CreateAsset(healAction, "Assets/ScriptableObjects/Actions/HealActions/" + entity.name + "HealAction.asset"); entity.AddAction(healAction); } return((Entity)entity); }
private bool IsBetterHeal(HealAction newAction, HealAction prevAction, Kernel kernel) { var newContext = (HealActionContext)newAction.getContext(); var prevContext = (HealActionContext)prevAction.getContext(); Fruiton newTarget = KernelUtils.GetFruitonAt(kernel, newContext.target); Fruiton prevTarget = KernelUtils.GetFruitonAt(kernel, prevContext.target); int newHealAmount = Math.Min(newContext.heal, newTarget.originalAttributes.hp - newTarget.currentAttributes.hp); int prevHealAmount = Math.Min(prevContext.heal, prevTarget.originalAttributes.hp - prevTarget.currentAttributes.hp); return(newTarget.get_isKing() || newTarget.type == Fruiton.MAJOR_TYPE && prevTarget.type == Fruiton.MINOR_TYPE || newTarget.type == prevTarget.type && newHealAmount > prevHealAmount); }
private Transform CreateDamagePopup(Transform target, HealAction action) { var popup = popupPooler.Dequeue().GetComponent <PopupView>(); popup.ChangeColor(color); popup.SetText("+" + action.amount + " Heal"); popup.transform.ResetParent(popupPooler.transform); popup.transform.position = target.position; popup.transform.rotation = target.rotation; popup.transform.localScale = target.localScale; popup.gameObject.SetActive(true); return(popup.transform); }
public static ActionParameter GetActionParameterByActionType(eActionType actionType, out bool isSuccess) { ActionParameter action = new ActionParameter(); isSuccess = true; switch (actionType) { case eActionType.ATTACK: action = new AttackAction(); break; case eActionType.MOVE: action = new MoveAction(); break; case eActionType.KNOCK: action = new KnockAction(); break; case eActionType.HEAL: action = new HealAction(); break; case eActionType.BARRIER: action = new BarrierAction(); break; case eActionType.CHANGE_SPEED: action = new ChangeSpeedAction(); break; case eActionType.WAVE_START_IDLE: action = new WaveStartIdleAction(); break; case eActionType.BUFF_DEBUFF: action = new BuffDebuffAction(); break; default: isSuccess = false; break; } return(action); }
public static ISpecialAction ReadSpecialAction(this NetIncomingMessage msg, SceneMgr mgr, Player owner = null) { //chtelo by to aby kazdej objekt implementoval sendable takhle nektery akce nepujdou pouzit ISpecialAction action = null; int hash = msg.ReadInt32(); if (hash == typeof(HealAction).GUID.GetHashCode()) { action = new HealAction(); } else if (hash == typeof(ActiveWeapon).GUID.GetHashCode()) { action = new ActiveWeapon(); } else if (hash == typeof(WeaponUpgrade).GUID.GetHashCode()) { action = new WeaponUpgrade(); } else if (hash == typeof(AsteroidDamage).GUID.GetHashCode()) { action = new AsteroidDamage(mgr, owner); } else if (hash == typeof(AsteroidGrowth).GUID.GetHashCode()) { action = new AsteroidGrowth(mgr, owner); } else if (hash == typeof(AsteroidSlow).GUID.GetHashCode()) { action = new AsteroidSlow(mgr, owner); } else if (hash == typeof(AsteroidThrow).GUID.GetHashCode()) { action = new AsteroidThrow(mgr, owner); } else if (hash == typeof(StaticField).GUID.GetHashCode()) { action = new StaticField(mgr, owner); } if (action != null) { action.ReadObject(msg); } return(action); }
public void HealAction_Heal_DecreaseCoins() { GameState state = new GameState(); state.CurrentPlayer = new Player(); state.CurrentPlayer.Initialize(10, 20, 10, 10); IAction healAction = new HealAction(); Assert.AreEqual(healAction.CanApply(state, config), true); ActionResultBase actionResult = healAction.Process(state, config); Assert.AreEqual(actionResult.IsSeccessful, true); Assert.AreEqual(state.CurrentPlayer.Coins, 0); Assert.AreEqual(state.CurrentPlayer.Health, 20); }
private void RPC_AddAction(string data, PhotonMessageInfo info) { string[] actionData = data.Split(','); Action actionToPerform = new Action(this); switch (actionData[1]) { case "hitShip": actionToPerform = new HitShipAction(this); break; case "move": actionToPerform = new MoveAction(this); break; case "search": actionToPerform = new SearchAction(this); break; case "repair": actionToPerform = new RepairAction(this); break; case "heal": actionToPerform = new HealAction(this); break; case "boostShields": actionToPerform = new BoostShieldsAction(this); break; case "share": actionToPerform = new ShareAction(this); break; case "suffocate": actionToPerform = new SuffocateAction(this); break; } actionToPerform.Deserialize(actionData); actions.Add(int.Parse(actionData[0]), actionToPerform); }
public HealActionResult Heal() { IAction healAction = new HealAction(); return(ProcessAction <HealActionResult>(healAction)); }
// HACK: ad-hoc placement code private void PlaceItems() { Weapon spear = new Weapon( new ItemParameter("spear", MaterialType.Wood) { AttackSpeed = 240, Damage = 200, ThrowRange = 7 }, Swatch.DbBlood, Game.Player.Loc - (1, 1)); Map.AddItem(spear); spear.Moveset = new Systems.MovesetHandler(new Systems.ActionNode( new Systems.ActionNode( new Systems.ActionNode( null, null, new MoveAction(new TargetZone(TargetShape.Range, 2)), "Leap"), null, new DamageAction(300, new TargetZone(TargetShape.Range, 1)), "Slam"), new Systems.ActionNode( null, null, new DamageAction(100, new TargetZone(TargetShape.Self, radius: 2)), "Whirlwind"), new DamageAction(100, new TargetZone(TargetShape.Directional, 2)), "Strike")); IAction heal = new HealAction(100, new TargetZone(TargetShape.Self)); Armor ha = new Armor( new ItemParameter("heavy armor", MaterialType.Iron) { AttackSpeed = 1000, Damage = 100, MeleeRange = 1, ThrowRange = 3 }, Swatch.DbMetal, Game.Player.Loc - (2, 3), ArmorType.Armor); Map.AddItem(ha); Map.AddItem(new Scroll( new ItemParameter("scroll of magic missile", MaterialType.Paper), Swatch.DbSun, Game.Player.Loc - (1, 2), new DamageAction( 200, new TargetZone(TargetShape.Directional, range: 10)))); Map.AddItem(new Scroll( new ItemParameter("scroll of healing", MaterialType.Paper), Swatch.DbGrass, Game.Player.Loc + (1, 1), heal)); Map.AddItem(new Scroll( new ItemParameter("scroll of enchantment", MaterialType.Paper), System.Drawing.Color.LightGreen, Game.Player.Loc - (1, 0), new EnchantAction( new TargetZone(TargetShape.Range, range: 10)))); Map.AddItem(new Scroll( new ItemParameter("scroll of fireball", MaterialType.Paper), Swatch.DbBlood, Game.Player.Loc - (2, 2), new DamageAction( 200, new TargetZone(TargetShape.Range, range: 10, radius: 3)))); Item planks = new Item( new ItemParameter("plank", MaterialType.Wood), Swatch.DbWood, '\\', Game.Player.Loc + (2, 2), 10); Item planks2 = new Item(planks, 10) { Loc = Game.Player.Loc + (3, 0) }; Item planks3 = new Item(planks, 10) { Loc = Game.Player.Loc + (0, 3) }; Item planks4 = new Item(planks, 10) { Loc = Game.Player.Loc + (3, 3) }; Map.AddItem(planks); Map.AddItem(planks2); Map.AddItem(planks3); Map.AddItem(planks4); }
public static ActionParameter GetActionParameterByActionType(eActionType actionType, out bool isSuccess) { ActionParameter action = new ActionParameter(); isSuccess = true; switch (actionType) { case eActionType.ATTACK: action = new AttackAction(); break; case eActionType.MOVE: action = new MoveAction(); break; case eActionType.KNOCK: action = new KnockAction(); break; case eActionType.HEAL: action = new HealAction(); break; case eActionType.BARRIER: action = new BarrierAction(); break; case eActionType.REFLEXIVE: //这个没有继承类,就用基类 action = new ActionParameter(); break; case eActionType.CHANGE_SPEED: action = new ChangeSpeedAction(); break; case eActionType.SLIP_DAMAGE: action = new SlipDamageAction(); break; case eActionType.BUFF_DEBUFF: action = new BuffDebuffAction(); break; case eActionType.BLIND: action = new BlindAction(); break; case eActionType.CHARGE_ENERGY: action = new ChargeEnergyAction(); break; case eActionType.DAMAGE_CHARGE: action = new DamageChargeAction(); break; case eActionType.NO_DAMAGE: action = new NoDamageAction(); break; case eActionType.GIVE_VALUE_AS_ADDITIVE: action = new GiveValueAdditiveAction(); break; case eActionType.GIVE_VALUE_AS_MULTIPLE: action = new GiveValueMultipleAction(); break; case eActionType.IF_FOR_AL: action = new IfForAllAction(); break; case eActionType.ACCUMULATIVE_DAMAGE: action = new AccumulativeDamageAction(); break; case eActionType.CHANGE_PARAMETER_FIELD: action = new ChangeParameterFieldAction(); break; case eActionType.WAVE_START_IDLE: action = new WaveStartIdleAction(); break; case eActionType.SKILL_EXEC_COUNT: action = new SkillExecCountAction(); break; default: isSuccess = false; break; } return(action); }
/// <inheritdoc/> public int Calculate(Character user, HealAction heal, Character target) { return(Math.Max(1, target.MaxHealth * heal.Amount / 100)); }
/// <inheritdoc/> public int Calculate(Character user, HealAction heal, Character target) { // ensure character cannot over-heal return(heal.Amount); }