// Use this for initialization void Start() { if (gemOn) { GemService.Instance.Connect (); gem = GemService.Instance.getGem (); } sphereInitPos = Sphere.transform.position; rb = Sphere.GetComponent<Rigidbody>(); tapDetected = false; }
public override void Execute() { string weaponName = this.Data[0]; int socketIndex = int.Parse(this.Data[1]); string[] gemArgs = this.Data[2].Split(); string clarityType = gemArgs[0]; string gemType = gemArgs[1]; IGem gemToAdd = this.gemFactory.CreateGem(gemType, clarityType); this.repository.Add(weaponName, socketIndex, gemToAdd); }
public void AddGemToSocket(int socketIndex, IGem gemType) { if (Validator.IsIndexInArray(socketIndex, this.Gems.Length)) { this.Gems[socketIndex] = gemType; } // The task's requirement is not to log any messages in that case and this part is commented because it affects the tests // else // { // throw new ArgumentException("Invalid socket entered"); // } }
public void AddGem(int socketIndex, IGem gem) { if (socketIndex > this.BaseStat.Sockets.Length - 1) { return; } if (this.BaseStat.Sockets[socketIndex] != null) { RemoveGem(socketIndex); } this.BaseStat.Sockets[socketIndex] = gem; UpdateMagicalStatus(gem, "addGem"); }
public void RemoveGem(int index) { if (index < 0 || index >= this.gems.Length || this.gems[index] == null) { return; } IGem gem = this.gems[index]; this.gems[index] = null; this.strength -= gem.GemStrengthIncreasement; this.agility -= gem.GemAgilityIncreasement; this.vitality -= gem.GemVitalityIncreasement; }
public void Execute(string[] commandParameters, IDictionary <string, IWeapon> weapons, IWeaponFactory weaponFactory, IInputOutputManager inputOutputManager, IGemFactory gemFactory) { string targetAxeName = commandParameters[0]; int socketIndex = int.Parse(commandParameters[1]); string[] tokens = commandParameters[2].Split(' '); string clarity = tokens[0]; string type = tokens[1]; IGem gem = gemFactory.CreateGem(type, clarity); IWeapon targetAxe = weapons[targetAxeName]; targetAxe.AddGem(gem, socketIndex); }
private void AddGem(IGem gem, int index) { try { if (index > 0 && index < 3) { gems[index] = gem; } } catch (Exception) { return; } }
public override void Execute() { string weaponName = this.Data[0]; int index = int.Parse(this.Data[1]); var gemData = this.Data[2].Split(); string clarity = gemData[0]; string gemType = gemData[1]; IGem gem = this.gemFactory.Create(clarity, gemType); IWeapon weapon = this.weaponRepository.GetWeapon(weaponName); weapon.AddSocked(gem, index); }
private void DecreaseByBonusStat(IGem gem) { var StrengthProp = gem.GetType() .GetProperty("Strength"); var AglityProp = gem.GetType() .GetProperty("Agility"); this.MinDamage -= 2 * (int)StrengthProp.GetValue(gem); this.MaxDamage -= 3 * (int)StrengthProp.GetValue(gem); this.MinDamage -= 1 * (int)AglityProp.GetValue(gem); this.MaxDamage -= 4 * (int)AglityProp.GetValue(gem); }
public override void Execute() { string weaponName = this.Data[1]; int index = int.Parse(this.Data[2]); string[] gemData = this.Data[3].Split(); string gemType = gemData[1]; string gemClarity = gemData[0]; IGem gem = this.GemFactory.CreateGem(gemType, gemClarity); IWeapon weapon = this.Repository.GetWeapon(weaponName); weapon.AddSocket(index, gem); }
public IGem CreateGem(params string[] parameters) { string gemClarity = parameters[0]; string gemType = parameters[1]; Assembly assembly = Assembly.GetCallingAssembly(); Type model = assembly.GetTypes().FirstOrDefault(t => t.Name == gemType); Validator.ValidateType(model, typeof(IGem)); IGem gem = (IGem)Activator.CreateInstance(model, gemClarity); return(gem); }
public void RemoveGem(int index) { if (index < 0 || index >= this.sockets.Length) { return; } IGem gemToRemove = this.sockets[index]; this.sockets[index] = null; DecreaseDemageValuesByGem(gemToRemove); }
public static void Main() { List <IWeapon> weapons = new List <IWeapon>(); while (true) { string[] commandArgs = Console.ReadLine().Split(";"); switch (commandArgs[0]) { case "Create": string weaponRarity = commandArgs[1].Split()[0]; string weponType = commandArgs[1].Split()[1]; Type type = Type.GetType($"{typeof(Weapon).Namespace}.{weponType}"); weapons.Add((IWeapon)Activator.CreateInstance(type, new object[] { commandArgs[2], weaponRarity })); break; case "Add": string weaponNmae = commandArgs[1]; int index = int.Parse(commandArgs[2]); string gemClarity = commandArgs[3].Split()[0]; string gemType = commandArgs[3].Split()[1]; Type typeOfGem = Type.GetType($"{typeof(Gem).Namespace}.{gemType}"); IGem gem = (IGem)Activator.CreateInstance(typeOfGem, new object[] { gemClarity }); weapons.Find(w => w.Name == weaponNmae).AddGem(index, gem); break; case "Remove": string name = commandArgs[1]; int fromIndex = int.Parse(commandArgs[2]); weapons.Find(w => w.Name == name).RemoveGem(fromIndex); break; case "Print": string weaponToPrint = commandArgs[1]; Console.WriteLine(weapons.Find(w => w.Name == weaponToPrint)); break; default: return; } } }
public void Run() { string input; while ((input = Console.ReadLine()) != "END") { string[] inputArgs = input.Split(';'); string command = inputArgs[0]; switch (command) { case "Create": string[] weaponArgs = inputArgs[1].Split(); string weaponType = weaponArgs[1]; string quality = weaponArgs[0]; string name = inputArgs[2]; IWeapon weapon = this.weaponFactory.CreateWeapon(weaponType, quality, name); this.weapons.Add(weapon); break; case "Add": string[] addGemArgs = inputArgs[3].Split(); string addGemClarity = addGemArgs[0]; string addGemType = addGemArgs[1]; IGem gem = this.gemFactory.CreateGem(addGemType, addGemClarity); IWeapon addGemWeapon = this.weapons.First(w => w.Name == inputArgs[1]); addGemWeapon.AddGem(int.Parse(inputArgs[2]), gem); break; case "Remove": IWeapon removeGemWeapon = this.weapons.First(w => w.Name == inputArgs[1]); removeGemWeapon.RemoveGem(int.Parse(inputArgs[2])); break; case "Print": IWeapon printWeapon = this.weapons.First(w => w.Name == inputArgs[1]); Console.WriteLine(printWeapon.ToString()); break; } } }
public void Add(string weaponName, int socketIndex, IGem gem) { var weapon = this.weapons.FirstOrDefault(x => x.Name == weaponName); if (weapon == null) { throw new ArgumentException($"{weaponName} is missing from repository."); } if (socketIndex >= 0 && socketIndex <= weapon.Sockets.Length - 1) { weapon.Sockets[socketIndex] = gem; } }
public IGem CreateGem(string[] data) { string gemClarity = data[0]; string gemType = data[1]; var type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(x => x.Name.ToLower() == gemType.ToLower()); if (type is null) { throw new ArgumentException("Invalid GemType!"); } IGem instance = (IGem)Activator.CreateInstance(type, new object[] { gemClarity }); return(instance); }
public override void Execute() { List <IWeapon> weapons = this.Repository.GetWeapons(); IWeapon weapon = weapons.FirstOrDefault(w => w.Name == base.Data[1]); if (weapon != null) { string[] gemInfo = base.Data[3] .Split(" ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); IGem gem = this.GemFactory.CreateGem(gemInfo[0], gemInfo[1]); weapon.AddGem(int.Parse(base.Data[2]), gem); } }
public IGem CreateGem(string args) { var splittedArgs = args.Split().ToList(); var clarity = (Clarity)Enum.Parse(typeof(Clarity), splittedArgs[0]); var type = splittedArgs[1]; IGem gem = null; switch (type) { case "Ruby": gem = new Ruby(); break; case "Emerald": gem = new Emerald(); break; case "Amethyst": gem = new Amethyst(); break; } var increaseStatsBy = 0; switch (clarity) { case Clarity.Chipped: increaseStatsBy = 1; break; case Clarity.Regular: increaseStatsBy = 2; break; case Clarity.Perfect: increaseStatsBy = 5; break; case Clarity.Flawless: increaseStatsBy = 10; break; } gem.Agility += increaseStatsBy; gem.Strenght += increaseStatsBy; gem.Vitality += increaseStatsBy; return(gem); }
public override void Execute() { string name = this.Data[0]; int index = int.Parse(this.Data[1]); var tokens = this.Data[2].Split(); string clarity = tokens[0]; string type = tokens[1]; IGem gem = this.gemFactory.CreateGem(clarity, type); this.repository.AddGem(name, index, gem); }
public void AddGem(int socketIndex, IGem gem) { if (ValidSocket(socketIndex)) { if (sockets[socketIndex] != null) { IGem currentGem = sockets[socketIndex]; RemoveGem(socketIndex, currentGem); } sockets[socketIndex] = gem; IncreaseStats(gem); } }
public void Add(string[] data) { string name = data[0]; int index = int.Parse(data[1]); string[] gemInfo = data[2].Split(); string clarity = gemInfo[0]; string type = gemInfo[1]; IGem gem = gemFactory.CreateGem(clarity, type); IWeapon weapon = this.weapons.FirstOrDefault(w => w.Name == name); weapon.AddGem(gem, index); }
public void AddGem(IGem gem, int socket) { if (this.Gems[socket] != null) { this.RemoveGem(socket); } this.Gems[socket] = gem; this.Strenght += gem.StrenghtIncrease; this.Agility += gem.AgilityIncrease; this.Vitality += gem.VitalityIncrease; SetDmg(); }
public void AddGem(IGem gem, int index) { if (index < 0 || index >= this.sockets.Length) { return; } if (sockets[index] != null) { DecreaseDamageValuesByGem(sockets[index]); } this.sockets[index] = gem; IncreaseDamageValuesByGem(gem); }
public IGem CreateGem(string clarity, string type) { Type currentGem = Type.GetType("InfernoInfinity.Entities.Gems." + type); GemClarity currentClarity; if (!Enum.TryParse <GemClarity>(clarity, out currentClarity)) { throw new ArgumentException("Invalid rarity type!"); } IGem instance = (IGem)Activator.CreateInstance(currentGem, new object[] { currentClarity }); return(instance); }
public void AddGemToWeapon(string weaponName, int gemIndex, IGem gem) { if (!this.weapons.Any(x => x.Name == weaponName)) { throw new ArgumentException($"{weaponName} doesn't exist"); } var currentWeapon = this.weapons.FirstOrDefault(x => x.Name.ToLower() == weaponName.ToLower()); if (gemIndex > currentWeapon.Sockets - 1) { throw new ArgumentException("Invalid socket"); } currentWeapon.AddGem(gemIndex, gem); }
public IGem CreateGem(string rarity, string gemType) { Enum.TryParse <GemRarity>(rarity, out var resultRarity); Assembly assembely = Assembly.GetCallingAssembly(); Type model = assembely.GetTypes().FirstOrDefault(x => x.Name == gemType + "Gem"); if (model == null) { throw new InvalidOperationException("Invalid gem type!"); } IGem gem = (IGem)Activator.CreateInstance(model, new object[] { resultRarity }); return(gem); }
public void AddGem(IGem gem, int index) { if (index >= 0 && index < this.gems.Length) { if (this.gems[index] != null) { this.strength -= this.gems[index].Strength; this.agility -= this.gems[index].Agility; this.vitality -= this.gems[index].Vitality; } this.gems[index] = gem; this.strength += gem.Strength; this.agility += gem.Agility; this.vitality += gem.Vitality; } }
public IGem Create(string gemClarity, string gemType) { Clarity clarity = (Clarity)Enum.Parse(typeof(Clarity), gemClarity); var assembly = Assembly.GetExecutingAssembly(); var type = assembly.GetTypes().FirstOrDefault(t => t.Name.ToLower() == gemType.ToLower()); if (type == null) { throw new ArgumentException("Invalid gem type!"); } IGem gem = (IGem)Activator.CreateInstance(type, new object[] { clarity }); return(gem); }
public override void Execute() { var gemClass = this.Data[3].Split()[1]; var clarityName = this.Data[3].Split()[0]; IGem gem = this.GemFactory.CreateGem(gemClass, clarityName); var weaponName = this.Data[1]; int index = int.Parse(this.Data[2]); IWeapon weapon = this.Repository.GetWeapon(weaponName); if (weapon != null) { weapon.AddGem(index, gem); } }
public void AddGem(IGem gem, int index) { if (!IndexIsValid(index)) { return; } if (this.gems[index] != null) { RemoveGem(index); } this.MinDmg += MinDmgBonusFromStr * gem.Stats.Strength + MinDmgBonusFromAgility * gem.Stats.Agility; this.MaxDmg += MaxDmgBonusFromStr * gem.Stats.Strength + MaxDmgBonusFromAgility * gem.Stats.Agility; this.gems[index] = gem; }
public override void Execute() { string weaponName = this.Data[1]; int socketIndex = int.Parse(this.Data[2]); string[] gemInfo = this.Data[3].Split(' '); string gemQuality = gemInfo[0]; string gemType = gemInfo[1]; IGem gem = this.gemFactory.CreateGem(gemType, gemQuality); IWeapon weapon = this.createdWeapons.FirstOrDefault(w => w.Name == weaponName); weapon.AddGem(gem, socketIndex); this.weaponStorage.Add(weapon); }