private void OnDisable() { if (garageContainer != null) { garageContainer.SetActive(value: false); } if (garageShootRoutine != null) { StopCoroutine(garageShootRoutine); TankContainer tankContainer = tanks[tankIndex]; if (tankContainer.FlameRoutine != null) { tankContainer.StopCoroutine(tankContainer.FlameRoutine); } tanks[tankIndex].FlameRoutine = null; if (tankContainer.BulletRoutine != null) { tankContainer.StopCoroutine(tankContainer.BulletRoutine); } tanks[tankIndex].BulletRoutine = null; if (tankContainer.LightningRoutine != null) { tankContainer.StopCoroutine(tankContainer.LightningRoutine); } tanks[tankIndex].LightningRoutine = null; for (int i = 0; i < tanks.Length; i++) { tanks[i].Shoot(val: false); tanks[i].StopShootSound(); } } }
public IEnumerator BulletShoot(TankContainer tank) { tank.Shoot(); yield return(new WaitForSeconds(1.25f)); tank.Shoot(val: false); }
public IEnumerator FlamerShoot(TankContainer tank) { tank.ReloadTime = 0f; tank.Shoot(); yield return(new WaitForSeconds(0.75f)); tank.Shoot(val: false); }
public IEnumerator LightningShoot(TankContainer tank) { tank.ReloadTime = 0f; tank.Shoot(); yield return(new WaitForSeconds(2f)); tank.Shoot(val: false); }
public IEnumerator MissileShoot(TankContainer tank) { Tank tank2 = Variables.instance.GetTank(tankIndex); tank.Shoot(); yield return(new WaitForSeconds(tank2.bullet.maxTime)); tank.Shoot(val: false); }
private void UpdateCollisions() { List <TankContainer> list = new List <TankContainer>(); CollisionMatrix collisionMatrix = default(CollisionMatrix); Vector3 position = base.transform.position; foreach (KeyValuePair <TankContainer, float> activeCollision in activeCollisions) { TankContainer key = activeCollision.Key; if (key == null || key.transform == null || key.CurrentHealth <= 0f) { list.Add(key); } else { Vector3 position2 = key.transform.position; if ((position - position2).sqrMagnitude > activeCollision.Value + collisionRadius) { list.Add(key); } else { bool flag = position.x < position2.x; if (key.Enemy != null && TankGame.instance.Boss != null && key.Enemy == TankGame.instance.Boss) { collisionMatrix.immovableLeft |= !flag; collisionMatrix.immovableRight |= flag; } else { collisionMatrix.movableLeft |= !flag; collisionMatrix.movableRight |= flag; } } } } if (position.x - collisionRadius <= moveBoundaries.min) { collisionMatrix.immovableLeft = true; } else if (!float.IsInfinity(moveBoundaries.max) && position.x + collisionRadius >= moveBoundaries.max) { collisionMatrix.immovableRight = true; } this.collisionMatrix = collisionMatrix; foreach (TankContainer item in list) { activeCollisions.Remove(item); } }
private void OnCollisionEnter2D(Collision2D collision) { int num = 1 << collision.gameObject.layer; int num2 = enemyLayerMask | LayerMask.GetMask("EnemyTank", "EnemyTankMain"); if ((num & num2) == num) { TankContainer tankContainer = collision.gameObject.GetComponent <TankContainer>(); if (!tankContainer) { tankContainer = collision.gameObject.GetComponentInParents <TankContainer>(4, num2); } if ((bool)tankContainer && !activeCollisions.ContainsKey(tankContainer)) { activeCollisions.Add(tankContainer, ((Vector2)base.transform.position - (Vector2)tankContainer.transform.position).sqrMagnitude); } } }
private void OnCollisionEnter2D(Collision2D collision) { if (((1 << collision.collider.gameObject.layer) & LayerMask.GetMask("PlayerTank", "PlayerTankRight")) != 0) { target = collision.transform.GetComponentInParent <TankContainer>(); TankGame.GivePlayerHealth(target, percentage); wrench.transform.SetParent(TankGame.instance.transform); wrench.transform.rotation = Quaternion.identity; Vector3 localScale = wrench.transform.localScale; localScale.Scale(new Vector3(2f, 2f, 1f)); LeanTween.scale(wrench, localScale, 1f).setEaseInOutExpo(); TankGame.instance.Delay(0.5f, delegate { LeanTween.rotate(wrench, new Vector3(0f, 0f, -45f), 0.5f).setEaseInOutExpo(); }); TankGame.instance.Delay(1f, delegate { LeanTween.rotate(wrench, new Vector3(0f, 0f, 0f), 0.5f).setEaseInOutExpo(); }); TankGame.instance.Delay(1.5f, delegate { LeanTween.rotate(wrench, new Vector3(0f, 0f, -45f), 0.5f).setEaseInOutExpo(); }); TankGame.instance.Delay(2f, delegate { LeanTween.rotate(wrench, new Vector3(0f, 0f, 0f), 0.5f).setEaseInOutExpo(); }); TankGame.instance.Delay(2f, delegate { LeanTween.alpha(wrench, 0f, 0.5f); UnityEngine.Object.Destroy(wrench, 3f); UnityEngine.Object.Destroy(base.gameObject, 3.5f); }); GetComponent <Collider2D>().enabled = false; if (GetComponent <SpriteRenderer>() != null) { GetComponent <SpriteRenderer>().enabled = false; } StartCoroutine(Move()); } }
private IEnumerator TankFlash(TankContainer tank) { sparkleParticles.Play(); SpriteRenderer r = tank.GetComponent <SpriteRenderer>(); MeshRenderer cr = null; if (tank.GetComponentInChildren <Chain>() != null) { cr = tank.GetComponentInChildren <Chain>().GetComponent <MeshRenderer>(); } int propertyId = Shader.PropertyToID("_Amount"); float num = 1.5f; float time = 0f; float stageTime = num / 2f; while (time < stageTime) { r.sharedMaterial.SetFloat(propertyId, time / stageTime); if (cr != null) { cr.material.SetFloat(propertyId, time / stageTime); } time += Time.deltaTime; yield return(new WaitForEndOfFrame()); } while (time > 0f) { r.sharedMaterial.SetFloat(propertyId, time / stageTime); if (cr != null) { cr.material.SetFloat(propertyId, time / stageTime); } time -= Time.deltaTime; yield return(new WaitForEndOfFrame()); } FinishTankFlash(stopCoroutine: false); }
private void OnEnable() { thisVehicle = GetComponentInParent <TankContainer>(); }