Beispiel #1
0
        public override void Act(KeyboardState kb, MouseState ms)
        {
            if (kb[Key.Escape])
            {
                CurrentWindow.SetWorld(new GameWorldStart());
                return;
            }

            long now  = GetCurrentTimeInMilliseconds();
            long diff = now - _timestampLast;

            if (!_test)
            {
                if (diff > 500)
                {
                    EnemySimple es = new EnemySimple();
                    es.SetModel("Spaceship6");
                    es.Name = "Enemy";
                    es.SetRotation(90, 0, 0);
                    es.SetPosition(HelperRandom.GetRandomNumber(-17f, 17f), 10.5f, 0);
                    es.IsCollisionObject = true;
                    AddGameObject(es);

                    _timestampLast = now;
                }
            }

            if (kb[Key.KeypadPlus])
            {
                _bloomradius        = HelperGeneral.Clamp(_bloomradius + 0.01f * KWEngine.DeltaTimeFactor, 0, 1);
                KWEngine.GlowRadius = _bloomradius;
                Console.WriteLine("Bloom radius: " + _bloomradius);
            }
            if (kb[Key.KeypadMinus])
            {
                _bloomradius        = HelperGeneral.Clamp(_bloomradius - 0.01f * KWEngine.DeltaTimeFactor, 0, 1);
                KWEngine.GlowRadius = _bloomradius;
                Console.WriteLine("Bloom radius: " + _bloomradius);
            }
        }
Beispiel #2
0
    void OnTriggerEnter()
    {
        Debug.Log("Se elimino al enemigo");

        // Una forma de hacerlo...
        // Destroy (transform.parent.gameObject);

        // Otra forma de hacerlo usando comunicacion entre scripts
        EnemyModel  em = (EnemyModel)(transform.GetComponentInParent <EnemyModel> ());
        EnemySimple es = (EnemySimple)(transform.GetComponentInParent <EnemySimple> ());

        GameManager.killedEnemys += 1;

        if (em != null)
        {
            em.Die();
        }
        else if (es != null)
        {
            es.Die();
        }
    }
Beispiel #3
0
 void Start()
 {
     if (enemies.Count == 0)
     {
         RaycastHit2D[] rch2ds = new RaycastHit2D[100];
         GetComponent <BoxCollider2D>().Cast(Vector2.zero, rch2ds, 0, true);
         foreach (RaycastHit2D rch2d in rch2ds)
         {
             if (rch2d && !rch2d.collider.isTrigger)
             {
                 EnemySimple es = rch2d.collider.gameObject.GetComponent <EnemySimple>();
                 if (es != null)
                 {
                     enemies.Add(es);
                 }
             }
         }
     }
     foreach (EnemySimple es in enemies)
     {
         es.activeMove = false;
     }
 }
Beispiel #4
0
 void Start()
 {
     MovementScript = this.GetComponent <EnemySimple>();
     SlimeAnim      = this.GetComponent <Animator>();
 }