public UnitWeapon CreateWeapon(string weaponLink) { if (string.IsNullOrEmpty(weaponLink)) { throw new ArgumentException("Argument cannot be null or emtpy", nameof(weaponLink)); } UnitWeapon weapon = new UnitWeapon() { WeaponNameId = weaponLink, Name = GameData.GetGameString(DefaultData.WeaponData.WeaponName.Replace(DefaultData.IdPlaceHolder, weaponLink)), Period = DefaultData.WeaponData.WeaponPeriod, Range = DefaultData.WeaponData.WeaponRange, }; IEnumerable <XElement> weaponElements = GetWeaponElements(weaponLink); if (!weaponElements.Any()) { return(null); } foreach (XElement element in weaponElements) { SetWeaponData(element, weapon); if (string.IsNullOrEmpty(weapon.WeaponNameId)) { return(null); } } return(weapon); }
public override void Step(Selectable sel) { UnitWeapon weap = sel.gameObject.GetComponentInChildren <UnitWeapon>(); UnitBase unit = sel.gameObject.GetComponent <UnitBase>(); if (weap == null || unit == null) { return; } location = targetCombat.transform.position; unit.SetWeaponTarget(target); float distToTarget = (target.position - sel.transform.position).magnitude; ProjectileWeapon pw = weap as ProjectileWeapon; bool canSee = true; if (pw != null) { canSee = pw.CanSee(target.position); } if (distToTarget < weap.MaxRange && canSee) { //Don't move any closer sel.SetNavTarget(sel.transform.position); } else { sel.SetNavTarget(target.position); } }
void Awake() { weapon = GetComponent<UnitWeapon>(); if (!gameObject.GetComponent<SphereCollider>()) gameObject.AddComponent<SphereCollider>().isTrigger = true; }
void Awake() { weapon = GetComponent <UnitWeapon>(); if (!gameObject.GetComponent <SphereCollider>()) { gameObject.AddComponent <SphereCollider>().isTrigger = true; } }
public void GetWeponAttackSpeedTests(double period, double attackPerSecond) { UnitWeapon weapon = new UnitWeapon() { Period = period, }; Assert.AreEqual(attackPerSecond, weapon.AttacksPerSecond); }
protected override void ApplyAdditionalOverrides(Unit unit, UnitDataOverride dataOverride) { if (unit == null) { throw new ArgumentNullException(nameof(unit)); } if (dataOverride == null) { throw new ArgumentNullException(nameof(dataOverride)); } if (unit.Abilities != null) { foreach (AbilityTalentId validAbility in dataOverride.AddedAbilities) { Ability ability = XmlDataService.AbilityData.CreateAbility(unit.CUnitId, validAbility.ReferenceId); if (ability != null) { if (dataOverride.IsAddedAbility(validAbility)) { unit.AddAbility(ability); } else { unit.RemoveAbility(ability); } } } dataOverride.ExecuteAbilityOverrides(unit.Abilities); } if (unit.Weapons != null) { foreach (string validWeapon in dataOverride.AddedWeapons) { UnitWeapon weapon = XmlDataService.WeaponData.CreateWeapon(validWeapon); if (weapon != null) { if (dataOverride.IsAddedWeapon(validWeapon)) { unit.AddUnitWeapon(weapon); } else { unit.RemoveUnitWeapon(weapon); } } } dataOverride.ExecuteWeaponOverrides(unit.Weapons); } base.ApplyAdditionalOverrides(unit, dataOverride); }
public void EqualsTest(string id) { UnitWeapon unitWeapon = new UnitWeapon() { WeaponNameId = id, }; Assert.AreEqual(unitWeapon, unitWeapon); }
private void SetWeaponData(XElement weaponElement, UnitWeapon weapon) { // parent lookup string?parentValue = weaponElement.Attribute("parent")?.Value; if (!string.IsNullOrEmpty(parentValue)) { XElement?parentElement = GameData.MergeXmlElements(_gameData.Elements(weaponElement.Name.LocalName).Where(x => x.Attribute("id")?.Value == parentValue)); if (parentElement != null) { SetWeaponData(parentElement, weapon); } } if (weapon == null) { return; } // loop through all elements and set found elements foreach (XElement element in weaponElement.Elements()) { string elementName = element.Name.LocalName.ToUpperInvariant(); if (elementName == "RANGE") { weapon.Range = XmlParse.GetDoubleValue(weapon.WeaponNameId, element, _gameData); } else if (elementName == "PERIOD") { weapon.Period = XmlParse.GetDoubleValue(weapon.WeaponNameId, element, _gameData); } else if (elementName == "DISPLAYEFFECT") { string?displayEffectElementValue = element.Attribute("value")?.Value; if (!string.IsNullOrEmpty(displayEffectElementValue)) { XElement?effectDamageElement = GameData.MergeXmlElements(_gameData.Elements("CEffectDamage").Where(x => x.Attribute("id")?.Value == displayEffectElementValue)); if (effectDamageElement != null) { WeaponAddEffectDamage(effectDamageElement, weapon); } } } else if (elementName == "OPTIONS") { string?indexValue = element.Attribute("index")?.Value; string?value = element.Attribute("value")?.Value; if (IsHeroParsing && !string.IsNullOrEmpty(indexValue) && !string.IsNullOrEmpty(value) && indexValue.Equals("disabled", StringComparison.OrdinalIgnoreCase) && value == "1") { weapon.WeaponNameId = string.Empty; return; } } } }
public override bool Complete(Selectable sel) { UnitWeapon weap = sel.gameObject.GetComponentInChildren <UnitWeapon>(); if (weap == null || target == null) { return(true); } return(false); }
public void NotSameObjectTest() { UnitWeapon unitWeapon = new UnitWeapon() { WeaponNameId = "abc", }; Assert.AreNotEqual(new List <string>() { "asdf" }, unitWeapon); }
public void EqualsMethodTests() { UnitWeapon unitWeapon = new UnitWeapon() { WeaponNameId = "weaponId1", }; Assert.IsFalse(unitWeapon.Equals((int?)null)); Assert.IsFalse(unitWeapon.Equals(5)); Assert.IsTrue(unitWeapon.Equals(obj: unitWeapon)); }
public void NotEqualsTest(string id) { UnitWeapon unitWeapon = new UnitWeapon() { WeaponNameId = "abc", }; Assert.AreNotEqual(unitWeapon, new UnitWeapon() { WeaponNameId = id, }); }
/// <summary> /// Sets the <see cref="Unit"/>'s weapon data. /// </summary> /// <param name="element">The <see cref="JsonElement"/> to read from.</param> /// <param name="unit">The data to be set from <paramref name="element"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="unit"/> is <see langword="null"/>.</exception> protected virtual void SetUnitWeapons(JsonElement element, Unit unit) { if (unit is null) { throw new ArgumentNullException(nameof(unit)); } if (element.TryGetProperty("weapons", out JsonElement weapons)) { foreach (JsonElement weaponArrayElement in weapons.EnumerateArray()) { string?weaponIdValue = weaponArrayElement.GetProperty("nameId").GetString(); if (weaponIdValue is null) { continue; } UnitWeapon unitWeapon = new UnitWeapon { WeaponNameId = weaponIdValue, Range = weaponArrayElement.GetProperty("range").GetDouble(), Period = weaponArrayElement.GetProperty("period").GetDouble(), Damage = weaponArrayElement.GetProperty("damage").GetDouble(), DamageScaling = weaponArrayElement.GetProperty("damageScale").GetDouble(), }; if (weaponArrayElement.TryGetProperty("name", out JsonElement nameElement)) { unitWeapon.Name = nameElement.ToString(); } // attribute factors if (weaponArrayElement.TryGetProperty("damageFactor", out JsonElement damageFactor)) { foreach (JsonProperty attributeFactorProperty in damageFactor.EnumerateObject()) { WeaponAttributeFactor weaponAttributeFactor = new WeaponAttributeFactor { Type = attributeFactorProperty.Name, Value = attributeFactorProperty.Value.GetDouble(), }; unitWeapon.AttributeFactors.Add(weaponAttributeFactor); } } unit.Weapons.Add(unitWeapon); } } }
private void WeaponAddEffectDamage(XElement effectDamageElement, UnitWeapon weapon) { // parent lookup string?parentValue = effectDamageElement.Attribute("parent")?.Value; if (!string.IsNullOrEmpty(parentValue)) { XElement?parentElement = GameData.MergeXmlElements(_gameData.Elements("CEffectDamage").Where(x => x.Attribute("id")?.Value == parentValue)); if (parentElement != null) { WeaponAddEffectDamage(parentElement, weapon); } } foreach (XElement element in effectDamageElement.Elements()) { string elementName = element.Name.LocalName.ToUpperInvariant(); if (elementName == "AMOUNT") { weapon.Damage = XmlParse.GetDoubleValue(weapon.WeaponNameId, element, _gameData); } else if (elementName == "ATTRIBUTEFACTOR") { string?index = element.Attribute("index")?.Value; string?value = element.Attribute("value")?.Value; WeaponAttributeFactor attributeFactor = new WeaponAttributeFactor(); if (!string.IsNullOrEmpty(index) && !string.IsNullOrEmpty(value)) { attributeFactor.Type = index; attributeFactor.Value = XmlParse.GetDoubleValue(weapon.WeaponNameId, element, _gameData); weapon.AttributeFactors.Add(attributeFactor); } } } double?scaleValue = _gameData.GetScaleValue(("Effect", effectDamageElement.Attribute("id")?.Value ?? string.Empty, "Amount")); if (scaleValue.HasValue) { weapon.DamageScaling = scaleValue.Value; } }
public void WeaponsTests() { UnitWeapon weapon1 = BraxisHoldoutTerranArchangelLaner.Weapons.ToList()[0]; Assert.AreEqual(4, weapon1.Range); Assert.AreEqual(0.0625, weapon1.Period); Assert.AreEqual(25, weapon1.Damage); Assert.AreEqual("Minion", weapon1.AttributeFactors.First().Type); Assert.AreEqual(1, weapon1.AttributeFactors.First().Value); UnitWeapon weapon2 = BraxisHoldoutTerranArchangelLaner.Weapons.ToList()[0]; Assert.AreEqual(4, weapon2.Range); Assert.AreEqual(0.0625, weapon2.Period); Assert.AreEqual(25, weapon2.Damage); Assert.AreEqual("Minion", weapon2.AttributeFactors.First().Type); Assert.AreEqual(1, weapon2.AttributeFactors.First().Value); }
UnitWeapon FindEquippedWeapon(Unit unit) { UnitWeapon none = new UnitWeapon(); if (unit.inventory.invSlot1.holding != "") { if (unit.inventory.invSlot1.weapon.equipped) { return(unit.inventory.invSlot1.weapon); } } if (unit.inventory.invSlot2.holding != "") { if (unit.inventory.invSlot2.weapon.equipped) { return(unit.inventory.invSlot2.weapon); } } if (unit.inventory.invSlot3.holding != "") { if (unit.inventory.invSlot3.weapon.equipped) { return(unit.inventory.invSlot3.weapon); } } if (unit.inventory.invSlot4.holding != "") { if (unit.inventory.invSlot4.weapon.equipped) { return(unit.inventory.invSlot4.weapon); } } if (unit.inventory.invSlot5.holding != "") { if (unit.inventory.invSlot5.weapon.equipped) { return(unit.inventory.invSlot5.weapon); } } return(none); }
public void OperatorEqualTest(string id, string id2) { UnitWeapon unitWeapon = new UnitWeapon() { WeaponNameId = id, }; UnitWeapon unitWeapon2 = new UnitWeapon() { WeaponNameId = id2, }; #pragma warning disable SA1131 // Use readable conditions Assert.IsFalse(null ! == unitWeapon2); #pragma warning restore SA1131 // Use readable conditions Assert.IsFalse(unitWeapon2 == null !); Assert.IsTrue(null ! == (Announcer)null !); Assert.IsTrue(unitWeapon == unitWeapon2); Assert.AreEqual(unitWeapon.GetHashCode(), unitWeapon2 !.GetHashCode()); }
public void AddWeaponAttributeFactorTests() { UnitWeapon unitWeapon = new UnitWeapon(); WeaponAttributeFactor weaponAttributeFactor = new WeaponAttributeFactor() { Type = "type1", Value = 5, }; unitWeapon.AttributeFactors.Add(weaponAttributeFactor); Assert.IsTrue(unitWeapon.AttributeFactors.Contains(weaponAttributeFactor)); WeaponAttributeFactor weaponAttributeFactor2 = new WeaponAttributeFactor() { Type = "type1", Value = 7, }; unitWeapon.AttributeFactors.Add(weaponAttributeFactor2); Assert.AreEqual(1, unitWeapon.AttributeFactors.Count); Assert.IsTrue(unitWeapon.AttributeFactors.Contains(weaponAttributeFactor2)); }
public IEnumerator GoTime() { if (!stats.sleep) { Debug.Log("can i go mom?"); if (stats.hobble) { move = move - 2; } else if (oldmove == 0) { oldmove = 0; } else { move = oldmove; } Debug.Log("can i go faar? + " + move); GameObject tile = null; FindNearestTarget(); CalculatePath(); FindSelectableTiles(); if (actualTargetTile != null) { actualTargetTile.target = true; tile = actualTargetTile.gameObject; } Move(); weapon = FindEquippedWeapon(gameObject.GetComponent <Stats>().FindMyself()); do { Move(); yield return(new WaitForSeconds(0.01f)); } while (isMoving); if (tile != null) { if (gameObject.transform.localRotation != tile.transform.localRotation) { gameObject.transform.localRotation = tile.transform.localRotation; } } } float nextTo = weapon.details.range; float thePlayer = Vector3.Distance(transform.position, target.transform.position); if (nextTo >= thePlayer) { attackState = true; } if (attackState && !stats.sleep) { List <GameObject> newTargets = new List <GameObject>(); AssignArray(newTargets); GameObject nearest = null; float distance = Mathf.Infinity; foreach (GameObject obj in newTargets) { float d = Vector3.Distance(transform.position, obj.transform.position); if (d < distance) { distance = d; nearest = obj; } } GameObject enemy = nearest; Stats newEnemy = enemy.GetComponent <Stats>(); enemy.GetComponent <MapPlayerAttack>().weapon = FindEquippedWeapon(enemy.GetComponent <Stats>().FindMyself()); newEnemy.attacked(gameObject.GetComponent <Stats>()); attackState = false; } GameObject.FindObjectOfType <SpeedCenterTurns>().AdvanceTurn(); }
protected override void SetTestData() { WeaponAttributeFactor weaponAttributeFactor1 = new WeaponAttributeFactor() { Type = "Minion", Value = 5, }; WeaponAttributeFactor weaponAttributeFactor2 = new WeaponAttributeFactor() { Type = "Structure", Value = 0.75, }; UnitWeapon unitWeapon = new UnitWeapon() { Damage = 56, Name = "Minion Archer Weapon", Period = 4, Range = 6, WeaponNameId = "MinionArcherWeapon", }; unitWeapon.AttributeFactors.Add(weaponAttributeFactor1); unitWeapon.AttributeFactors.Add(weaponAttributeFactor2); Unit unit = new Unit() { Name = "Minion Archer", Id = "MinionArcher", Description = new TooltipDescription(string.Empty), HyperlinkId = "MinionArcher", CUnitId = "MinionArcher", DamageType = "Minion", InnerRadius = 1.125, Radius = 1.111, Sight = 6, Speed = 4, ScalingBehaviorLink = "MinionScaling", KillXP = 210, UnitPortrait = new UnitPortrait() { TargetInfoPanelFileName = "targetInfo.png", }, }; unit.Life.LifeMax = 500; unit.Weapons.Add(unitWeapon); unit.Attributes.Add("att1"); unit.Attributes.Add("att2"); TestData.Add(unit); Unit unit2 = new Unit() { Name = "Minion Footman", Id = "MinionFootman", Description = new TooltipDescription(string.Empty), HyperlinkId = "MinionFootman", CUnitId = "MinionFootman", DamageType = "Minion", InnerRadius = 1.125, Radius = 1.111, Sight = 6, Speed = 4, }; unit2.Life.LifeMax = 900; unit2.Weapons.Add(new UnitWeapon() { Damage = 75, Name = "Minion Footman Weapon", Period = 6, Range = 7, WeaponNameId = "MinionFootmanWeapon", }); unit2.Weapons.Add(new UnitWeapon() { Damage = 56, Name = "Minion Archer Weapon", Period = 4, Range = 6, WeaponNameId = "MinionArcherWeapon", }); TestData.Add(unit2); }
void OnGUI() { GUILayout.BeginArea(new Rect(0, 0, Screen.width / 2, Screen.height/2)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); if (currentMenu == Menu.HomeMenu) { if (GUILayout.Button("Select Action")) { currentMenu = Menu.SkillSelection; } if (GUILayout.Button("Use Item")) { currentMenu = Menu.Items; } GUILayout.Space(10); if (GUILayout.Button("Exit Menu")) { menuPar.SetActive(false); } } else if (currentMenu == Menu.SkillSelection) { GUILayout.BeginArea(new Rect(0, 0, Screen.width / 2, Screen.height * 1.5f)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); // GUILayout.Space(10); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(Screen.width / 2f), GUILayout.Height(Screen.height * 1.5f)); turnCon = GameObject.FindObjectOfType<SpeedCenterTurns>(); unitObj = turnCon.activeUnit; unit = unitObj.GetComponent<Stats>().FindMyself(); attack = unitObj.GetComponent<MapPlayerAttack>(); UnitWeapon weapon = FindEquippedWeapon(); if (weapon.equipped) { if (GUILayout.Button("Attack with " + weapon.name)) { attack.attackArea = weapon.details.range; attack.weapon = weapon; attack.ShowAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (weapon.details.physical) GUILayout.Label("Physical Damage"); if (weapon.details.magic) GUILayout.Label("Magic Damage"); if (weapon.details.effects.poison) GUILayout.Label("Poison"); if (weapon.details.effects.fireDamage) GUILayout.Label("Fire Damage"); } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill1.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill1; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill1; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill2.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill2; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill2; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill3.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill3; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = u; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill4.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill4; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill4; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill5.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill5; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill5; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill6.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill6; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill6; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill7.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill7; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill7; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill8.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill8; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill8; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill9.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill9; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill9; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill10.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill10; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill10; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill11.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill11; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill11; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(3); if (unit.unitInfo.main.pickSkill.skill12.name != "") { UnitSkillDetail u = unit.unitInfo.main.pickSkill.skill12; if (!checking) { if (GUILayout.Button(u.name)) { attack.currentAttack = unit.unitInfo.main.pickSkill.skill12; checking = true; } if (u.physicalDamage) GUILayout.Label("Physical Damage"); if (u.magicDamage) GUILayout.Label("Magic Damage"); if (u.effects.poison) GUILayout.Label("Poison"); if (u.effects.fireDamage) GUILayout.Label("Fire Damage"); } else if (attack.currentAttack == u) { if (GUILayout.Button("Yes use " + u.name)) { attack.UniqueAttack(); checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } if (GUILayout.Button("No")) { attack.currentAttack = empty; checking = false; } } } GUILayout.Space(10); if (GUILayout.Button("Exit Menu")) { checking = false; attack.currentAttack = empty; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } GUILayout.Label("", GUILayout.Width(Screen.width / 2.3f), GUILayout.Height(Screen.height * 1.5f)); GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } else if (currentMenu == Menu.Items) { GUILayout.BeginArea(new Rect(0, 0, Screen.width / 2, Screen.height / 2f)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.Space(10); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(Screen.width / 2f), GUILayout.Height(Screen.height * 1.5f)); turnCon = GameObject.FindObjectOfType<SpeedCenterTurns>(); unitObj = turnCon.activeUnit; unit = unitObj.GetComponent<Stats>().FindMyself(); attack = unitObj.GetComponent<MapPlayerAttack>(); EquipmentOwned e = CurrentGame.game.memoryGeneral.itemsOwned; ItemHolder potionSmall = CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Potion Small"); ItemHolder potionLarge = CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Potion Large"); ItemHolder chestKey = CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Chest Key"); ItemHolder doorKey = CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Door Key"); if (potionSmall.count > 0) { if (GUILayout.Button("Potion Small " + "x " + potionSmall.count)) { unitObj.GetComponent<Stats>().currentHp += potionSmall.effects.effectBase; unitObj.GetComponent<Stats>().HealHp(potionSmall.effects.effectBase); unitObj.GetComponent<Stats>().UpdateHp(); CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Potion Small").count--; attack.AssignMe(); MapManager manager = GameObject.FindObjectOfType<MapManager>(); manager.PlayerSkill(); currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } } else { GUILayout.Label("Potion Small x 0"); } if (potionLarge.count > 0) { if (GUILayout.Button("Potion Large " + "x " + potionLarge.count)) { unitObj.GetComponent<Stats>().currentHp += potionLarge.effects.effectBase; unitObj.GetComponent<Stats>().HealHp(potionLarge.effects.effectBase); unitObj.GetComponent<Stats>().UpdateHp(); CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Potion Large").count--; attack.AssignMe(); MapManager manager = GameObject.FindObjectOfType<MapManager>(); manager.PlayerSkill(); currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } } else { GUILayout.Label("Potion Lagre x 0"); } if (chestKey.count > 0) { if (SomethingClose("Chest", unitObj)) { if (GUILayout.Button("Chest Key " + "x " + chestKey.count)) { float nextTo = 1.9f; List<GameObject> newTargets = new List<GameObject>(); gotChest.Clear(); AssignArray(newTargets, "Chest"); foreach (GameObject obj in newTargets) { float d = Vector3.Distance(GameObject.Find(unitObj.name).transform.position, obj.transform.position); Debug.Log(d + " the space between us"); if (nextTo >= d) gotChest.Add(obj); } } } else { GUILayout.Box("No Nearby Chests"); GUILayout.Label("Chest Key " + "x " + chestKey.count); } } else { GUILayout.Label("Chest Key x 0"); } if (gotChest.Count > 0) { foreach (GameObject obj in gotChest) { if (GUILayout.Button("Open Chest " + obj.name)) { obj.GetComponent<ChestRewards>().RandomReward(); CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Chest Key").count--; attack.AssignMe(); MapManager manager = GameObject.FindObjectOfType<MapManager>(); manager.PlayerSkill(); gotChest.Clear(); currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } } if (GUILayout.Button("Dont Use Key")) { gotChest.Clear(); } } if (doorKey.count > 0) { if (SomethingClose("Door", unitObj)) { if (GUILayout.Button("Door Key " + "x " + doorKey.count)) { float nextTo = 1.9f; List<GameObject> newTargets = new List<GameObject>(); gotDoor.Clear(); AssignArray(newTargets, "Door"); foreach (GameObject obj in newTargets) { float d = Vector3.Distance(GameObject.Find(unitObj.name).transform.position, obj.transform.position); Debug.Log(d + " the space between us now"); if (nextTo >= d) { Debug.Log("Success now"); gotDoor.Add(obj); } } } } else { GUILayout.Box("No Nearby Doors"); GUILayout.Label("Door Key " + "x " + chestKey.count); } } else { GUILayout.Label("Door Key x 0"); } if (gotDoor.Count > 0) { foreach (GameObject obj in gotDoor) { if (GUILayout.Button("Open Door " + obj.name)) { obj.GetComponent<LockedDoors>().OpenTheWay(); CurrentGame.game.memoryGeneral.itemsOwned.items.Find(x => x.name == "Door Key").count--; attack.AssignMe(); MapManager manager = GameObject.FindObjectOfType<MapManager>(); manager.PlayerSkill(); gotDoor.Clear(); currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } } if (GUILayout.Button("Dont Use Key")) { gotDoor.Clear(); } } GUILayout.Space(10); if (GUILayout.Button("Exit Menu")) { checking = false; currentMenu = Menu.HomeMenu; menuPar.SetActive(false); } GUILayout.Label("", GUILayout.Width(Screen.width / 2f), GUILayout.Height(Screen.height * 1.5f)); GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
public IActionResult Unit(EditUnitViewModel editModel) { UnitModel editUnit = context.Units.Single(c => c.ID == editModel.soloID); editUnit.ARM = editModel.ARM; editUnit.CMD = editModel.CMD; editUnit.DEF = editModel.DEF; editUnit.FA = editModel.FA; editUnit.MAT = editModel.MAT; editUnit.RAT = editModel.RAT; editUnit.Name = editModel.Name; editUnit.SPD = editModel.SPD; editUnit.PointCost = editModel.PointCost; editUnit.STR = editModel.STR; editUnit.MaxUnit = editModel.MaxUnit; editUnit.MinUnit = editModel.MaxUnit; editUnit.factionName = editModel.Faction; context.SaveChanges(); editModel.currenntAbilIDs = context.UnitAbilities.Where(c => c.UnitID == editUnit.ID).Select(x => x.AbilityID).ToList(); editModel.currenntSpellIDs = context.UnitSpells.Where(c => c.UnitID == editUnit.ID).Select(x => x.SpellID).ToList(); editModel.currenntWeaponIDs = context.UnitWeapons.Where(c => c.UnitID == editUnit.ID).Select(x => x.WeaponId).ToList(); if (editModel.abilIDS != null) { foreach (var abil in editModel.abilIDS) { if (!editModel.currenntAbilIDs.Contains(abil)) { UnitAbiliity NewSoloAbility = new UnitAbiliity(); NewSoloAbility.AbilityID = abil; NewSoloAbility.UnitID = editModel.soloID; context.UnitAbilities.Add(NewSoloAbility); context.SaveChanges(); } foreach (var currentAbil in editModel.currenntAbilIDs) { if (!editModel.abilIDS.Contains(currentAbil)) { UnitAbiliity soloabil = (from s in context.UnitAbilities where s.AbilityID == currentAbil where s.UnitID == editModel.soloID select s).FirstOrDefault <UnitAbiliity>(); context.UnitAbilities.Remove(soloabil); context.SaveChanges(); } } } } else { // delete all solo abils var soloAbils = context.UnitAbilities.Where(c => c.UnitID == editModel.soloID).ToList(); foreach (var Abil in soloAbils) { context.UnitAbilities.Remove(Abil); context.SaveChanges(); } } if (editModel.weapIDS != null) { foreach (var weap in editModel.weapIDS) { if (!editModel.currenntWeaponIDs.Contains(weap)) { UnitWeapon NewSoloWeapon = new UnitWeapon(); NewSoloWeapon.WeaponId = weap; NewSoloWeapon.UnitID = editModel.soloID; context.UnitWeapons.Add(NewSoloWeapon); context.SaveChanges(); } foreach (var weaps in editModel.currenntWeaponIDs) { if (!editModel.weapIDS.Contains(weaps)) { UnitWeapon soloWeap = (from s in context.UnitWeapons where s.WeaponId == weap where s.UnitID == editModel.soloID select s).FirstOrDefault <UnitWeapon>(); context.UnitWeapons.Remove(soloWeap); context.SaveChanges(); } } } } else { // delete all solo abils var soloWeaps = context.UnitWeapons.Where(c => c.UnitID == editModel.soloID).ToList(); foreach (var Weap in soloWeaps) { context.UnitWeapons.Remove(Weap); context.SaveChanges(); } } if (editModel.spellIDS != null) { foreach (var spell in editModel.spellIDS) { if (!editModel.currenntSpellIDs.Contains(spell)) { UnitSpell NewSoloSpell = new UnitSpell(); NewSoloSpell.SpellID = spell; NewSoloSpell.UnitID = editModel.soloID; context.UnitSpells.Add(NewSoloSpell); context.SaveChanges(); } foreach (var spells in editModel.currenntSpellIDs) { if (!editModel.spellIDS.Contains(spells)) { UnitSpell soloSpell = (from s in context.UnitSpells where s.SpellID == spell where s.UnitID == editModel.soloID select s).FirstOrDefault <UnitSpell>(); context.UnitSpells.Remove(soloSpell); context.SaveChanges(); } } } } else { // delete all solo abils var soloSpells = context.UnitSpells.Where(c => c.UnitID == editModel.soloID).ToList(); foreach (var Spell in soloSpells) { context.UnitSpells.Remove(Spell); context.SaveChanges(); } } return(Redirect("/View/Unit/" + editModel.soloID)); }
private void Start() { HouseWeapon = GetComponentInParent <UnitWeapon>(); }
protected override void ApplyAdditionalOverrides(Hero hero, HeroDataOverride dataOverride) { if (dataOverride.EnergyTypeOverride.Enabled) { hero.Energy.EnergyType = dataOverride.EnergyTypeOverride.EnergyType; } if (dataOverride.EnergyOverride.Enabled) { hero.Energy.EnergyMax = dataOverride.EnergyOverride.Energy; } if (dataOverride.ParentLinkOverride.Enabled) { hero.ParentLink = dataOverride.ParentLinkOverride.ParentLink; } if (hero.Abilities != null) { foreach (AbilityTalentId addedAbility in dataOverride.AddedAbilities) { Ability ability = XmlDataService.AbilityData.CreateAbility(hero.CUnitId, addedAbility); if (ability != null) { if (dataOverride.IsAddedAbility(addedAbility)) { hero.AddAbility(ability); } else { hero.RemoveAbility(ability); } } } dataOverride.ExecuteAbilityOverrides(hero.Abilities); } if (hero.HeroPortrait != null) { dataOverride.ExecutePortraitOverrides(hero.CHeroId, hero.HeroPortrait); } if (hero.Talents != null) { dataOverride.ExecuteTalentOverrides(hero.Talents); } if (hero.Weapons != null) { foreach (string addedWeapon in dataOverride.AddedWeapons) { UnitWeapon weapon = XmlDataService.WeaponData.CreateWeapon(addedWeapon); if (weapon != null) { if (dataOverride.IsAddedWeapon(addedWeapon)) { hero.AddUnitWeapon(weapon); } else { hero.RemoveUnitWeapon(weapon); } } } dataOverride.ExecuteWeaponOverrides(hero.Weapons); } }
public void AttributeFactorDoesNotExistTest() { UnitWeapon unitWeapon = new UnitWeapon(); Assert.IsFalse(unitWeapon.AttributeFactors.Contains(new WeaponAttributeFactor())); }
public IActionResult Unit(AddUnitViewModel model) { if (ModelState.IsValid) { UnitModel newUnit = new UnitModel(); newUnit.Name = model.Name; newUnit.ARM = model.ARM; newUnit.CMD = model.CMD; newUnit.DEF = model.DEF; newUnit.FA = model.FA; newUnit.MAT = model.MAT; newUnit.MaxUnit = model.MaxUnit; newUnit.MinUnit = model.MinUnit; newUnit.PointCost = model.PointCost; newUnit.RAT = model.RAT; newUnit.SPD = model.SPD; newUnit.STR = model.STR; newUnit.FA = model.FA; newUnit.factionName = model.Faction; context.Units.Add(newUnit); context.SaveChanges(); if (model.abilIDS != null) { foreach (var abil in model.abilIDS) { UnitAbiliity NewUnitAbillity = new UnitAbiliity(); NewUnitAbillity.AbilityID = abil; NewUnitAbillity.UnitID = newUnit.ID; context.UnitAbilities.Add(NewUnitAbillity); context.SaveChanges(); } } if (model.weapIDS != null) { foreach (var weap in model.weapIDS) { UnitWeapon newWeapon = new UnitWeapon(); newWeapon.WeaponId = weap; newWeapon.UnitID = newUnit.ID; context.UnitWeapons.Add(newWeapon); context.SaveChanges(); } } if (model.spellIDS != null) { foreach (var spell in model.spellIDS) { UnitSpell NewSoloSpell = new UnitSpell(); NewSoloSpell.SpellID = spell; NewSoloSpell.UnitID = newUnit.ID; context.UnitSpells.Add(NewSoloSpell); context.SaveChanges(); } } context.Units.Add(newUnit); context.SaveChanges(); return(Redirect("/")); } return(View("AdUnit", model)); }
void Awake() { mover = GetComponent <UnitMover>(); squad = transform.parent.GetComponent <Squad>(); weapon = GetComponent <UnitWeapon>(); muzzleEffect = Instantiate(muzzleEffect_prefab, this.transform.GetChild(1) // hips .GetChild(2) // spine .GetChild(0) //spine 1 .GetChild(0) //spine 2 .GetChild(2) //right should .GetChild(0) // right arm .GetChild(0) // rightfore arm .GetChild(0) //right hand .GetChild(5)); tracerEffect = Instantiate(tracerEffect_prefab, this.transform.GetChild(1) // hips .GetChild(2) // spine .GetChild(0) //spine 1 .GetChild(0) //spine 2 .GetChild(2) //right should .GetChild(0) // right arm .GetChild(0) // rightfore arm .GetChild(0) //right hand .GetChild(5)); //Set unit muzzle color switch (unitClass) { case Class.Rifleman: { tracerEffect.GetComponent <ParticleSystem>().startColor = Color.red; muzzleEffect.GetComponent <ParticleSystem>().startColor = Color.red; break; } case Class.HeavyAssault: { tracerEffect.GetComponent <ParticleSystem>().startColor = Color.cyan; muzzleEffect.GetComponent <ParticleSystem>().startColor = Color.cyan; break; } case Class.Sniper: { tracerEffect.GetComponent <ParticleSystem>().startColor = Color.magenta; muzzleEffect.GetComponent <ParticleSystem>().startColor = Color.magenta; break; } case Class.MG: { tracerEffect.GetComponent <ParticleSystem>().startColor = Color.green; muzzleEffect.GetComponent <ParticleSystem>().startColor = Color.green; break; } case Class.Commander: { tracerEffect.GetComponent <ParticleSystem> ().startColor = Color.yellow; muzzleEffect.GetComponent <ParticleSystem>().startColor = Color.yellow; break; } } ChangeImg(); }
public UnitInvSlot3() { holding = ""; weapon = new UnitWeapon(); assessory = new UnitAssessory(); }