public static void Main() { var demonsList = Console.ReadLine().Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray(); string namePattern = @"[^0-9+\-*\/\.]"; string damagePattern = @"[+-]?\d+(?:\.?\d+)?"; var deamonsBook = new List <Demon>(); foreach (var demonName in demonsList) { int currentDemonHealt = CalculatingHealth(demonName, namePattern); double currentDemonDamage = CalculatingDamage(demonName, damagePattern); Demon newDemon = new Demon { Name = demonName, Health = currentDemonHealt, Damage = currentDemonDamage }; deamonsBook.Add(newDemon); } foreach (Demon demon in deamonsBook.OrderBy(n => n.Name)) { Console.WriteLine($"{demon.Name} - {demon.Health} health, {demon.Damage:f2} damage"); } }
internal static Demon Parse(string demonName) { string name = demonName; Regex healthPattern = new Regex(@"[^\d\-*\/\.]"); Regex damagePattern = new Regex(@"-?\d+(?:\.\d+)?"); var health = healthPattern.Matches(demonName) .Cast <Match>() .Select(x => (int)char.Parse(x.Value)) .Sum(); var damage = damagePattern.Matches(demonName) .Cast <Match>() .Select(x => decimal.Parse(x.Value)) .Sum(); var multiply = demonName.Count(x => x == '*'); var divide = demonName.Count(x => x == '/'); damage *= (int)Math.Pow(2, multiply); damage /= (int)Math.Pow(2, divide); Demon demon = new Demon { Name = name, Health = health, Damage = damage }; return(demon); }
void Update() { setAnimation("falling", isOnGround ? 0 : catRigidbody.velocity.y); if (catRigidbody.velocity.x == 0 && catRigidbody.velocity.y == 0) { GetComponent <Animator>().Play("Nothing"); } setAnimation("running", Mathf.Abs(catRigidbody.velocity.x)); if (!mobilePad) { foreach (Axe anAxe in Enum.GetValues(typeof(Axe))) { axes[anAxe] = Mathf.Clamp(Input.GetAxis(axeToString(anAxe)), -1, 1); } } if (axes[Axe.EGZORCISM] != 0) { Demon demon = getClosestPossesedItem(); if (demon != null) { demon.CatSeesMe(); if (!lockDrain) { setAnimation(Axe.EGZORCISM, true); } demon.drainPower(Time.deltaTime * 10, this); lockDrain = true; } } }
void Update() { prevPos = transform.position; if (itemId == ItemId.musketBall) { transform.Translate(0, 0, bulletSpeed * Time.deltaTime); } else { transform.Translate(0, 0, bulletSpeed * Time.deltaTime); } Vector3 posDifference = transform.position - prevPos; RaycastHit[] hits = Physics.RaycastAll(new Ray(prevPos, posDifference.normalized)); for (int i = 0; i < hits.Length; i++) { if (hits[i].collider.gameObject.GetComponent <Demon>()) { Demon demon = hits[i].collider.gameObject.GetComponent <Demon>(); demon.setHP(demon.getHP() - bulletDamage); Destroy(gameObject); break; } else if (hits[i].collider.gameObject.tag == "environment") { Debug.Log(hits[i].collider.gameObject.name); Destroy(gameObject); } } }
static void Main(string[] args) { string healthPattern = @"[0-9+\-*\/.]"; string[] input = Console.ReadLine() .Split(new string[] { ", ", ",", " " }, StringSplitOptions.RemoveEmptyEntries) .ToArray(); List <Demon> demons = new List <Demon>(); foreach (string demon in input) { //bool isNameValid = IsNameValid(demon); //if (isNameValid) //{ string onlyLetters = Regex.Replace(demon, healthPattern, ""); int health = HealthCalculator(onlyLetters); double damage = DamageCalculator(demon); Demon currDemon = new Demon(); currDemon.Name = demon; currDemon.Health = health; currDemon.Damage = damage; demons.Add(currDemon); //} } demons = demons.OrderBy(n => n.Name).ToList(); foreach (var demon in demons) { Console.WriteLine($"{demon.Name} - {demon.Health} health, {demon.Damage:f2} damage"); } }
static void Main() { string[] demons = Console.ReadLine() .Split(new char[] { ' ', ',', '\t' }, StringSplitOptions.RemoveEmptyEntries); List <Demon> book = new List <Demon>(); for (int i = 0; i < demons.Length; i++) { Demon demon = new Demon(); demon.Name = demons[i]; demon.Health = GetDemonHealth(demons[i]); demon.Damage = GetDemonDamage(demons[i]); book.Add(demon); } book = book.OrderBy(x => x.Name).ToList(); foreach (Demon dem in book) { Console.WriteLine($"{dem.Name} - {dem.Health} health, {dem.Damage:F2} damage"); } }
// OnCollisionEnter2D is called when this collider2D/rigidbody2D has begun touching another rigidbody2D/collider2D (2D physics only) private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.CompareTag("Demon")) { Debug.Log("Hit demon"); Demon hitDemon = collision.collider.gameObject.GetComponent <Demon>(); if (hitDemon.Damage(damage)) { penetration--; if (penetration < 0) { Destroy(gameObject); } } } else if (collision.collider.CompareTag("Person")) { Debug.Log("Hit person"); Person person = collision.collider.gameObject.GetComponent <Person>(); person.influenceLevel += damage / 10f; penetration--; if (penetration < 0) { Destroy(gameObject); } } }
static void Main(string[] args) { Dictionary <string, Demon> dataBase = new Dictionary <string, Demon>(); Regex demonReg = new Regex(@"[^ ,]+(?=(,| |))"); Regex healthReg = new Regex(@"[^0-9\+\.\*\/-]"); Regex damageReg = new Regex(@"[\+\-]?[0-9]*\.?[0-9]+"); string input = Console.ReadLine(); var demons = demonReg.Matches(input).Cast <Match>().Select(n => n.Value).ToList(); foreach (var demon in demons) { var currentHealth = CalculateTheHealth(healthReg, demon); var currentDamage = CalculateTheDamage(damageReg, demon); var currentDemon = new Demon(currentHealth, currentDamage); dataBase[demon] = currentDemon; } foreach (var demon in dataBase.OrderBy(n => n.Key)) { Console.WriteLine($"{demon.Key} - {demon.Value.Health} health, {demon.Value.Damage:f2} damage"); } }
private static void CreateMonsters() // Just because i want random kind of monsters, in different lvls i go through this loop. And the settings gives them random lvls and names. { for (int i = 0; i < 15; i++) { Dragon dragon = new Dragon(); fireMonsters.Add(dragon); Demon demon = new Demon(); fireMonsters.Add(demon); Tortoise tortoise = new Tortoise(); waterMonsters.Add(tortoise); SwampTroll troll = new SwampTroll(); waterMonsters.Add(troll); Crocodile croc = new Crocodile(); waterMonsters.Add(croc); RabiesBear bear = new RabiesBear(); grassMonsters.Add(bear); Wasp wasp = new Wasp(); grassMonsters.Add(wasp); Scarab scarab = new Scarab(); grassMonsters.Add(scarab); } DragonLord dL = new DragonLord(); // but only one dragon lord. fireMonsters.Add(dL); }
public List <DemonGroup> GetDemonFusions(Demon target) { List <DemonGroup> combos = new List <DemonGroup>(); List <DemonResult> results = new List <DemonResult>(); List <Demon> limits = new List <Demon>(m_Demons.Where(o => o.race == target.race).OrderBy(o => o.grade)); int targetGrade = 0; int topGrade = 200; for (int i = 0; i < limits.Count; i++) { if (target.grade > limits[i].grade) { targetGrade = limits[i].grade; } else { topGrade = limits[i].grade; break; } } for (int i = 0; i < m_Results.Count; i++) { if (m_Results[i].result == target.race) { results.Clear(); List <Demon> race1 = new List <Demon>(m_Demons.Where(o => o.race == m_Results[i].source1)); List <Demon> race2 = new List <Demon>(m_Demons.Where(o => o.race == m_Results[i].source2)); for (int a = 0; a < race1.Count; a++) { for (int b = 0; b < race2.Count; b++) { Demon d1 = race1[a]; Demon d2 = race2[b]; int avgGrade = 1 + Mathf.FloorToInt((d1.grade + d2.grade) / 2f); if (avgGrade > targetGrade && avgGrade <= topGrade) { bool doAdd = true; for (int c = 0; c < results.Count; c++) { if (results[c].d1 == d1 && results[c].d2 == d2) { doAdd = false; break; } } if (doAdd) { results.Add(new DemonResult(d1, d2)); } } } } combos.Add(new DemonGroup(results)); } } return(combos); }
public void Activate(Demon demon) { this.demon = demon; summonImage.sprite = demon.icon; sellButtonText.text = string.Format("Sell {0} [${1}]", demon.demonName, demon.worth); gameObject.SetActive(true); demon.PlayAudio(); }
public void StartOffering(Demon demon) { moveTarget = demon.gameObject; this.demon = demon; animator.SetTrigger("Pulse"); proximityCollider.enabled = false; isBeingOffered = true; }
void SpawnDemon() { //print("Demon spawnas"); if (player.demonsEncountered < 2) { //print("First demon encounter"); player.demonsEncountered++; player.DemonEncounter(); } // Check if there are any avaiable demon control points in current world area if (worldMan.worldAreas[worldMan.currentWorldArea].demonBezCP.Length == 0) { return; } // Spawn the demon somewhehere between the two start control points given by WorldManager Vector3 startCP1 = worldMan.worldAreas[worldMan.currentWorldArea].demonStart[0].transform.position; Vector3 startCP2 = worldMan.worldAreas[worldMan.currentWorldArea].demonStart[1].transform.position; Vector3 rndStart = player.transform.position; int whileSaver = 0; while (Vector3.Distance(rndStart, player.transform.position) < 1f && whileSaver < 5) // max 4 attempts { rndStart = new Vector3(Random.Range(startCP1.x, startCP2.x), Random.Range(startCP1.y, startCP2.y), Random.Range(startCP1.z, startCP2.z)); whileSaver++; print("Demon start pos rnd attempt"); } GameObject newDemonGameObject = Instantiate(orgDemon) as GameObject; Demon newDemon = newDemonGameObject.GetComponent <Demon>(); newDemon.controlP1 = worldMan.worldAreas[worldMan.currentWorldArea].demonBezCP[0]; newDemon.controlP2 = worldMan.worldAreas[worldMan.currentWorldArea].demonBezCP[1]; newDemon.start = rndStart; Random.InitState(System.DateTime.Now.Millisecond); newDemon.transform.position = newDemon.start; newDemon.sound = demonSounds[Random.Range(0, nrDemonSounds)]; //print("Demon spawn at " + newDemon.start); newDemon.autoHoming = Random.Range(0, 4) < 3; print("New demon homing " + newDemon.autoHoming); newDemon.transform.SetParent(this.transform); newDemon.gameObject.SetActive(true); activeDemon = true; }
public static void Main() { string[] names = Console.ReadLine() .Split(new char[] { ',', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string patternHealth = @"[^0-9\*\/\+-\.\s\,]"; string patternDamage = @"[\+\-]?[0-9]+(\.?[0-9]+|[0-9]*)"; //(-?\d*\.?\d+) Regex rgxHealth = new Regex(patternHealth); Regex rgxDamage = new Regex(patternDamage); List <Demon> demons = new List <Demon>(); foreach (string name in names) { long totalHealth = 0; decimal totalDamage = 0; MatchCollection matchesHealth = rgxHealth.Matches(name); MatchCollection matchesDamage = rgxDamage.Matches(name); Demon demon = new Demon(); demon.Name = name; foreach (Match match in matchesHealth) { char currElement = char.Parse(match.ToString()); totalHealth += currElement; demon.Health = totalHealth; } foreach (Match match in matchesDamage) { decimal number = decimal.Parse(match.ToString()); totalDamage += number; } for (int i = 0; i < name.Length; i++) { if (name[i] == '*') { totalDamage *= 2; } if (name[i] == '/') { totalDamage /= 2; } } demon.Damage = totalDamage; demons.Add(demon); } var orderedDemons = demons.OrderBy(x => x.Name); foreach (var demon in orderedDemons) { Console.WriteLine("{0} - {1} health, {2:F2} damage", demon.Name, demon.Health, demon.Damage); } }
int CheckTargetForDemon(Demon demon) { for (int i = 0; i < targets.Count; i ++) { if (demon == targets[i].demon) { return i; } } return -1; }
private void Awake() { if (this.gameObject.GetComponent <Demon>() != null) { thisDemon = this.gameObject.GetComponent <Demon>(); } if (this.GetComponent <ICanKillPlayer>() != null) { playerkiller = this.GetComponent <ICanKillPlayer>(); } }
public Tongue(Demon source) { tongueTextures = new LinkedList<Texture2D>(); pieceTex = AkumaContentManager.tonguePieceTex; sourceTex = AkumaContentManager.tongueSourceTex; tongueTextures.AddFirst(sourceTex); this.source = source; location = source.location; location.Y = source.location.Y + source.walkTex.Height - 34; game = source.game; }
/// <summary> /// Called when a demon is made. Returns true if the demon that was made is a part of the mission. /// </summary> /// <returns><c>true</c>, if demon was maded, <c>false</c> otherwise.</returns> /// <param name="demon">Demon.</param> public bool MadeDemon(Demon demon) { int targetId = CheckTargetForDemon(demon); if (targetId > -1) { targets[targetId].MadeDemon(); // TODO Update UIMission return true; } return false; }
public static Demon Parse(string DemonName) { var demon = new Demon(); demon.Name = DemonName; demon.Health = CalculateHealth(DemonName); demon.Demage = CalculateDemage(DemonName); return(demon); }
static void Main(string[] args) { string[] names = Console.ReadLine() .Split(" ,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); List <Demon> demonBook = new List <Demon>(); foreach (string name in names) { string healthPattern = @"[^\d\+\-\/\*\.]"; string damagePattern = @"[\-\+]*\d+(\.\d+)*"; string multiplier = @"\*"; string divider = @"\/"; MatchCollection healthMatches = Regex.Matches(name, healthPattern); MatchCollection damageMatches = Regex.Matches(name, damagePattern); MatchCollection multiplierMatches = Regex.Matches(name, multiplier); MatchCollection dividerMatches = Regex.Matches(name, divider); int health = healthMatches .Cast <Match>() .Select(h => (int)(Char.Parse(h.Value))) .Sum(); double damage = damageMatches .Cast <Match>() .Select(h => double.Parse(h.Value)) .Sum(); if (multiplierMatches.Count > 0) { damage *= Math.Pow(2, multiplierMatches.Count); } if (dividerMatches.Count > 0) { damage /= Math.Pow(2, dividerMatches.Count); } Demon demon = new Demon { Name = name, Damage = damage, Health = health }; demonBook.Add(demon); } foreach (Demon demon in demonBook.OrderBy(d => d.Name)) { Console.WriteLine($"{demon.Name} - {demon.Health} health, {demon.Damage:F2} damage"); } }
public static Monster CreateMonster(MonsterList monster, Game game, int level) { Monster newMonster = null; switch (monster) { case MonsterList.Bat: newMonster = Bat.Create(level, game); newMonster.Behavior = new StandardMoveAndAttack(); break; case MonsterList.Banshee: newMonster = Banshee.Create(level, game); newMonster.Behavior = new TeleportAroundPlayer(); break; case MonsterList.Demon: newMonster = Demon.Create(level, game); newMonster.Behavior = new StandardMoveAndAttack(); break; case MonsterList.Doll: newMonster = Doll.Create(level, game); newMonster.Behavior = new DontLookAway(); break; case MonsterList.Ghoul: newMonster = Ghoul.Create(level, game); newMonster.Behavior = new StandardMoveAndAttack(); break; case MonsterList.LivingArmor: newMonster = LivingArmor.Create(level, game); newMonster.Behavior = new DontLookAway(); break; case MonsterList.Spider: newMonster = Spider.Create(level, game); newMonster.Behavior = new StandardMoveAndAttack(); break; case MonsterList.Wraith: newMonster = Wraith.Create(level, game); newMonster.Behavior = new TeleportAroundPlayer(); break; } newMonster.Health = newMonster.Health + (level - 1); newMonster.Attack = newMonster.Attack + (level - 1); return(newMonster); }
// Demons: public void makeDemonsAngrier() { foreach (GameObject demon in demonsOnScreen) { Demon demonScript = demon.GetComponent <Demon> (); demonScript.increaseShootingRate(); } // increase the number of demons that should come out of rocks: for (int i = 0; i < maxDemonsOnScreen.Length; i++) { maxDemonsOnScreen [i]++; } }
public void Successful_exchange() { Dwarf dwarf = new Dwarf(9, 1, 0); Demon demon = new Demon(23, 6547, 24); Sword sword = new Sword(999999999); dwarf.AddItem(sword); ExchangeEncounter encounter = new ExchangeEncounter(dwarf, demon, sword); Assert.IsTrue(encounter.RunEncounter()); }
public static void SortAndPrintResult(List <Demon> demonsInfo) { demonsInfo = demonsInfo .OrderBy(x => x.name) .ToList(); for (int i = 0; i < demonsInfo.Count; i++) { Demon demon = demonsInfo[i]; Console.WriteLine($"{demon.name} - {demon.health} health, {demon.damage:F2} damage"); } }
public void UnSuccessful_exchange() { Dwarf dwarf = new Dwarf(9, 1, 0); Demon demon = new Demon(23, 6547, 24); //dwarf no tiene nigun item. El intercambio deberia fallar (devolver false.) //dwarf.AddItem(new Sword(999999999)); ExchangeEncounter encounter = new ExchangeEncounter(dwarf, demon, new Shield(82387)); Assert.Catch <NoItemsToShareException>(() => encounter.RunEncounter()); }
public Demon GenerateDemon() { Demon.Trait one = Demon.TraitList[Random.Range(0, Demon.TraitList.Count)]; Demon.Trait two = Demon.TraitList[Random.Range(0, Demon.TraitList.Count)]; while (one == two) { two = Demon.TraitList[Random.Range(0, Demon.TraitList.Count)]; } Demon NewDemon = new Demon(DemonNames[Random.Range(0, DemonNames.Count)], one, two); return(NewDemon); }
public static void Main() { #region //Mighty battle is coming. In the stormy nether realms, demons are fighting against each other for supremacy in a duel from which only one will survive. //Your job, however is not so exciting.You are assigned to sign in all the participants in the nether realm's mighty battle's demon book, //which of course is sorted alphabetically. //A demon's name contains his health and his damage. //The sum of the asci codes of all characters(excluding numbers(0 - 9), arithmetic symbols('+', '-', '*', '/') and delimiter dot('.')) //gives a demon's total health. //The sum of all numbers in his name forms his base damage. //Note that you should consider the plus '+' and minus '-' signs(e.g. + 10 is 10 and - 10 is -10). //However, there are some symbols('*' and '/') that can further alter the base damage by multiplying or dividing it by 2 //(e.g. in the name "m15*/c-5.0", the base damage is 15 + (-5.0) = 10 and then you need to multiply it by 2(e.g. 10 * 2 = 20), //then divide it by 2(e.g. 20 / 2 = 10)). //So, multiplication and division are applied only after all numbers are included in the calculation and in the order they appear in the name. //You will get all demons on a single line, separated by commas and zero or more blank spaces. //Sort them in alphabetical order and print their names along their health and damage. #endregion var listOfDemons = new List <Demon>(); var inputedDemons = Console.ReadLine().Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); foreach (var demon in inputedDemons) { var newDemon = new Demon(); newDemon.Name = demon; //get his health newDemon.Health = CalculateHealth(demon); //get his damage newDemon.Damage = CalculateDamage(demon); listOfDemons.Add(newDemon); } var result = listOfDemons.OrderBy(x => x.Name); foreach (var currentDemon in result) { Console.WriteLine($"{currentDemon.Name} - {currentDemon.Health} health, {currentDemon.Damage:f2} damage"); } }
public void AddSaved(Demon d) { for (int k = 0; k < m_Saved.Count; k++) { if (m_Saved[k].demon.name == d.name) { return; } } DemonInfo info = GetInfo(m_SavedParent); info.Setup(d); m_Saved.Add(info); }
private static void InsertDemon(SortedDictionary <string, Demon> data) { string[] tokens = ReadLine(); foreach (var t in tokens) { int health = 0; double damage = 0d; MatchCollection regex = Regex.Matches(t, @"(?<number>-?\d+(?:\.\d+)?)|(?<characters>[^*+-\/\.])|(?<arithmetic>[*\/])"); foreach (Match r in regex) { if (r.Groups["characters"].Value.Trim() != String.Empty) { health += char.Parse(r.Groups["characters"].Value.Trim()); } if (r.Groups["number"].Value != String.Empty) { damage += double.Parse(r.Groups["number"].Value); } } foreach (Match r in regex) { if (r.Groups["arithmetic"].Value != String.Empty) { if ("*/".Contains(char.Parse(r.Groups["arithmetic"].Value))) { if (char.Parse(r.Groups["arithmetic"].Value) == '*') { damage *= 2; } else if (char.Parse(r.Groups["arithmetic"].Value) == '/') { damage /= 2; } } } } data[t] = new Demon() { Health = health, Damage = damage }; } }
public override void _Ready() { base._Ready(); gameState = NodeGetter.GetFirstNodeInGroup <GameState>(GetTree(), GameConstants.GameStateGroup, true); demon = NodeGetter.GetFirstNodeInGroup <Demon>(GetTree(), GameConstants.DemonGroup, true); pointTimer = GetNode <Timer>(pointTimerNodePath); damageTimer = GetNode <Timer>(damageTimerNodePath); treeState = GetNode <TreeState>(treeStateNodePath); addEnergyTimer = GetNode <Timer>(addEnergyTimerNodePath); treeActionRadius = GetNode <TreeActionRadius>(treeActionRadiusNodePath); pointTimer.Connect("timeout", this, nameof(OnPointTimerTimeout)); damageTimer.Connect("timeout", this, nameof(OnDamageTimerTimeout)); addEnergyTimer.Connect("timeout", this, nameof(OnEnergyTimerTimeout)); }
public void RemoveSaved(Demon d) { for (int k = 0; k < m_Saved.Count; k++) { if (m_Saved[k].demon.name == d.name) { DemonInfo i = m_Saved[k]; i.transform.SetParent(m_InactiveContainer); m_OldDemonInfos.Add(i); m_CurrentDemonInfos.Remove(i); m_Saved.RemoveAt(k); break; } } }
public Demon getClosestPossesedItem() { Demon[] demons = GameObject.FindObjectsOfType <Demon>(); float distance = Mathf.Infinity; Demon choosenOne = null; foreach (Demon demon in demons) { float dist = Vector2.Distance(demon.transform.position, transform.position); if (demon.isPossesed && dist < distance && dist <= sonarRange) { choosenOne = demon; } } return(choosenOne); }
private void OnTriggerStay2D(Collider2D col) { if (col.tag == "Enemy") { if (col.gameObject.layer == 8) { Demon demon = col.gameObject.GetComponentInChildren <Demon>(); demon.SubHealth(attackDamage); } if (col.gameObject.layer == 9) { Dragon dragon = col.gameObject.GetComponentInChildren <Dragon>(); dragon.SubHealth(attackDamage); } } }
public void ApplyMusic(float angle) { currentDebuff = new Ablaze(force * Time.deltaTime * coeff); foreach (GameObject coreling in fieldOfView.seenCorelings) { Demon demon = coreling.GetComponent <Demon>(); if (demon != null) { float angleFromMus = CustomLib.AngleFromPos(transform.position, demon.transform.position) - transform.rotation.eulerAngles.z; if (angleFromMus <= angle / 2f && angleFromMus >= -angle / 2f) { demon.AddDebuff(currentDebuff); } } } }
public void OnMadeDemon(Demon demon) { // Stop if we don't have a mission if (!curMission) return; bool madeDemonIsMission = curMission.MadeDemon(demon); if (madeDemonIsMission) { if (curMission.IsFinished()) { // TODO report that the mission is finished //RemoveMission(); print("Mission finiesed!"); turnInText.text = string.Format("Turn in [${0}]", curMission.reward); discardButtonObject.SetActive(false); } } }
public void UpdateBeastiaryDemonColor(Demon demon) { SetBeastiaryImageColor(demon.demonId, demon.hasSummoned); }