public void Init(HunterStats stats, Vector3 position, List <Hunter> parents = null) { HunterType = stats.HunterType; Attack = stats.Attack; Health = stats.Health; LowHealthThreshold = stats.LowHealthThreshold; Speed = stats.Speed; SightDistance = stats.SightDistance; ProcreationProbability = stats.ProcreationProbability; ProcreationTime = stats.ProcreationTime; transform.position = position; if (parents != null) { Parents = parents; } maxHealth = stats.Health; rb.mass = Health * sizeMultiplier; transform.localScale = Vector3.one * rb.mass; areaOfEffectRing.localScale = areaOfEffectBaseScale * SightDistance; switch (HunterType) { case HunterType.Solo: SoloHunters += 1; break; case HunterType.Group: GroupHunters += 1; break; } }
public HunterStats(HunterStats stats) { HunterType = stats.HunterType; Attack = stats.Attack; Health = stats.Health; LowHealthThreshold = stats.LowHealthThreshold; Speed = stats.Speed; SightDistance = stats.SightDistance; ProcreationProbability = stats.ProcreationProbability; ProcreationTime = stats.ProcreationTime; }
private void DemoDataStructures() { /* * 1) Why and when its used? * 2) How to add/remove * 3) How to iterate * 4) How to get size * 5) ------- */ //Array => | null | Address | CharacterType[] characterTypes = new CharacterType[2]; characterTypes[0] = new HunterType("h1", "ah1", 10, 5); characterTypes[1] = new HunterType("xh1", "xah1", 60, 25); characterTypes[0] = null; foreach (CharacterType c in characterTypes) { HunterType h = c as HunterType; Console.WriteLine(h.defaultModel); } for (int i = 0; i < characterTypes.Length; i++) { HunterType h = characterTypes[i] as HunterType; Console.WriteLine(h.defaultModel); if (h.alternateModel.Equals("h1")) { } } //List List <int> numberList = new List <int>(); numberList.Add(12); numberList.Add(120); numberList.Add(1200); numberList.Remove(1); //120 numberList.RemoveRange(0, 2); // numberList.Count; foreach (var x in numberList) { Console.WriteLine(x); } //Stack Stack <string> comsumables = new Stack <string>(); //LIFO (last in, first out) comsumables.Push("a"); comsumables.Push("d"); comsumables.Push("c"); comsumables.Push("d"); Console.WriteLine(comsumables.Pop()); //d => list now has a, b, c Console.WriteLine(comsumables.Peek()); //c => list still has a, b, c //comsumables.Count; foreach (string s in comsumables) { Console.WriteLine(s); } //Queue Queue <double> doubleQueue = new Queue <double>(); //FIFO doubleQueue.Enqueue(3.14); doubleQueue.Enqueue(2.81); doubleQueue.Enqueue(2.99792458); double value = doubleQueue.Dequeue(); //3.14 Console.WriteLine(doubleQueue.Count); foreach (double d in doubleQueue) { Console.WriteLine(d); } //Set HashSet <String> shopping = new HashSet <string>(); shopping.Add("kiwi"); shopping.Add("milk"); shopping.Add("meat"); shopping.Add("orange"); shopping.Add("kiwi"); if (shopping.Add("milk")) { Console.WriteLine("Already added this!!!"); } //Dictionary }