public Character() { Party = new List <BasicMon>(); PC = new List <BasicMon>(); InCombat = false; InPvpCombat = false; Combat = null; }
public void ExitCombat() { InCombat = false; InPvpCombat = false; CombatRequest = 0; InCombatWith = 0; Combat = null; }
public CombatInstance GetCombat() { GameObject combat = m_combatPool.GetPooledObject(); CombatInstance ci = combat.GetComponent(typeof(CombatInstance)) as CombatInstance; ci.SetKillCallback(m_combatPool.Kill); return(ci); }
public CombatController() { combatScheduler = new CombatScheduler(); combatInstance = new CombatInstance(); roundNumber = 0; ScheduleNextRound(); }
public virtual void chooseSkill(CombatInstance instance) { Skill.SkillName randomSkill; int choice = Random.Range(0, skills.Count); randomSkill = skills.ToArray()[choice]; Skill.useSkill(randomSkill, this, instance.player); }
/// <summary> /// Attemps a regular combat attack(melee) against a target /// </summary> /// <returns>A combat instance object which contains all of the combat data /// that occurred during this attack.</returns> /// <param name="defender">The target to be attacked. Must implement ICombatCapable interface.</param> public CombatInstance RegularAttack(ICombatCapable defender) { CombatInstance currentAttack = new CombatInstance(); int damageToInflict = 0; /* * Bonus or pentalty in combat due to level differences * Positive if above target, negative if below */ double levelDifferenceModifier = Convert.ToDouble(this.CombatLevel - defender.CombatLevel) / 100.0D; double missChance = defender.EvasionChance() + (1.0D - this.StrikeChance()) - levelDifferenceModifier; //Damage to inflict will be progressively reduced currentAttack.BaseDamage = this.CalculateDamage(); damageToInflict = currentAttack.BaseDamage; //Roll for attack currentAttack.AttackRoll = this.SuccessRoll(); if (currentAttack.AttackRoll > missChance) { //Determine if defender is able to block(has a shield?) currentAttack.DefenderCanBlock = defender.CanBlock(); if (currentAttack.DefenderCanBlock) { //Roll to beat defender's block chance currentAttack.BypassBlockRoll = this.SuccessRoll(); if (currentAttack.BypassBlockRoll < defender.BlockChance()) { currentAttack.WasBlocked = true; currentAttack.DamageBlocked = defender.BlockAmount(); damageToInflict -= currentAttack.DamageBlocked; } else { //Attack got through block currentAttack.WasBlocked = false; } } //Attack was in some way successful //Do the armour damage reduction calculation currentAttack.DamageReducedByArmour = ArmourDamageReduction(damageToInflict, defender.ArmourValue()); damageToInflict -= currentAttack.DamageReducedByArmour; //Inflict the damage, and calculate how much was absorbed(determined by the defender) currentAttack.DamageAbsorbed = damageToInflict - defender.SufferDamage(damageToInflict); currentAttack.DamageInflicted = damageToInflict - currentAttack.DamageAbsorbed; } else { currentAttack.AttackSuccess = false; } return(currentAttack); }
public override void processDamage(CombatInstance instance, int dmg) { health -= dmg; //TODO: Display Combat Text if (health == 0) { die(); } }
public void PlayerLostIfDeadAndEnemiesLeft() { var enemyMock = new Mock <ICharacter>(); enemies.Add(enemyMock.Object); players.Clear(); // no players left combatInstance = new CombatInstance(players.ToArray(), enemyFactoryMock.Object); var result = combatInstance.Update(); Assert.IsFalse(result.PlayerWon); }
public void KillingBadGuysGeneratesGold() { var enemyMock = new Mock <ICharacter>(); enemyMock.Setup(f => f.GoldWorth).Returns(1234); enemyMock.Setup(f => f.IsDead()).Returns(true); enemies.Add(enemyMock.Object); combatInstance = new CombatInstance(players.ToArray(), enemyFactoryMock.Object); var result = combatInstance.Update(); Assert.AreEqual(1234, result.GainedGold); }
public override void processDamage(CombatInstance instance, int dmg) { health -= dmg; //TODO: Display Combat Text if (health == 0) { instance.expGive += expGive; instance.enemies.Remove(this); die(); } }
public void Setup() { playerMock = new Mock <ICharacter>(); players = new List <ICharacter>(); players.Add(playerMock.Object); eventRecipientMock = new Mock <IEventRecipient <ICombatUpdateEvent> >(); enemies = new List <ICharacter>(); enemyFactoryMock = new Mock <IEnemyFactory>(); enemyFactoryMock.Setup(f => f.GenerateEnemies()).Returns(enemies); timeMock = new Mock <ITimeProvider>(); timeMock.Setup(f => f.DeltaTime).Returns(1); // Since turnprogression is DeltaTime*speed this makes calculating it easier mockPlayerAttributes = new Mock <ICombatAttributes>(); playerMock.Setup(f => f.Attributes).Returns(mockPlayerAttributes.Object); walletMock = new Mock <IPlayerWallet>(); combatInstance = new CombatInstance(players.ToArray(), enemyFactoryMock.Object); }
public IEnumerator chooseSkill(TextManager manager, CombatInstance instance) { bool skillChosen = false; CombatMenu currMenu = CombatMenu.Start; while (!skillChosen) { manager.setupMenu(getOptions(currMenu, instance)); while (manager.mode != TextManager.ManagerMode.Standby) { yield return(null); } navigateMenu(currMenu, instance, manager.output); skillChosen = true; } }
private string[] getOptions(CombatMenu menu, CombatInstance instance) { List <string> result = new List <string>(); if (menu == CombatMenu.Start) { result.Add("Attack"); result.Add("Skill"); result.Add("Move"); } else if (menu == CombatMenu.Skills) { foreach (Skill.SkillName skill in skills) { result.Add(skill.ToString()); } } else if (menu == CombatMenu.Target) { int postFix = 0; bool incr = false; if (instance.enemies.Count > 1) { postFix = 1; incr = true; } foreach (Enemy enemy in instance.enemies) { if (incr) { postFix++; } result.Add(enemy.combatName + (incr ? " " + postFix : "")); } } return(result.ToArray()); }
public static void useSkill(SkillName sk, CombatEntity user, CombatEntity target) { if (sk == SkillName.Attack) { int damage = calculateDamage(user, target); List <string> text = new List <string>(); text.Add(user.combatName + " attacked " + target.combatName); text.Add(user.combatName + " did " + damage + " points of damage"); GameObject.FindObjectOfType <TextManager>().addToQueue(text.ToArray()); CombatInstance instance = GameObject.FindObjectOfType <CombatInstance>(); target.processDamage(instance, damage); //actually process the damage to the target } else if (sk == SkillName.Inspect) { List <string> text = new List <string>(); text.Add(user.combatName + " inspected " + target.combatName); GameObject.FindObjectOfType <TextManager>().addToQueue(text.ToArray()); CombatEntity.displayStats(target, GameObject.FindObjectOfType <TextManager>()); } }
public async Task InitiateRaid(SocketGuildChannel channel) { ContextIds idList = new ContextIds(Context); idList.ChannelId = channel.Id; var user = UserHandler.GetUser(idList.UserId); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.UserInCombat(idList); await UserHandler.UserHasNoCards(idList, user); } catch (InvalidUserStateException) { return; } //Start raid CombatInstance combat = new CombatInstance(idList); combat.IsDuel = false; var combatId = CombatHandler.NumberOfInstances(); combat.CombatId = combatId; user.CombatRequest = 0; user.CombatID = combatId; await combat.AddPlayerToCombat(user, combat.CreateNewTeam()); //await MessageHandler.SendMessage(idList, $"{user.ActiveCards[0].Name} is attacking #{channel.Name}! Combat will begin in 10 minutes.\n```\nUse 0.joincombat to join\n```"); await MessageHandler.SendMessage(idList, $"{user.ActiveCards[0].Name} challenges the party! Combat will begin in 3 minutes.\n```\nUse 0.joincombat to join\n```"); CombatHandler.StoreInstance(combatId, combat); }
public async Task Duel(SocketGuildUser target) { var fromUser = UserHandler.GetUser(Context.User.Id); var toUser = UserHandler.GetUser(target.Id); ContextIds idList = new ContextIds(Context); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.UserInCombat(idList); await UserHandler.OtherUserInCombat(idList, toUser); await UserHandler.UserHasNoCards(idList, fromUser); await UserHandler.OtherUserHasNoCards(idList, fromUser, toUser); } catch (InvalidUserStateException) { return; } //Check that the user did not target themself with the command if (fromUser.UserId != toUser.UserId) { //Set the current user's combat request ID to the user specified fromUser.CombatRequest = toUser.UserId; //Check if the specified user has a combat request ID that is the current user's ID if (toUser.CombatRequest == fromUser.UserId) { //Start duel CombatInstance combat = new CombatInstance(idList); combat.IsDuel = true; var combatId = CombatHandler.NumberOfInstances(); combat.CombatId = combatId; fromUser.CombatRequest = 0; fromUser.CombatID = combatId; await combat.AddPlayerToCombat(fromUser, combat.CreateNewTeam()); toUser.CombatRequest = 0; toUser.CombatID = combatId; await combat.AddPlayerToCombat(toUser, combat.CreateNewTeam()); CombatHandler.StoreInstance(combatId, combat); await CombatHandler.InitiateDuel(combat); } else { //Challenge the specified user await Context.Channel.SendMessageAsync($"{target.Mention}, you have been challenged to a duel by {Context.User.Mention}\nUse the \"0.duel [mention target]\" command to accept."); } } else { //Tell the current user they have are a dum dum await Context.Channel.SendMessageAsync($"{Context.User.Mention}, stop hitting yourself!"); } }
public async Task Duel(SocketGuildUser target) { var fromUser = UserHandler.GetUser(Context.User.Id); var toUser = UserHandler.GetUser(target.Id); ContextIds idList = new ContextIds(Context); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.OtherCharacterExists(idList, toUser); await UserHandler.ValidCharacterLocation(idList); await UserHandler.OtherCharacterLocation(idList, toUser); } catch (InvalidCharacterStateException) { return; } //Check that the user did not target themself with the command if (fromUser.UserId != toUser.UserId) { //Set the current user's combat request ID to the user specified fromUser.Char.CombatRequest = toUser.UserId; //Check if the specified user has a combat request ID that is the current user's ID if (toUser.Char.CombatRequest == fromUser.UserId) { //Make sure neither users are in combat while sending response request if (fromUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot start a duel while in combat!"); } else if (toUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot start a duel with a player who is in combat!"); } else { //Start duel var combat = new CombatInstance(idList, Context.User.Id, target.Id); await Context.Channel.SendMessageAsync($"The duel between {target.Mention} and {Context.User.Mention} will now begin!"); fromUser.Char.InCombat = true; fromUser.Char.InPvpCombat = true; fromUser.Char.CombatRequest = 0; fromUser.Char.InCombatWith = toUser.UserId; fromUser.Char.Combat = new CombatInstance(idList, fromUser.UserId, toUser.UserId); toUser.Char.InCombat = true; toUser.Char.InPvpCombat = true; toUser.Char.CombatRequest = 0; toUser.Char.InCombatWith = fromUser.UserId; toUser.Char.Combat = new CombatInstance(idList, toUser.UserId, fromUser.UserId); await CombatHandler.StartCombat(fromUser.Char.Combat); } } else { //Make sure neither users are in combat while sending initial request if (fromUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot request a duel when you are in combat!"); } else if (toUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot duel a player who is in combat!"); } else { //Challenge the specified user await Context.Channel.SendMessageAsync($"{target.Mention}, you have been challenged to a duel by {Context.User.Mention}\nUse the \"duel [mention target]\" command to accept."); } } } else { //Tell the current user they have are a dum dum await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot duel yourself."); } }
public void StartCombat(CombatManager combatManager, CombatInstance combatInstance) { Assert.IsTrue(IsMine); AudioClip prevMusic = combatInstance.GetPreviousMusic(); //FindObjectOfType<GameManager>().GetComponent<MusicManager>().Music.clip; AudioClip fightMusic = combatInstance.GetCombatMusic(); combatManager.Construct(combatInstance); PhotonNetwork.Spawn(combatManager.photonView); }
public abstract void processDamage(CombatInstance instance, int dmg);
public bool Event_ThrowItem(ComponentEvent e) { AreaMap map = Engine.instance.world.currentMap; var throwEvent = ((EThrowItem)e); string itemType = throwEvent.itemName; // try to find the item on the entity to throw it var consumeItemEvent = (EConsumeItem)owner.FireEvent(new EConsumeItem() { itemName = itemType }); if (!consumeItemEvent.hasItem) { return(true); } // This enttiy did have the item to throw Entity projectile = consumeItemEvent.consumedItem; // Get the thrwoer strength and item weight, in order to calc both damage and max throw distance var getStrength = (EGetAttributeLevel)owner.FireEvent(new EGetAttributeLevel() { target = "strength" }); int strength = getStrength.level; float strRatio = (strength / 100.0f); var getWeight = (EGetWeight)owner.FireEvent(new EGetWeight()); int thrownWeight = getWeight.weight; float maxDistance = CombatEngine.GetThrowRange(owner, projectile); int throwDamage = (int)(strRatio * thrownWeight); // if the target position is farther than the max distance, select the nearest point in that direction Vector2 targetLoc = throwEvent.targetLocation; Vector2 toTarget = targetLoc - owner.position; if (toTarget.Magnitude() > maxDistance) { Vector2 dir = toTarget.Normalized(); targetLoc = owner.position + (dir * maxDistance); } // check where the item hits, if there is something in the way Vector2 hitNormal; Vector2 endPosition = map.CollisionPointFromTo(owner.position, targetLoc, out hitNormal); // find the target to hit, and apply some damage and knock them back Entity[] targets = map.GetAllObjectsAt(endPosition.X, endPosition.Y); foreach (Entity hit in targets) { CombatInstance combat = new CombatInstance(owner, hit) { { "damage", throwDamage }, { "weapon", projectile } }; CombatEngine.ProcessCombat(combat); } // the thrown item ends up next to the target location, or the nearest valid location toTarget = Vector2.OrthoNormal(toTarget); endPosition = endPosition - toTarget; endPosition = map.GetNearestValidMove(endPosition); Engine.instance.world.SpawnExisting(projectile, endPosition); return(true); }
public static List <Embed> RoundStart(CombatInstance inst) { List <Embed> embeds = new List <Embed>(); var builder = new EmbedBuilder() .WithAuthor($"Round: {inst.RoundNumber}"); var players = ""; List <string> effectTitles = new List <string>(); List <List <string> > effects = new List <List <string> >(); int cardCount = 1; foreach (BasicCard card in inst.CardList) { List <string> currentPlayerEffects = new List <string>(); string shields = ""; if (card.Effects.Count > 0 || card.Markers.Count > 0 || card.HasPassive) { effectTitles.Add($"({card.Signature})"); } var light = 0; var medium = 0; var heavy = 0; foreach (BuffDebuff eff in card.Effects) { light += eff.LightShield; medium += eff.MediumShield; heavy += eff.HeavyShield; currentPlayerEffects.Add($"\n{eff.ToString()}"); } if (card.HasPassive) { currentPlayerEffects.Add($"\n**{card.Passive.Name} ({card.Signature}'s Passive)**- {card.Passive.Description}"); } if (light > 0) { shields += $"{light} light shields. "; } if (medium > 0) { shields += $"{medium} medium shields. "; } if (heavy > 0) { shields += $"{heavy} heavy shields."; } foreach (Marker mark in card.Markers) { currentPlayerEffects.Add($"\n{mark.ToString()}"); } //if(card.Effects.Count > 0 || card.Markers.Count > 0 || card.HasPassive) //currentPlayerEffects.Add("\n.\n"); if (card.Name.Equals(card.Signature)) { players += $"{cardCount}. **[{card.Name}]:** {card.CurrentHP}/{card.TotalHP} HP {shields}\n"; } else { players += $"{cardCount}. **[{card.Name}] {card.Signature}:** {card.CurrentHP}/{card.TotalHP} HP {shields}\n"; } if (currentPlayerEffects.Count == 0) { currentPlayerEffects.Add("none"); } effects.Add(currentPlayerEffects); cardCount++; } builder.WithDescription(players); //builder.AddField("ACTIVE EFFECTS", finalEffects, false); builder.WithFooter($"It is {inst.CardList[inst.TurnNumber].Signature}'s turn."); builder.WithColor(62, 62, 255); var embed = builder.Build(); embeds.Add(embed); /*REDACTED ACTIVE EFFECTS SECTION * effects.Reverse(); * effectTitles.Reverse(); * while(effects.Count > 0) * { * Console.WriteLine("k"); * var bail = false; * var effBuilder = new EmbedBuilder() * .WithAuthor($"**ACTIVE EFFECTS**") * .WithFooter($"It is {inst.CardList[inst.TurnNumber].Signature}'s turn."); * Console.WriteLine("l"); * * for (int i = effects.Count - 1; i >= 0; i--) * { * Console.WriteLine("m"); * var playerEffects = ""; * int totalChars = 0; * for (int j = effects[i].Count - 1; j >= 0; j--) * { * Console.WriteLine("n"); * totalChars += effects[i][j].Length; * Console.WriteLine("o"); * if(totalChars < 1024) * { * Console.WriteLine("p"); * playerEffects += $"{effects[i][j]}\n"; * Console.WriteLine("q"); * effects[i].RemoveAt(j); * Console.WriteLine("r"); * } * else * { * Console.WriteLine("s"); * effBuilder.AddField($"{effectTitles[i]}", $"{playerEffects}", false); * Console.WriteLine("t"); * bail = true; * Console.WriteLine("u"); * break; * } * } * Console.WriteLine("v"); * if(bail) * break; * Console.WriteLine("w"); * effBuilder.AddField($"{effectTitles[i]}", $"{playerEffects}", false); //This line is stupid and why we archived this * Console.WriteLine("x"); * //effectTitles.RemoveAt(i); * effects.RemoveAt(i); * Console.WriteLine("y"); * } * Console.WriteLine("z"); * embeds.Add(effBuilder.Build()); * Console.WriteLine("za"); * } * Console.WriteLine("zb");*/ return(embeds); }
public CombatManager StartCombat(CombatInstance combatInstance) { Assert.IsTrue(IsMine); CombatManager newManager = PhotonNetwork.Instantiate<CombatManager>(m_defaultCombatManager, Vector3.zero, Quaternion.identity, 0); StartCombat(newManager, combatInstance); return newManager; }
private void navigateMenu(CombatMenu menu, CombatInstance instance, int option) { }
private void Update() { if (!m_gameBoard) { m_gameBoard = GetComponentInParent(typeof(GameBoard)) as GameBoard; } float unitDistance = m_gameBoard.GetUnitDistance(); foreach (Pawn pawn in m_pawns) { if (pawn) { // check pawn in front in current tile or the tile in the direction of attack/move Vector3 direction = GetPawnDirection(pawn); // if not in combat, check if any enemy pawn is standing infront if (!pawn.isInCombat) { Pawn other = null; if (pawn.isMovingToFreePlace) { // we reached the place we go towards, then change to another float posX = m_gameBoard.tiles[pawn.m_tilePositionX, pawn.m_tilePositionY].transform.position.x - 0.5f; float posY = m_gameBoard.tiles[pawn.m_tilePositionX, pawn.m_tilePositionY].transform.position.y - 0.5f; posX += unitDistance * pawn.m_subTilePositionX + 0.1f; posY += unitDistance * pawn.m_subTilePositionY; Vector3 desiredPosition = new Vector3(posX, posY, 0.0f); if ((pawn.transform.position.x >= (desiredPosition.x - 0.05f)) && (pawn.transform.position.x <= (desiredPosition.x + 0.05f)) && (pawn.transform.position.y >= (desiredPosition.y - 0.05f)) && (pawn.transform.position.y <= (desiredPosition.y + 0.05f))) { pawn.isMovingToFreePlace = false; pawn.transform.position = desiredPosition; } else { Vector3 newPosition = new Vector3(direction.x * unitDistance * m_speed, direction.y * unitDistance * m_speed, direction.z * unitDistance * m_speed); pawn.transform.position += newPosition; } } else if (!IsNextTileReserved(direction, pawn, ref other)) { pawn.isMovingToFreePlace = true; } else { if (other) { if (other.armyId == pawn.armyId) { // nothing to do continue; } // create combat instance CombatInstance combatInstance = m_gameBoard.GetCombat(); combatInstance.SetCombat(pawn, other); } } } } } RecalculateNumberOfPawn(); RecalculateWeight(); }
// Use this for initialization void Start() { playerScript = Player.createPlayer(CombatEntity.Job.Ranger); playerScript.combatName = "Raptura"; instance = FindObjectOfType <CombatInstance>(); }