public GameObject GetSlimeFromPool(int type, Vector3 position = new Vector3()) { GameObject slime_obj = ObjectManager.Instance.InstantiateWithObjectPooling(_drop.GetPrefab(), position); Stats temp = EnumHolder.Instance.GetStats(_drop.GetPrefab().name); SlimeBase temp_component = slime_obj.GetComponent <SlimeBase>(); if (temp_component != null) { Destroy(temp_component); } System.Type _MyScriptType = System.Type.GetType(((ElementType)_elements.GetList()[type]).GetSlimeScriptName()); SlimeBase temp_script = slime_obj.AddComponent(_MyScriptType) as SlimeBase; temp_script.Init(temp, ((((ElementType)_elements.GetList()[type]).name.Equals("Lightning")) ? 2 : 1), ((ElementType)_elements.GetList()[type]), _startingTier); slime_obj.SetActive(true); return(slime_obj); }
public SlimeWanderState(SlimeBase owner) : base(owner) { _startPosition = _owner.GetPosition(); }
public SlimeBaseState(SlimeBase owner) { _owner = owner; }
// Update is called once per frame void Update() { if (_StartingTime <= 0) { if (!_SpawnedEnding && _Properties.GetEndingParticle() != null) { GameObject temp = Instantiate(_Properties.GetEndingParticle(), gameObject.transform); Destroy(temp, _EndingTime); _SpawnedEnding = true; } if (_PlayedCastingAudio) { if (_Properties.IsCastingLoop()) { AudioManager.Instance.StopSE(_Properties.GetCastingAudio().name); _PlayedCastingAudio = false; } } if (!_PlayedEndingAudio) { if (_Properties.GetEndingAudio() != null) { _PlayedEndingAudio = true; AudioManager.Instance.PlaySE(_Properties.GetEndingAudio().name, _Properties.IsEndingLoop()); } } if (_EndingTime <= 0) { gameObject.SetActive(false); if (_PlayedEndingAudio) { if (_Properties.IsEndingLoop()) { AudioManager.Instance.StopSE(_Properties.GetEndingAudio().name); _PlayedEndingAudio = false; } } } else { _EndingTime -= Time.deltaTime; } } else { _StartingTime -= Time.deltaTime; } switch (_Properties.GetEffectType(_StartingTime <= 0)) { case EnumHolder.AreaEffectType.SPAWNING: { if (_Delay <= 0) { int temp_target = Random.Range(0, _Properties.GetTargetable().GetList().Count); GameObject temp_obj = ObjectManager.Instance.InstantiateWithObjectPooling( _Properties.GetTargetable().GetList()[temp_target], new Vector3( gameObject.transform.position.x + Random.Range(-_Properties.GetRadius(), _Properties.GetRadius()), gameObject.transform.position.y + _Properties.GetYOffset(), gameObject.transform.position.z + Random.Range(-_Properties.GetRadius(), _Properties.GetRadius()) )); if (temp_obj.tag.Equals("Slime")) { Stats temp = EnumHolder.Instance.GetStats(_Properties.GetTargetable().GetList()[temp_target].name); SlimeBase temp_component = temp_obj.GetComponent <SlimeBase>(); if (temp_component != null) { Destroy(temp_component); } int type = Random.Range(0, _Properties.GetElement().GetList().Count); System.Type _MyScriptType = System.Type.GetType(((ElementType)_Properties.GetElement().GetList()[type]).GetSlimeScriptName()); SlimeBase temp_script = temp_obj.AddComponent(_MyScriptType) as SlimeBase; temp_script.Init(temp, ((((ElementType)_Properties.GetElement().GetList()[type]).name.Equals("Lightning")) ? 2 : 1), ((ElementType)_Properties.GetElement().GetList()[type]), _Properties.GetTier()); } _Delay = _Properties.GetDelay(); } else { _Delay -= Time.deltaTime; } } break; case EnumHolder.AreaEffectType.SUCKING: { foreach (GameObject obj in _Properties.GetTargetable().GetList()) { if (ObjectManager.Instance.GetActiveObjects(obj) != null) { foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj)) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius()) { entity.transform.position = Vector3.Slerp(entity.transform.position, new Vector3(gameObject.transform.position.x, entity.transform.position.y, gameObject.transform.position.z), (1.0f - (Vector3.Distance(gameObject.transform.position, entity.transform.position) / _Properties.GetRadius())) * 0.5f); } } } } } break; case EnumHolder.AreaEffectType.PUSHING: { foreach (GameObject obj in _Properties.GetTargetable().GetList()) { if (ObjectManager.Instance.GetActiveObjects(obj) != null) { foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj)) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius()) { entity.transform.position += ( new Vector3(entity.transform.position.x, entity.transform.position.y, entity.transform.position.z) - new Vector3(gameObject.transform.position.x, entity.transform.position.y, gameObject.transform.position.z)).normalized * (1.0f - (Vector3.Distance(gameObject.transform.position, entity.transform.position) / _Properties.GetRadius())); if (_Delay <= 0) { IDamageable dmg = entity.GetComponent <IDamageable>(); if (dmg != null) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius()) { dmg.TakeDamage(_Properties.GetDamage()); } } _Delay = _Properties.GetDelay(); } else { _Delay -= Time.deltaTime; } } } } } } break; case EnumHolder.AreaEffectType.DAMAGE: { if (_Delay <= 0) { foreach (GameObject obj in _Properties.GetTargetable().GetList()) { if (ObjectManager.Instance.GetActiveObjects(obj) != null) { foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj)) { IDamageable dmg = entity.GetComponent <IDamageable>(); if (dmg != null) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius()) { dmg.TakeDamage(_Properties.GetDamage()); if (LayerMask.LayerToName(entity.layer) == "Slime") { entity.SetActive(false); } } } } } } _Delay = _Properties.GetDelay(); } else { _Delay -= Time.deltaTime; } } break; case EnumHolder.AreaEffectType.GROWING: { if (_Delay <= 0) { foreach (GameObject obj in _Properties.GetTargetable().GetList()) { if (ObjectManager.Instance.GetActiveObjects(obj) != null) { foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj)) { IGrowable grow = entity.GetComponent <IGrowable>(); if (grow != null) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _Properties.GetRadius()) { grow.Grow(_Properties.GetTier()); } } } } } _Delay = _Properties.GetDelay(); } else { _Delay -= Time.deltaTime; } } break; default: break; } }
public SlimeFleeState(SlimeBase owner) : base(owner) { _tempPlayer = GameObject.Find("Player"); }
protected virtual void Dead() { gameObject.SetActive(false); if (_PlayedCastingAudio) { if (_ProjectileProperties.IsCastingLoop()) { AudioManager.Instance.StopSE(_ProjectileProperties.GetCastingAudio().name); _PlayedCastingAudio = false; } } if (!_PlayedEndingAudio) { if (_ProjectileProperties.GetEndingAudio() != null) { _PlayedEndingAudio = true; AudioManager.Instance.PlaySE(_ProjectileProperties.GetEndingAudio().name, _ProjectileProperties.IsEndingLoop()); } } if (_ProjectileProperties.ShakeOnImpact()) { for (int i = 0; i < _multiplyer; ++i) { _ProjectileProperties.GetEvent().InvokeAllListeners(); } } if (_MovingParticleCopy != null) { Destroy(_MovingParticleCopy); _MovingParticleCopy = null; } if (_ProjectileProperties.GetImpactParticle() != null) { GameObject temp = Instantiate(_ProjectileProperties.GetImpactParticle(), gameObject.transform.position, gameObject.transform.rotation); temp.transform.localScale = gameObject.transform.localScale; Destroy(temp, _impact_particle_timer); } if (_damage > 0) { foreach (GameObject obj in _Targetable) { if (ObjectManager.Instance.GetActiveObjects(obj) != null) { foreach (GameObject entity in ObjectManager.Instance.GetActiveObjects(obj)) { if (Vector3.Distance(gameObject.transform.position, entity.transform.position) < _ProjectileProperties.GetImpactRadius() * _multiplyer) { IDamageable dmg = entity.GetComponent <IDamageable>(); if (dmg != null) { dmg.TakeDamage(_damage * _multiplyer); Debug.Log("[Damaging (" + _damage * _multiplyer + ")] " + obj.name); if (_StatusEffects.Count > 0) { if (Random.Range(0, 100) < _percentage * _multiplyer) { foreach (StatusEffect se in _StatusEffects) { Debug.Log("[Applying (" + se.name + ")] " + obj.name); se.GetEvent().InvokeSpecificListner(obj.GetInstanceID()); } } } } } } } } } //SPAWNING if (_ProjectileProperties.GetObjectsToSpawn() != null) { foreach (GameObject obj in _ProjectileProperties.GetObjectsToSpawn().GetList()) { for (int i = 0; i < _ProjectileProperties.GetIteration(); ++i) { GameObject temp_obj = ObjectManager.Instance.InstantiateWithObjectPooling(obj, gameObject.transform.position); if (temp_obj.GetComponent <AreaEffect>() != null) { temp_obj.GetComponent <AreaEffect>().Init(_ProjectileProperties.GetProperties()); } else if (temp_obj.tag.Equals("Slime")) { Stats temp = EnumHolder.Instance.GetStats(obj.name); SlimeBase temp_component = temp_obj.GetComponent <SlimeBase>(); if (temp_component != null) { Destroy(temp_component); } int type = Random.Range(0, _ProjectileProperties.GetProperties().GetElement().GetList().Count - 1); System.Type _MyScriptType = System.Type.GetType(((ElementType)_ProjectileProperties.GetProperties().GetElement().GetList()[type]).GetSlimeScriptName()); SlimeBase temp_script = temp_obj.AddComponent(_MyScriptType) as SlimeBase; temp_script.Init(temp, ((((ElementType)_ProjectileProperties.GetProperties().GetElement().GetList()[type]).name.Equals("Lightning")) ? 2 : 1), ((ElementType)_ProjectileProperties.GetProperties().GetElement().GetList()[type]), _ProjectileProperties.GetTier()); } if (_ProjectileProperties._HasRandomMotion) { Rigidbody temp_rb = temp_obj.GetComponent <Rigidbody>(); if (temp_rb != null) { float force = 3500; temp_rb.AddForce(new Vector3(Random.Range(-force, force), 0, Random.Range(-force, force)), ForceMode.Acceleration); } } } } } }