// Update is called once per frame void Update() { if (state == Modes.Fire) { if (counter.Count(FireTime)) { counter.Reset(Random.Range(0f, FireTime * TimeVariation)); FireballPrefab.PrefabInstantiate(FireDamage, transform.position, (planet.transform.position - transform.position).normalized * FireImpulse); } } }
// Update is called once per frame void Update() { switch (state) { case Modes.Charging: if (counter.Count(ChargeTime)) { state = Modes.Flying; } break; case Modes.Flying: float dist = (transform.position - Target.position).magnitude; float lerpSpeed = FlySpeed / dist; transform.position = Vector3.Lerp(transform.position, Target.position, lerpSpeed * Time.deltaTime); if (transform.position == Target.position) { counter.Reset(); state = Modes.Exploding; Target.SendMessage("OnBonus", Type, SendMessageOptions.DontRequireReceiver); } break; case Modes.Exploding: if (counter.Count(ChargeTime)) { GameObject.Destroy(gameObject); } break; } }
void StartDestruction() { if (state == Modes.Exploding) { return; } counter.Reset(); state = Modes.Exploding; explosionObject = ((GameObject)GameObject.Instantiate(ExplosionsFx.gameObject)).GetComponent <FxRemover>(); animator.SetTrigger("Explode"); explosionObject.transform.parent = transform; explosionObject.transform.localPosition = Vector2.zero; explosionObject.enabled = false; Planet.EnemyShips--; }
// Update is called once per frame void Update() { if (state == Modes.Count) { if (counter.Count(RefreshRate)) { counter.Reset(); RequestBanner(); } } }
// Update is called once per frame void FixedUpdate() { Rigidbody2D r = GetComponent <Rigidbody2D>(); Vector2 pos = transform.TransformPoint(EnginePos); Vector2 force = transform.TransformDirection(0, Power * r.mass, 0); switch (state) { case Modes.Delay: //r.AddForceAtPosition(force,pos); r.AddTorque(GetTorque() * r.mass * DelayTorqueMult); if (Counter.Count(DelayTime)) { state = Modes.Engine; missile.TrailEffect.gameObject.SetActive(true); r.angularVelocity = 0; Counter.Reset(); } break; case Modes.Engine: r.AddForceAtPosition(force, pos); r.AddTorque(GetTorque() * r.mass * EnginesTorqueMult); if (Counter.Count(EnginesTime)) { state = Modes.Fly; Counter.Reset(); missile.DetachTrail(); } break; case Modes.Fly: break; } }