Ejemplo n.º 1
0
 // 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);
         }
     }
 }
Ejemplo n.º 2
0
    // 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;
        }
    }
Ejemplo n.º 3
0
    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--;
    }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (state == Modes.Count)
     {
         if (counter.Count(RefreshRate))
         {
             counter.Reset();
             RequestBanner();
         }
     }
 }
Ejemplo n.º 5
0
    // 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;
        }
    }