public void InitializeHeroPawns() { // For each herodata, create an actual pawn for (int i = 0; i < heroesData.Count; i++) { HeroData heroData = heroesData[i]; GameObject tempHero = Instantiate(heroPrefab, new Vector3(10, 0, 0), Quaternion.identity) as GameObject; HeroPawn tempHeroPawn = tempHero.GetComponent <HeroPawn>(); tempHero.name = heroData.displayName; Animator tempHeroAnim = tempHero.GetComponent <Animator>(); tempHeroAnim.runtimeAnimatorController = heroData.animatorController; tempHeroPawn.heroData = heroData; tempHeroPawn.weaponCondition = Random.Range(minStartCondition, maxStartCondition); tempHeroPawn.armorCondition = Random.Range(minStartCondition, maxStartCondition); tempHeroPawn.gold = tempHeroPawn.heroData.startingGold; tempHeroPawn.relationships = new List <float>(); for (int relationshipIndex = 0; relationshipIndex < heroesData.Count; relationshipIndex++) { tempHeroPawn.relationships.Add(0); } heroes.Add(tempHeroPawn); } // Now that heroes exist, we can give them relationships InitializeRelationships(); }
public virtual void OnTriggerEnter2D(Collider2D other) { HeroPawn OtherActor = other.gameObject.GetComponentInParent <HeroPawn>(); if (OtherActor) { OtherActor.TakeDamage(this, damageAmount, new DamageEventInfo(), Owner); OnDeath(); } else if (other.gameObject.GetComponent <Grenade>() || other.gameObject.GetComponent <GrenadeLeft>()) { if (other.gameObject.GetComponent <Grenade>()) { other.gameObject.GetComponent <Grenade>().OnDeath(); } else { other.gameObject.GetComponent <GrenadeLeft>().OnDeath(); } OnDeath(); } else if (other.gameObject.GetComponent <HammerDamage>()) { OnDeath(); } }
public virtual void OnTriggerEnter2D(Collider2D other) { HeroPawn OtherActor = other.gameObject.GetComponentInParent <HeroPawn>(); if (OtherActor) { OtherActor.TakeDamage(this, damageAmount, new DamageEventInfo(), Owner); } }
private void OnTriggerEnter2D(Collider2D collision) { HeroPawn OtherActor = collision.gameObject.GetComponentInParent <HeroPawn>(); if (OtherActor) { OtherActor.TakeDamage(this, damageAmount, null, Owner); } }
public void HeroesToYourStartingPositions() { // Move pawn to their appropriate start locations for (int i = 0; i < heroes.Count; i++) { HeroPawn hero = heroes[i]; hero.StartCoroutine(hero.MoveTo(shop.beforeShoppingIdlePoints[i].position)); } }
public override void Fire3(bool value) { HeroPawn HP = ((HeroPawn)PossesedPawn); if (HP) { HP.Fire3(value); } }
public override void Horizontal(float value) { HeroPawn HP = ((HeroPawn)PossesedPawn); if (HP) { HP.Horizontal(value); } }
public void UpdateCharacterWindow(HeroPawn hero) { characterNameBox.text = hero.heroData.displayName; characterDescriptionBox.text = hero.heroData.biographyText; characterAttackBox.text = "" + Mathf.Floor(GameManager.instance.ValueBasedOnDurability(hero.heroData.attack, hero.weaponCondition)); characterAttackBox.text += " ATK\n(" + ToPercent(hero.weaponCondition) + ")"; characterDefenseBox.text = "" + Mathf.Floor(GameManager.instance.ValueBasedOnDurability(hero.heroData.defense, hero.armorCondition)); characterDefenseBox.text += " DEF\n(" + ToPercent(hero.armorCondition) + ")"; characterGoldBox.text = hero.gold + " gp"; characterHealthBox.text = hero.heroData.health + " hp"; characterImage.sprite = hero.heroData.displaySprite; int currentRelationshipBox = 0; // For each of the heroes in the game for (int otherHeroIndex = 0; otherHeroIndex < GameManager.instance.heroes.Count; otherHeroIndex++) { // If this relationship is with yourself, skip this hero if (hero == GameManager.instance.heroes[otherHeroIndex]) { Debug.Log("Skipping relationship with self!"); continue; } // Otherwise else { // Enable the relationship box relationshipImages[currentRelationshipBox].characterImage.gameObject.SetActive(true); //Set the image relationshipImages[currentRelationshipBox].characterImage.sprite = GameManager.instance.heroes[otherHeroIndex].heroData.displaySprite; // Set the relationship value relationshipImages[currentRelationshipBox].RelationshipImage.fillAmount = hero.relationships[otherHeroIndex] / GameManager.instance.maxRelationshipLevel; // Advance to next relationshipbox currentRelationshipBox++; // If we are out of boxes, we have to quit if (currentRelationshipBox >= relationshipImages.Count) { Debug.Log("More heroes than boxes."); break; } } } // If there are leftover relationship boxes, disable them for (int i = currentRelationshipBox; i < relationshipImages.Count; i++) { Debug.Log("Turning off leftover box #" + i); relationshipImages[i].characterImage.gameObject.SetActive(false); } }
public virtual void OnTriggerStay2D(Collider2D other) { HeroPawn OtherActor = other.gameObject.GetComponentInParent <HeroPawn>(); if (OtherActor) { player = other.gameObject; playerFinder.enabled = !playerFinder.enabled; } }
private void Awake() { camPointNumber = -1; nextMovePointHero = -1; SearchDestroyCopySingletonOrThisCreateInstance(); m_HeroPawn = FindObjectOfType <HeroPawn>(); m_HeroTransform = m_HeroPawn.gameObject.GetComponent <Transform>(); m_HeroPawn.fakeSwordCollider.enabled = false; m_Camera = Camera.main; camTransform = m_Camera.gameObject.transform; GetWeaponOffValue(); CurrentWeaponHero = WeaponHero.Sword; foreach (EnemyRoom er in enemyInRoom) { foreach (GameObject go in er.enemyGO) { er.enemyPW.Add(go.GetComponentInChildren <EnemyPawn>()); er.enemyPWGO.Add(er.enemyPW[er.enemyPW.Count - 1].gameObject); go.SetActive(false); } } levelOfComplexity = PlayerPrefs.HasKey("LevelOfComplexity") ? PlayerPrefs.GetFloat("LevelOfComplexity") : 0.75f; weaponLightingPrefab = Resources.Load("WeaponMagicLightingCircle") as GameObject; weaponLightingGO = Instantiate(weaponLightingPrefab); weaponLightingTransform = weaponLightingGO.transform; weaponLightingRB = weaponLightingGO.GetComponent <Rigidbody2D>(); weaponLightingGO.SetActive(false); weaponWaterBallPrefab = Resources.Load("WeaponMagicWaterBall") as GameObject; weaponFireBallPrefab = Resources.Load("WeaponMagicFireBall") as GameObject; weaponIceBallPrefab = Resources.Load("WeaponMagicIceBall") as GameObject; }
public QuestOutcome DetermineBattleOutcome(List <HeroPawn> heroes, QuestData quest) { // Takes in party and quest, determines battle outcomes QuestOutcome results = new QuestOutcome(); // Aggregate total party float heroAggregateHealth = 0; float heroAggregateAttack = 0; float heroAggregateDefense = 0; foreach (HeroPawn hero in heroes) { heroAggregateAttack += ValueBasedOnDurability(hero.heroData.attack, hero.weaponCondition); heroAggregateDefense += ValueBasedOnDurability(hero.heroData.defense, hero.armorCondition); heroAggregateHealth += hero.heroData.health; // Since durability hits EVERY fight, We can reduce durability here, and save us another iteration through heroes hero.weaponCondition -= Random.Range(quest.minDurabilityDamage, quest.maxDurabilityDamage); hero.armorCondition -= Random.Range(quest.minDurabilityDamage, quest.maxDurabilityDamage); } // Add advantages -- be sure to check for monster changes foreach (HeroPawn hero in heroes) { float bonusModifier = 1.0f; // Start at full bonus // iterate through disadvantages bool foundDisadvantage = false; foreach (Disadvantage disadvantage in hero.heroData.disadvantages) { // iterate through monsters foreach (MonsterData monster in quest.monsters) { // Iterate through each monsters set of types foreach (MonsterTag tag in monster.modifiers) { // if we find one of those types in our disadvantage, note it and quit if (disadvantage.against.Contains(tag)) { // TODO: Add event about the disadvantage Debug.Log(hero.heroData.displayName + " is terrified of the " + tag.displayName + " " + monster.displayName); foundDisadvantage = true; break; } } // If I found a disadvantage, I don't need to look at other monsters if (foundDisadvantage) { break; } } // If I found a disadvantage, I don't need to look at other disadvantages if (foundDisadvantage) { break; } } // If we found a disadvantage if (foundDisadvantage) { // create a bonus modifier based on average relationships bonusModifier = bonusEffectByRelationshipAverageCurve.Evaluate(AveragePartyRelationship(heroes) / maxRelationshipLevel); } // Otherwise, our bonus modifier is still 1.0 else { bonusModifier = 1.0f; } // iterate through advantages foreach (Advantage advantage in hero.heroData.advantages) { //Apply "advantage.amount * modifier* and add to aggregates if (advantage.statistic == Stat.Attack) { heroAggregateAttack += advantage.bonusAmount * bonusModifier; Debug.Log("The power of friendship adds " + (advantage.bonusAmount * bonusModifier) + " | " + bonusModifier + " / " + advantage.bonusAmount + " attack."); } if (advantage.statistic == Stat.Health) { heroAggregateHealth += advantage.bonusAmount * bonusModifier; Debug.Log("The power of friendship adds " + (advantage.bonusAmount * bonusModifier) + " | " + bonusModifier + " / " + advantage.bonusAmount + " health."); } if (advantage.statistic == Stat.Defense) { heroAggregateDefense += advantage.bonusAmount * bonusModifier; Debug.Log("The power of friendship adds " + (advantage.bonusAmount * bonusModifier) + " | " + bonusModifier + " / " + advantage.bonusAmount + " defense."); } } } // NOTE: DO NOT CHANGE MONSTERS. Make temp monsters and change the temp ones float monsterAggregateHealth = 0; float monsterAggregateAttack = 0; float monsterAggregateDefense = 0; foreach (MonsterData monster in quest.monsters) { monsterAggregateAttack += monster.attack; monsterAggregateDefense += monster.defense; monsterAggregateHealth += monster.health; } // Track number of rounds int numberOfRounds = 0; // As long as the monsters are alive while (monsterAggregateHealth > 0) { // Increase round count numberOfRounds++; // Damage monsters float damageDone = Mathf.Max(1, (heroAggregateAttack * Random.Range(minHeroBattleChance, maxHeroBattleChance)) - (monsterAggregateDefense * Random.Range(minMonsterBattleChance, maxMonsterBattleChance))); monsterAggregateHealth -= damageDone; Debug.Log("The party does " + damageDone + " damage. The monster party has a total of " + monsterAggregateHealth + " health left!"); // If monster dead, break. if (monsterAggregateHealth <= 0) { break; } // Damage players damageDone = Mathf.Max(1, (monsterAggregateAttack * Random.Range(minMonsterBattleChance, maxMonsterBattleChance)) - (heroAggregateDefense * Random.Range(minHeroBattleChance, maxHeroBattleChance))); heroAggregateHealth -= damageDone; Debug.Log("The monster party does " + damageDone + " damage. The party has a total of " + heroAggregateHealth + " health left!"); // If players dead, break if (heroAggregateHealth <= 0) { break; } } // If monsters are dead, success. if (monsterAggregateHealth <= 0) { // Add gold to all players foreach (HeroPawn hero in heroes) { // Divide gold among heroes, leftovers are destroyed into the ether hero.gold += (int)(quest.goldReward / heroes.Count); //Update relationships foreach (HeroPawn otherHero in heroes) { if (otherHero != hero) { // Find where they are in the main heroes list int heroID = 0; for (int i = 0; i < GameManager.instance.heroes.Count; i++) { if (otherHero != hero && otherHero == GameManager.instance.heroes[i]) { heroID = i; break; } } hero.relationships[heroID] += increaseToRelationshipPerMission; Debug.Log(hero.heroData.displayName + " and " + GameManager.instance.heroes[heroID].heroData.displayName + " high five."); } } } // Add success events to the event list // TODO: Don't do one per round, that's too many. Maybe one per person. for (int i = 0; i < numberOfRounds; i++) { // Pick a random hero HeroPawn chosenOne = heroes[Random.Range(0, heroes.Count)]; // TODO: Pick a random string from the hero's success events string eventString = chosenOne.name + " stabs the vile beast in the face."; // TODO: Add the finalized (no variables) version of that string to the list of outcome events. results.events.Add(eventString); } } // Else failed mission else { // No change to relationships // No change to gold // Add fail events to the event list // TODO: Don't do one per round, that's too many. Maybe one per person. for (int i = 0; i < numberOfRounds; i++) { // Pick a random hero HeroPawn chosenOne = heroes[Random.Range(0, heroes.Count)]; // TODO: Pick a random string from the hero's success events string eventString = chosenOne.name + " stumbles."; // TODO: Add the finalized (no variables) version of that string to the list of outcome events. results.events.Add(eventString); } } return(results); }