public CreatureStatus(Xml.Status xmlstatus, Creature target, Xml.Castable castable = null, Creature source = null, int duration = -1, int tickFrequency = -1, double intensity = 1.0) { Target = target; XmlStatus = xmlstatus; Start = DateTime.Now; Target = target; Source = source; Duration = duration == -1 ? xmlstatus.Duration : duration; Tick = tickFrequency == -1 ? xmlstatus.Tick : tickFrequency; Intensity = intensity; // Calculate damage/heal effects. Note that a castable MUST be passed here for a status // to have damage effects as the castable itself has fields we need to access // (intensity, etc) in order to do damage calculations. if (castable != null) { var start = CalculateNumericEffects(castable, xmlstatus.Effects.OnApply, source); var tick = CalculateNumericEffects(castable, xmlstatus.Effects.OnTick, source); var end = CalculateNumericEffects(castable, xmlstatus.Effects.OnRemove, source); var expire = CalculateNumericEffects(castable, xmlstatus.Effects.OnExpire, source); OnStartEffect = new SimpleStatusEffect(start.Heal, start.Damage); OnTickEffect = new SimpleStatusEffect(tick.Heal, tick.Damage); OnRemoveEffect = new SimpleStatusEffect(end.Heal, end.Damage); OnExpireEffect = new SimpleStatusEffect(expire.Heal, expire.Damage); BonusModifiers = NumberCruncher.CalculateStatusModifiers(castable, intensity, xmlstatus.Effects.OnApply.StatModifiers, source, target); } }
public int lmIndex; // Updated by LevelManager when level changes /* -----< DECLARATIONS -END >----- */ #endregion DECLARATIONS #region AWAKE void Awake() { //Persistence if (Instance) { DestroyImmediate(gameObject); } else { DontDestroyOnLoad(gameObject); Instance = this; } //Scene stuff totalScenes = SceneManager.sceneCountInBuildSettings; //Am I connected to Level Manager? If not get a connection. if (!levelManager) { levelManager = GameObject.FindObjectOfType <LevelManager>(); } //Am I connected to hud? If not get a connection. if (!hud) { hud = GameObject.FindObjectOfType <HUD>(); } } //Awake() -end
static void Main(string[] args) { NumberCruncher numberCruncher = new NumberCruncher(); numberCruncher.Run(); Console.ReadLine(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { NumberCruncher.Register(ApplicationView.GetForCurrentView().Id, Window.Current.Dispatcher, numberCruncher); UpdateText(); //ApplicationView.GetForCurrentView().Consolidated += MainPage_Consolidated; //CoreApplication.GetCurrentView().CoreWindow.Closed += CoreWindow_Closed; }
/* -----< DECLARATIONS -END >----- */ void Start() { //Find Objects nc = GameObject.FindObjectOfType <NumberCruncher>(); enemy = GameObject.FindObjectOfType <Enemy>(); //nc.Enemies_Spawned(false); //Edge of screen stuff float distanceToCamera = transform.position.z - Camera.main.transform.position.z; Vector3 leftBoundry = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distanceToCamera)); Vector3 rightBoundry = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distanceToCamera)); xmax = rightBoundry.x; xmin = leftBoundry.x; //Edge of screen stuff - end SpawnUntilFull(); //Populate with enemies spawned = true; enemy.Formation_Spawned(GetInstanceID(), spawned); //Report 'Spawned' to enemy manager } //Start() -end
/* -----< DECLARATIONS - END >----- */ void Start() { //Find Objects nc = GameObject.FindObjectOfType <NumberCruncher>(); myJoystick = GameObject.FindObjectOfType <UltimateJoystick>(); myFire = GameObject.FindObjectOfType <UltimateButton>(); levelManager = GameObject.FindObjectOfType <LevelManager>(); //TODO: Add comments to whole section float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance)); xmin = leftmost.x + padding; xmax = rightmost.x - padding; //Get the size of the player controls from the PPM //Also applies changes made to the controls in the setting menu myJoystick.joystickSize = PlayerPrefsManager.ControlsSize_Get(); myFire.buttonSize = PlayerPrefsManager.ControlsSize_Get(); myFire.UpdatePositioning(); // ask UB to update our changes myJoystick.UpdatePositioning(); // ask UJ to update our changes } //Start() -end
public MainPage() { this.InitializeComponent(); random = new Random(); numberCruncher = new NumberCruncher(); numberCruncher.NumberEvent += NumberCruncher_NumberEvent; synchronizationContext = SynchronizationContext.Current; }
/* -----< DECLARATIONS - END >----- */ private void Start() { //INITIALISATION //Find Objects nc = GameObject.FindObjectOfType<NumberCruncher>(); levelComplete_txt.enabled = false; }
public void ImplementsINumberCruncher(NumberCruncher cruncher) { // -- Arrange // -- Act // -- Assert Assert.IsAssignableFrom <INumberCruncher>(cruncher); }
void Start() { // Get the value of the Player Shield from Number Cruncher nc = GameObject.FindObjectOfType <NumberCruncher>(); float shield = nc.playerShield; float max = nc.playerShieldMax; UltimateStatusBar.UpdateStatus("PlayerShield", shield, max); }
void Start() { // Get the value of the Player Shield from Number Cruncher nc = GameObject.FindObjectOfType <NumberCruncher>(); float health = nc.playerHealth; float max = nc.playerHealthMax; UltimateStatusBar.UpdateStatus("PlayerHealth", health, max); }
//SCRIPT //DECLARATIONS -end void Start() { nc = GameObject.FindObjectOfType<NumberCruncher>(); if (nc != null) { nc.lmIndex = SceneManager.GetActiveScene().buildIndex; } }
public bool allSpawned = false; //flag for all enemies spawned /* -----< DECLARATIONS -END >----- */ #endregion DECLARATIONS #region START void Start() { //Find Objects nc = GameObject.FindObjectOfType <NumberCruncher>(); //INITIALISE //Formantions Fomation_Count(); } //Start () -end
static void Main(string[] args) { List <int> numberList = new List <int>() { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; Console.Write(NumberCruncher.EvenNumbers(numberList)); Console.ReadLine(); }
public async void Run(IBackgroundTaskInstance taskInstance) { deferral = taskInstance.GetDeferral(); taskEndTime = DateTime.Now + TimeSpan.FromSeconds(25); numberCruncher = new NumberCruncher(); //numberCruncher.RandomNumberEvent += NumberCruncher_RandomNumberEvent; numberCruncher.NumberEvent += NumberCruncher_NumberEvent; numberCruncher.StartNumberFetcher(); await CheckTimer(); deferral.Complete(); }
public void ApplyOperationReturnsTheSameValue( int expected, NumberCruncher calculator) { // -- Arrange // -- Act var actual = calculator.Apply(expected); // -- Assert Assert.Equal(expected, actual); }
public void AddOperationReturnsCorrectResultWhenAppliedToZero( int value, int expected, NumberCruncher calculator) { // -- Arrange // -- Act var actual = calculator.Add(value).Apply(0); // -- Assert Assert.Equal(expected, actual); }
public void SubtractOperationReturnsCorrectResultWhenAppliedToZero( int value, int expected, NumberCruncher calculator) { // -- Arrange // -- Act var actual = calculator.Subtract(value).Apply(0); // -- Assert Assert.Equal(expected, actual); }
public void DivideOperationReturnsCorrectResultWhenAppliedToTwo( int value, decimal expected, NumberCruncher calculator) { // -- Arrange // -- Act var actual = calculator.Divide(value).Apply(2); // -- Assert Assert.Equal(expected, actual); }
static void Main(string[] args) { //create list of numbers List <int> numbers = new List <int>() { 1, 9, 14, 27, 36, 45, 49, 52, 64, 73, 88, 92 }; //Call on the method in the NumberCruncher class/ NumberUtility Class Library Console.WriteLine("There is a list of numbers.\n"); Console.WriteLine($"The sum of even numbers in the list is: {NumberCruncher.CrunchNumbers(numbers)}\n"); Console.WriteLine($"Can you guess what the numbers are? \n\nlol jk\n"); Console.ReadLine(); }
//SCRIPT /* -----< DECLARATIONS - END >----- */ #endregion #region START private void Start() { //Dynamically get objects and assign a handle nc = GameObject.FindObjectOfType <NumberCruncher>(); //Enemy if (GetInstanceID() != 0) //send instanceid to nc { nc.EnemyRoster_Add(GetInstanceID()); } } //Start() -end
static void Main(string[] args) { //I created a set list, but can create list from user-entered integers var numbers = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //create variable for value from method in class int sum = NumberCruncher.EvenSum(numbers); //print to console in a string Console.WriteLine("The total sum of all the even numbers in a list from 1-10: {0}", sum); Console.ReadLine(); }
static void Main(string[] args) { List <int> nums = new List <int>(); nums.Add(10); nums.Add(5); nums.Add(6); nums.Add(7); nums.Add(8); nums.Add(2); nums.Add(14); nums.Add(3); nums.Add(4); nums.Add(22); Console.WriteLine(NumberCruncher.SumOfEvens(nums)); Console.ReadLine(); }
private (double Heal, DamageOutput Damage) CalculateNumericEffects(Xml.Castable castable, Xml.ModifierEffect effect, Creature source) { double heal = 0; var dmg = new DamageOutput(); if (effect == null) { return(heal, dmg); } if (effect.Heal != null) { heal = NumberCruncher.CalculateHeal(castable, effect, Target, source, Name); } if (effect.Damage != null) { dmg = NumberCruncher.CalculateDamage(castable, effect, Target, source, Name); } return(heal, dmg); }
static void Main(string[] args) { List <int> nums = new List <int>() { 10, 5, 8, 6, 7, 2, 14, 3, 4, 22 }; //nums.Add(10); //nums.Add(5); //nums.Add(6); //nums.Add(7); //nums.Add(8); //nums.Add(2); //nums.Add(14); //nums.Add(3); //nums.Add(4); //nums.Add(22); Console.WriteLine("The sum of all the even numbers is: \n" + NumberCruncher.SumOfEvens(nums)); Console.ReadLine(); }
public void CalculatesASimpleEquation( int applyValue, int multiplyValue, int subtractValue, int divideValue, int addValue, decimal expected, NumberCruncher calculator) { // -- Arrange // -- Act var actual = calculator .Multiply(multiplyValue) .Subtract(subtractValue) .Divide(divideValue) .Add(addValue) .Apply(applyValue); // -- Assert Assert.Equal(expected, actual); }
// Use this for initialization void Start() { #region Number Cruncher Destroy nc = FindObjectOfType <NumberCruncher>(); //Find the running NumberCruncher if (GameObject.Find("NumberCruncher") != null) // If NumberCruncher DOES exist { nc = FindObjectOfType <NumberCruncher>(); highscore.text = nc.highScore.ToString(); score.text = nc.score.ToString(); Destroy(nc.gameObject); // Finished getting data from Number Cruncher. // Destroy it otherwise there will be another // when the game level starts. } else if (GameObject.Find("NumberCruncher") == null) // If NumberCruncher does NOT exists { Debug.LogError("Could not find a NumberCruncher to open"); } #endregion } //Start() -end
public virtual bool UseCastable(Xml.Castable castObject, Creature target = null, Xml.SpawnCastable spawnCastable = null) { if (!Condition.CastingAllowed) { return(false); } if (this is User) { GameLog.UserActivityInfo($"UseCastable: {Name} begin casting {castObject.Name} on target: {target?.Name ?? "no target"} CastingAllowed: {Condition.CastingAllowed}"); } var damage = castObject.Effects.Damage; List <Creature> targets = new List <Creature>(); if (this is Monster) { if (spawnCastable != null) { damage = new Xml.CastableDamage { Simple = new Xml.SimpleQuantity { Min = (uint)spawnCastable.MinDmg, Max = (uint)spawnCastable.MaxDmg } }; castObject.Effects.Damage = damage; //set damage based on spawncastable settings. castObject.Element = spawnCastable.Element; //handle defined element without redoing a ton of code. } } targets = GetTargets(castObject, target); // Quick checks // If no targets and is not an assail, do nothing if (targets.Count() == 0 && castObject.IsAssail == false && string.IsNullOrEmpty(castObject.Script)) { GameLog.UserActivityInfo($"UseCastable: {Name}: no targets and not assail"); return(false); } // Is this a pvpable spell? If so, is pvp enabled? // We do these next steps to ensure effects are displayed uniformly and as fast as possible var deadMobs = new List <Creature>(); if (castObject.Effects?.Animations?.OnCast != null) { foreach (var tar in targets) { foreach (var user in tar.viewportUsers.ToList()) { GameLog.UserActivityInfo($"UseCastable: Sending {user.Name} effect for {Name}: {castObject.Effects.Animations.OnCast.Target.Id}"); user.SendEffect(tar.Id, castObject.Effects.Animations.OnCast.Target.Id, castObject.Effects.Animations.OnCast.Target.Speed); } } if (castObject.Effects?.Animations?.OnCast?.SpellEffect != null) { GameLog.UserActivityInfo($"UseCastable: Sending spelleffect for {Name}: {castObject.Effects.Animations.OnCast.SpellEffect.Id}"); Effect(castObject.Effects.Animations.OnCast.SpellEffect.Id, castObject.Effects.Animations.OnCast.SpellEffect.Speed); } } if (castObject.Effects?.Sound != null) { PlaySound(castObject.Effects.Sound.Id); } GameLog.UserActivityInfo($"UseCastable: {Name} casting {castObject.Name}, {targets.Count()} targets"); if (!string.IsNullOrEmpty(castObject.Script)) { // If a script is defined we fire it immediately, and let it handle targeting / etc if (Game.World.ScriptProcessor.TryGetScript(castObject.Script, out Script script)) { return(script.ExecuteFunction("OnUse", this)); } else { GameLog.UserActivityError($"UseCastable: {Name} casting {castObject.Name}: castable script {castObject.Script} missing"); return(false); } } if (targets.Count == 0) { GameLog.UserActivityError("{Name}: {castObject.Name}: hey fam no targets"); } foreach (var tar in targets) { if (castObject.Effects?.ScriptOverride == true) { // TODO: handle castables with scripting // DoStuff(); continue; } if (!castObject.Effects.Damage.IsEmpty) { Xml.Element attackElement; var damageOutput = NumberCruncher.CalculateDamage(castObject, tar, this); if (castObject.Element == Xml.Element.Random) { Random rnd = new Random(); var Elements = Enum.GetValues(typeof(Xml.Element)); attackElement = (Xml.Element)Elements.GetValue(rnd.Next(Elements.Length)); } else if (castObject.Element != Xml.Element.None) { attackElement = castObject.Element; } else { attackElement = (Stats.OffensiveElementOverride != Xml.Element.None ? Stats.OffensiveElementOverride : Stats.BaseOffensiveElement); } GameLog.UserActivityInfo($"UseCastable: {Name} casting {castObject.Name} - target: {tar.Name} damage: {damageOutput}, element {attackElement}"); tar.Damage(damageOutput.Amount, attackElement, damageOutput.Type, damageOutput.Flags, this, false); if (this is Monster) { if (tar is User) { (tar as User).SendSystemMessage($"{this.Name} attacks you with {castObject.Name}."); } } if (this is User) { if (Equipment.Weapon != null && !Equipment.Weapon.Undamageable) { Equipment.Weapon.Durability -= 1 / (Equipment.Weapon.MaximumDurability * ((100 - Stats.Ac) == 0 ? 1 : (100 - Stats.Ac))); } } if (tar.Stats.Hp <= 0) { deadMobs.Add(tar); } } // Note that we ignore castables with both damage and healing effects present - one or the other. // A future improvement might be to allow more complex effects. else if (!castObject.Effects.Heal.IsEmpty) { var healOutput = NumberCruncher.CalculateHeal(castObject, tar, this); tar.Heal(healOutput, this); if (this is User) { GameLog.UserActivityInfo($"UseCastable: {Name} casting {castObject.Name} - target: {tar.Name} healing: {healOutput}"); if (Equipment.Weapon != null && !Equipment.Weapon.Undamageable) { Equipment.Weapon.Durability -= 1 / (Equipment.Weapon.MaximumDurability * ((100 - Stats.Ac) == 0 ? 1 : (100 - Stats.Ac))); } } } // Handle statuses foreach (var status in castObject.Effects.Statuses.Add.Where(e => e.Value != null)) { Xml.Status applyStatus; if (World.WorldData.TryGetValue <Xml.Status>(status.Value.ToLower(), out applyStatus)) { var duration = status.Duration == 0 ? applyStatus.Duration : status.Duration; GameLog.UserActivityInfo($"UseCastable: {Name} casting {castObject.Name} - applying status {status.Value} - duration {duration}"); tar.ApplyStatus(new CreatureStatus(applyStatus, tar, castObject, this, duration)); } else { GameLog.UserActivityError($"UseCastable: {Name} casting {castObject.Name} - failed to add status {status.Value}, does not exist!"); } } foreach (var status in castObject.Effects.Statuses.Remove) { Xml.Status applyStatus; if (World.WorldData.TryGetValue <Xml.Status>(status.ToLower(), out applyStatus)) { GameLog.UserActivityError($"UseCastable: {Name} casting {castObject.Name} - removing status {status}"); tar.RemoveStatus(applyStatus.Icon); } else { GameLog.UserActivityError($"UseCastable: {Name} casting {castObject.Name} - failed to remove status {status}, does not exist!"); } } } // Now flood away foreach (var dead in deadMobs) { World.ControlMessageQueue.Add(new HybrasylControlMessage(ControlOpcodes.HandleDeath, dead)); } Condition.Casting = false; return(true); }
public void ImplementsINumberCruncher(NumberCruncher cruncher) { // -- Arrange // -- Act // -- Assert Assert.IsAssignableFrom<INumberCruncher>(cruncher); }
public virtual bool UseCastable(Castable castObject, Creature target = null) { if (!Condition.CastingAllowed) { return(false); } if (this is User) { ActivityLogger.Info($"UseCastable: {Name} begin casting {castObject.Name} on target: {target?.Name ?? "no target"} CastingAllowed: {Condition.CastingAllowed}"); } var damage = castObject.Effects.Damage; List <Creature> targets; targets = GetTargets(castObject, target); if (targets.Count() == 0) { return(false); } // We do these next steps to ensure effects are displayed uniformly and as fast as possible var deadMobs = new List <Creature>(); foreach (var tar in targets) { foreach (var user in tar.viewportUsers) { user.SendEffect(tar.Id, castObject.Effects.Animations.OnCast.Target.Id, castObject.Effects.Animations.OnCast.Target.Speed); } } if (castObject.Effects?.Animations?.OnCast?.SpellEffect != null) { Effect(castObject.Effects.Animations.OnCast.SpellEffect.Id, castObject.Effects.Animations.OnCast.SpellEffect.Speed); } if (castObject.Effects.Sound != null) { PlaySound(castObject.Effects.Sound.Id); } ActivityLogger.Info($"UseCastable: {Name} casting {castObject.Name}, {targets.Count()} targets"); foreach (var tar in targets) { if (castObject.Effects?.ScriptOverride == true) { // TODO: handle castables with scripting // DoStuff(); continue; } if (castObject.Effects?.Damage != null) { Enums.Element attackElement; var damageOutput = NumberCruncher.CalculateDamage(castObject, tar, this); if (castObject.Element == Castables.Element.Random) { Random rnd = new Random(); var Elements = Enum.GetValues(typeof(Enums.Element)); attackElement = (Enums.Element)Elements.GetValue(rnd.Next(Elements.Length)); } else if (castObject.Element != Castables.Element.None) { attackElement = (Enums.Element)castObject.Element; } else { attackElement = (Stats.OffensiveElementOverride == Enums.Element.None ? Stats.OffensiveElementOverride : Stats.OffensiveElement); } if (this is User) { ActivityLogger.Info($"UseCastable: {Name} casting {castObject.Name} - target: {tar.Name} damage: {damageOutput}, element {attackElement}"); } tar.Damage(damageOutput.Amount, attackElement, damageOutput.Type, damageOutput.Flags, this, false); if (tar.Stats.Hp <= 0) { deadMobs.Add(tar); } } // Note that we ignore castables with both damage and healing effects present - one or the other. // A future improvement might be to allow more complex effects. else if (castObject.Effects.Heal != null) { var healOutput = NumberCruncher.CalculateHeal(castObject, tar, this); tar.Heal(healOutput, this); if (this is User) { ActivityLogger.Info($"UseCastable: {Name} casting {castObject.Name} - target: {tar.Name} healing: {healOutput}"); } } // Handle statuses foreach (var status in castObject.Effects.Statuses.Add.Where(e => e.Value != null)) { Status applyStatus; if (World.WorldData.TryGetValueByIndex <Status>(status.Value, out applyStatus)) { ActivityLogger.Info($"UseCastable: {Name} casting {castObject.Name} - applying status {status.Value}"); ApplyStatus(new CreatureStatus(applyStatus, tar, castObject)); } else { ActivityLogger.Error($"UseCastable: {Name} casting {castObject.Name} - failed to add status {status.Value}, does not exist!"); } } foreach (var status in castObject.Effects.Statuses.Remove) { Status applyStatus; if (World.WorldData.TryGetValueByIndex <Status>(status, out applyStatus)) { ActivityLogger.Error($"UseCastable: {Name} casting {castObject.Name} - removing status {status}"); RemoveStatus(applyStatus.Icon); } else { ActivityLogger.Error($"UseCastable: {Name} casting {castObject.Name} - failed to remove status {status}, does not exist!"); } } } // Now flood away foreach (var dead in deadMobs) { World.ControlMessageQueue.Add(new HybrasylControlMessage(ControlOpcodes.HandleDeath, dead)); } return(true); }