private IEnumerator DoEnemyCheck() { yield return(null); yield return(null); while (EffectReady) { RaycastHit[] hits = Physics.SphereCastAll(transform.position, Radius, Vector3.one); foreach (RaycastHit hit in hits) { if (hit.transform.CompareTag("enemyCollide")) { EnemyProgression ep = hit.transform.GetComponentInParent <EnemyProgression>(); if (ep != null) { if (fromEnemy) { ep.HealthScript.Health = (int)Mathf.Clamp(ep.HealthScript.Health + Healing / 2, 0, ep.maxHealth); ep.Slow(6, Boost, 25); } else { ep.HitMagic(Damage); ep.Slow(6, Slow, 10); } } } } yield return(new WaitForSeconds(0.5f)); } }
public ClinetEnemyProgression(Transform tr) { creationTime = Time.time; EnemyProgression p = tr.GetComponent <EnemyProgression>(); if (p == null) { p = tr.GetComponentInChildren <EnemyProgression>(); } if (p != null) { EnemyName = p.EnemyName; Level = p.Level; Health = (int)p.Health; MaxHealth = (int)p.MaxHealth; ExpBounty = p.Bounty; Armor = p.Armor; ArmorReduction = p.ArmorReduction; SteadFest = p.SteadFest; Affixes = new int[p.abilities.Count]; for (int i = 0; i < p.abilities.Count; i++) { Affixes[i] = (int)p.abilities[i]; } } }
public static void AddHostEnemy(EnemyProgression ep) { if (!hostDictionary.ContainsKey(ep.entity.networkId.PackedValue)) { hostDictionary.Add(ep.entity.networkId.PackedValue, ep); } }
public ClinetEnemyProgression(BoltEntity e) { creationTime = Time.time; Entity = e; Packed = e.networkId.PackedValue; if (GameSetup.IsMpClient) { Network.NetworkManager.SendLine("EE" + Packed.ToString() + ";", Network.NetworkManager.Target.OnlyServer); } else { EnemyProgression p = EnemyManager.hostDictionary[Packed]; EnemyName = p.EnemyName; Level = p.Level; Health = (int)p.Health; MaxHealth = (int)p.MaxHealth; ExpBounty = p.Bounty; Armor = p.Armor; ArmorReduction = p.ArmorReduction; SteadFest = p.SteadFest; Affixes = new int[p.abilities.Count]; for (int i = 0; i < p.abilities.Count; i++) { Affixes[i] = (int)p.abilities[i]; } } if (!EnemyManager.clinetProgressions.ContainsKey(e)) { EnemyManager.clinetProgressions.Add(e, this); } }
public static void RemoveEnemy(EnemyProgression ep) { try { if (ep.entity != null) { if (ep.entity.networkId != null) { if (hostDictionary.ContainsKey(ep.entity.networkId.PackedValue)) { hostDictionary.Remove(ep.entity.networkId.PackedValue); } } } else if (GameSetup.IsSinglePlayer) { singlePlayerList.Remove(ep); } if (spProgression != null) { if (spProgression.ContainsKey(ep.transform.root)) { spProgression.Remove(ep.transform.root); } } } catch (System.Exception e) { ModAPI.Log.Write(e.ToString()); } }
void Update() { lifetime += Time.deltaTime; scale = Mathf.Clamp(scale + Time.deltaTime * radius * 1.5f / duration / 2, 0, radius / 5); transform.localScale = Vector3.one * scale / 3; RaycastHit[] hits = Physics.SphereCastAll(transform.position, scale * 5, Vector3.one, scale * 5); foreach (RaycastHit hit in hits) { Rigidbody rb = hit.rigidbody; if (rb != null) { if (!(!FromEnemy && rb == LocalPlayer.Rigidbody)) { Vector3 force = transform.position - rb.position; force *= 20 / force.magnitude; force *= pullForce; rb.AddForce(force); } } if (!GameSetup.IsMpClient && !FromEnemy) { if (hit.transform.tag == "enemyCollide") { if (!CoughtEnemies.Contains(hit.transform.root)) { if (hit.transform.root.GetComponentInChildren <EnemyHealth>() != null) { CoughtEnemies.Add(hit.transform.root); } } } } } transform.Translate(Vector3.up * 0.55f * Time.deltaTime * (Mathf.Pow(duration - (lifetime), 2)) / duration); transform.Rotate(Vector3.up * rotationSpeed); if (FromEnemy) { if (Vector3.Distance(LocalPlayer.Transform.position, transform.position) < scale * 5) { Pull(LocalPlayer.Transform); LocalPlayer.Stats.Health -= damage * Time.deltaTime; } } else if (!GameSetup.IsMpClient) { foreach (Transform t in CoughtEnemies) { EnemyProgression p = t.GetComponentInChildren <EnemyProgression>(); if (!p.CCimmune) { Pull(t); } } } }
protected override void Update() { if (progression == null) { progression = GetComponent <EnemyProgression>(); } if (setup.waterDetect.drowned) { HitReal(Health); } base.Update(); }
public static void AddHostEnemy(EnemyProgression ep) { if (!hostDictionary.ContainsKey(ep.entity.networkId.PackedValue)) { CotfUtils.Log("Adding enemy " + ep.entity.networkId.PackedValue + " : Level " + ep.Level + " " + ep.enemyType + " with " + ep.MaxHealth.ToString("N0") + " hp"); hostDictionary.Add(ep.entity.networkId.PackedValue, ep); } else { hostDictionary[ep.entity.networkId.PackedValue] = ep; } }
//Returns clinet progression for Singleplayer public static ClinetEnemyProgression GetCP(Transform tr) { if (spProgression.ContainsKey(tr.root)) { ClinetEnemyProgression cp = spProgression[tr.root]; if (Time.time <= cp.creationTime + ClinetEnemyProgression.LifeTime) { return(cp); } else { spProgression.Remove(tr.root); } } else { EnemyProgression p = tr.root.GetComponent <EnemyProgression>(); if (p == null) { p = tr.root.GetComponentInChildren <EnemyProgression>(); } if (p != null) { ClinetEnemyProgression cpr = new ClinetEnemyProgression(tr.root); spProgression.Add(tr.root, cpr); return(cpr); } else { { mutantScriptSetup setup = tr.root.GetComponentInChildren <mutantScriptSetup>(); if (setup == null) { setup = tr.root.GetComponent <mutantScriptSetup>(); } if (setup != null) { p = setup.health.gameObject.AddComponent <EnemyProgression>(); if (p != null) { p._Health = setup.health; p._AI = setup.ai; p.entity = setup.GetComponent <BoltEntity>(); p.setup = setup; } } } } } return(null); }
protected override void Update() { if (progression == null) { progression = GetComponent <EnemyProgression>(); } if (setup.waterDetect.drowned && !deadBlock) { Health = 0; HitReal(100); } base.Update(); }
protected override void Update() { if (progression == null) { progression = GetComponent <EnemyProgression>(); } if (setup.waterDetect.drowned && !deadBlock) { Health = 0; progression.extraHealth = 0; dieExplode(); } base.Update(); }
IEnumerator HitEverySecond() { while (true) { foreach (Transform t in CoughtEnemies) { EnemyProgression ep = t.GetComponentInChildren <EnemyProgression>(); if (ep != null) { ep.HitMagic(Mathf.RoundToInt(damage / 2)); } } yield return(new WaitForSeconds(0.5f)); } }
public static void RemoveEnemy(EnemyProgression ep) { if (ep.entity != null) { if (ep.entity.networkId != null) { if (hostDictionary.ContainsKey(ep.entity.networkId.PackedValue)) { hostDictionary.Remove(ep.entity.networkId.PackedValue); } } } if (spProgression.ContainsKey(ep.transform.root)) { spProgression.Remove(ep.transform.root); } }
private IEnumerator HitEverySecond() { while (true) { foreach (Transform t in CoughtEnemies) { EnemyProgression ep = t.GetComponentInChildren <EnemyProgression>(); if (ep != null) { DamageMath.DamageClamp(damage, out int d, out int a); for (int i = 0; i < a; i++) { ep.HitMagic(Mathf.RoundToInt(d / 2)); } } } yield return(new WaitForSeconds(0.5f)); } }
public ClinetEnemyProgression(BoltEntity e) { creationTime = Time.time; Entity = e; Packed = e.networkId.PackedValue; if (GameSetup.IsMpClient) { using (System.IO.MemoryStream answerStream = new System.IO.MemoryStream()) { using (System.IO.BinaryWriter w = new System.IO.BinaryWriter(answerStream)) { w.Write(6); w.Write(Packed); w.Close(); } ChampionsOfForest.Network.NetworkManager.SendLine(answerStream.ToArray(), ChampionsOfForest.Network.NetworkManager.Target.OnlyServer); answerStream.Close(); } } else { Debug.Log("Enemy in dictionary + " + Packed + " contains: " + EnemyManager.hostDictionary.ContainsKey(Packed)); EnemyProgression p = EnemyManager.hostDictionary[Packed]; EnemyName = p.enemyName; Level = p.Level; Health = p.extraHealth + p.HealthScript.Health; MaxHealth = p.maxHealth; ExpBounty = p.bounty; Armor = p.Armor; ArmorReduction = p.ArmorReduction; Steadfast = p.Steadfast; Affixes = new int[p.abilities.Count]; for (int i = 0; i < p.abilities.Count; i++) { Affixes[i] = (int)p.abilities[i]; } } if (!EnemyManager.clinetProgressions.ContainsKey(e)) { EnemyManager.clinetProgressions.Add(e, this); } }
//It takes some time for enemies to appear on screen. private void LateProgressionCreate() { try { if (progression == null) { progression = gameObject.AddComponent <EnemyProgression>(); progression._Health = this; progression._AI = ai; progression.entity = entity; progression.setup = setup; } progression.setupComplete = false; progression.OnDieCalled = false; } catch (System.Exception e) { ModAPI.Log.Write(e.ToString()); } }
/// <summary> /// host/singleplayer constructor /// </summary> /// <param name="tr"></param> public ClientEnemyProgression(Transform tr) { creationTime = Time.time; EnemyProgression p = tr.GetComponent <EnemyProgression>(); if (p == null) { p = tr.GetComponentInChildren <EnemyProgression>(); } if (p != null) { EnemyName = p.enemyName; dynCEP = new DynamicClientEnemyProgression(p.extraHealth + p.HealthScript.Health, p.armor, p.armorReduction, p.DamageTotal); Level = p.level; MaxHealth = p.maxHealth; ExpBounty = p.bounty; Steadfast = p.Steadfast; Affixes = new int[p.abilities.Count]; for (int i = 0; i < p.abilities.Count; i++) { Affixes[i] = (int)p.abilities[i]; } } }
public static void ReduceArmor(EnemyProgression target, int amount) { target.ArmorReduction += amount; }
//Returns clinet progression for Singleplayer public static ClientEnemyProgression GetCP(Transform tr) { if (spProgression.ContainsKey(tr.root)) { ClientEnemyProgression cp = spProgression[tr.root]; if (cp.Health <= 0) { spProgression.Remove(tr.root); return(null); } if (Time.time <= cp.creationTime + ClientEnemyProgression.LifeTime) { if (cp.DynamicOutdated) { Debug.Log("Outdated dynamic CP"); var e = tr.GetComponentInParent <EnemyProgression>(); if (e) { cp.UpdateDynamic(e.HP, e.armor, e.armorReduction, e.DamageTotal); } } } else { Debug.Log("Outdated static CP"); var e = tr.GetComponentInParent <EnemyProgression>(); if (e) { cp.Update(null, e.enemyName, e.level, e.HP, e.DamageTotal, e.maxHealth, e.bounty, e.armor, e.armorReduction, e.Steadfast, e.abilities.Count > 0 ? e.abilities.Select(x => (int)x).ToArray() : new int[0]); } } return(cp); } else { EnemyProgression p = tr.root.GetComponent <EnemyProgression>(); if (p == null) { p = tr.root.GetComponentInChildren <EnemyProgression>(); } if (p != null) { ClientEnemyProgression cpr = new ClientEnemyProgression(tr.root); spProgression.Add(tr.root, cpr); return(cpr); } else { { mutantScriptSetup setup = tr.root.GetComponentInChildren <mutantScriptSetup>(); if (setup == null) { setup = tr.root.GetComponent <mutantScriptSetup>(); } if (setup != null) { p = setup.health.gameObject.AddComponent <EnemyProgression>(); if (p != null) { p.HealthScript = setup.health; p.AIScript = setup.ai; p.entity = setup.GetComponent <BoltEntity>(); p.setup = setup; } } } } } return(null); }