// Use this for initialization void Start() { _groundChecker = GetComponent <GroundChecker>(); _movementChecker = GetComponent <MovementChecker>(); _movementChecker.X_PositionChanged += XPositionChanged; _movementChecker.MovementStopped += DetectedStopping; _delayManager = GetComponent <DelayManager>(); _explosiveObject = GetComponent <ExplosiveObject>(); }
private void StopCollider() { if (_groundMover != null) { _groundMover.X_PositionChanged -= GroundMoverOnPositionChanged; } _groundMover = null; _subscribedCollider = null; }
private void DetectedCollider(GameObject gameObject) { var testExplosive = gameObject.GetComponentInParent<ExplosiveObject>(); //print(test); if(testExplosive != null) { var getGroundMover = gameObject.GetComponentInParent<MovementChecker>(); _subscribedCollider = testExplosive; _groundMover = getGroundMover; _groundMover.X_PositionChanged += GroundMoverOnPositionChanged; } }
private void DetectedCollider(GameObject gameObject) { var testExplosive = gameObject.GetComponentInParent <ExplosiveObject>(); //print(test); if (testExplosive != null) { var getGroundMover = gameObject.GetComponentInParent <MovementChecker>(); _subscribedCollider = testExplosive; _groundMover = getGroundMover; _groundMover.X_PositionChanged += GroundMoverOnPositionChanged; } }
// Update is called once per frame void Update() { transform.Translate(new Vector3(1f, 0f, 0f) * speed * Time.deltaTime); elapsedLifetime += Time.deltaTime; if (elapsedLifetime > maxLifetime) { // Deactivate projectile and return it to the pool if (projectileType == (int)Weapon.ProjectileTypes.Rocket) { ExplosiveObject boom = GetComponent <ExplosiveObject>(); boom.Explode(); FindObjectOfType <RocketPool>().ReturnToPool(this); } else { FindObjectOfType <ProjectilePool>().ReturnToPool(this); } } }
protected virtual void FindNearestObjects()//поиск ближайших объектов и подрыв их { _objectDown.Explosives.Remove(this); FoundObjects = _objectDown.GetNearestObject(transform.position, Raduis, RaduisExplosion); for (int i = 0; i < FoundObjects.Count; i++) { if (FoundBlock = FoundObjects[i] as BaseBlock) { FoundBlock.Destroy(Power); } else if (FoundExplosiveObject = FoundObjects[i] as ExplosiveObject) { FoundExplosiveObject.Detonation(); } } if (Vector3.Distance(transform.position, _player.transform.position) < Raduis * 3) { _player.AddExplosionForce(10, transform.position, Raduis * 3, 0, ForceMode.Impulse); } Destroy(gameObject); }
private void OnTriggerEnter(Collider other) { Health destructibleTarget = other.gameObject.GetComponent <Health>(); if (destructibleTarget != null) { destructibleTarget.ModifyHealth(-damage); } // Deactivate projectile and return it to the pool if (projectileType == (int)Weapon.ProjectileTypes.Rocket) { ExplosiveObject boom = GetComponent <ExplosiveObject>(); Debug.Log("Calling explode"); boom.Explode(); Debug.Log("Calling returnToPool"); FindObjectOfType <RocketPool>().ReturnToPool(this); } else { Debug.Log("Returning to bullet pool"); FindObjectOfType <ProjectilePool>().ReturnToPool(this); } }
protected void Start() { base.Start(); explosive = GetComponent <ExplosiveObject>(); }
private async void Fire() { if (!_canFire) { return; } if (Ammo > 0) { _canFire = false; _myAnimator.SetBool("IsFire", true); await Task.Delay(333);// простой, что бы подождать момент выстрела if (!gameObject.activeInHierarchy) { return; } _inventory.GetItem(15, 1);//"Покупка патрона" _myAud.clip = FireClip; _myAud.Play(); GameObject effect = Instantiate(_FireEffect, _FireEffect.transform.position, _FireEffect.transform.rotation);// создание эффекта выстрела effect.SetActive(true); effect.transform.SetParent(transform); Destroy(effect, 0.12f); Ray ray = _cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { if (_lastExplosion = hit.transform.GetComponent <ExplosiveObject>()) { Delay((int)(Vector3.Distance(hit.point, transform.position) * 2.5f), true); } else if (hit.transform.GetComponent <RetentionObject>()) { _lastRb = hit.transform.GetComponent <Rigidbody>(); Delay((int)(Vector3.Distance(hit.point, transform.position) * 2.5f), false); } await Task.Delay((int)(Vector3.Distance(hit.point, transform.position) * 2.5f)); if (!gameObject.activeInHierarchy) { return; } GameObject decalEffect = null; if (_lastBlock = hit.transform.GetComponent <BaseBlock>()) { if (_lastBlock.Type == 0) { decalEffect = Instantiate(_ConcreteDecalEffect, hit.point, hit.transform.rotation); // создание эффекта попадания } else if (_lastBlock.Type == 1) // wood { decalEffect = Instantiate(_WoodDecalEffect, hit.point, hit.transform.rotation); // создание эффекта попадания } else if (_lastBlock.Type == 2) // glass { decalEffect = Instantiate(_SoftBodydecalEffect, hit.point, hit.transform.rotation); // создание эффекта попадания } else { decalEffect = Instantiate(_DirtDecalEffect, hit.point, hit.transform.rotation);// создание эффекта попадания } } if (hit.transform.GetComponent <FirstPersonController>()) { decalEffect = Instantiate(_SoftBodydecalEffect, hit.point, hit.transform.rotation);// создание эффекта попадания } else if (decalEffect == null) { decalEffect = Instantiate(_DirtDecalEffect, hit.point, hit.transform.rotation);// создание эффекта попадания } decalEffect.SetActive(true); decalEffect.transform.SetParent(hit.transform); decalEffect.transform.forward = hit.normal; decalEffect.GetComponent <ParticleSystem>().Play(); Destroy(decalEffect, decalEffect.GetComponent <ParticleSystem>().main.duration); } _myAnimator.SetBool("IsFire", false); Ammo--; await Task.Delay(200); _canFire = true; } else { _myAud.clip = EmptyClick; _myAud.Play(); _myAnimator.SetBool("IsFire", false); } }
// Use this for initialization void Start() { _groundChecker = GetComponent<GroundChecker>(); _movementChecker = GetComponent<MovementChecker>(); _movementChecker.X_PositionChanged += XPositionChanged; _movementChecker.MovementStopped += DetectedStopping; _delayManager = GetComponent<DelayManager>(); _explosiveObject = GetComponent<ExplosiveObject>(); }
public ObjectEvent(ExplosiveObject obj) { mObject = obj; }
void Start() { ExplosiveObjectComponent = GetComponent <ExplosiveObject>(); }