void Update() { timer += Time.deltaTime; if (timer >= timeToGenerate) { objState.SetState(objState.SetStateWElec()); timer -= timeToGenerate; } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <ObjectState>()) { ObjectState otherState = collision.gameObject.GetComponent <ObjectState>(); switch (_elem) { case ShootScript.Element.FIRE: if (_fireSplash) { Instantiate(_fireSplash, transform.position, transform.rotation); } otherState.SetState(otherState.SetStateWFire()); otherState.SetPosition(transform.position); break; case ShootScript.Element.WATER: if (_waterSplash) { Instantiate(_waterSplash, transform.position, transform.rotation); } collision.GetComponentInParent <ObjectGeneration>().ExtinguishFire(); Debug.Log("Water"); break; case ShootScript.Element.ELECTRICITY: otherState.SetState(otherState.SetStateWElec()); //Debug.Log(otherState.GetState()); Debug.Log("Electricity"); break; } } if (collision.gameObject.tag != "Player" && collision.gameObject.tag != "Checkpoint" && collision.gameObject.tag != "DontTrigger" && collision.gameObject.tag != "Projectile") { DestroyObject(gameObject); } }