Beispiel #1
0
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("CenterCameraEvent"))
     {
         CenterCamera();
     }
 }
Beispiel #2
0
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("PlayerDeathEvent"))
     {
         PlayerDied(((PlayerDeathEvent)e).GetPlayer());
     }
 }
Beispiel #3
0
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("UpdateHud"))
     {
         updateHud();
     }
 }
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("BackgroundScrollEvent"))
     {
         amountToMoveX += ((BackgroundScrollEvent)e).MoveX;
         amountToMoveY += ((BackgroundScrollEvent)e).MoveY;
     }
 }
Beispiel #5
0
    public void receiveEvent(GameEvents.GameEvent e)
    {
        if (e.GetType().Name.Equals("DamagePlayer"))
        {
            int  damage      = ((DamagePlayer)e).getDamageValue();
            bool doKnockback = !(tookDamage || invunerable) && ((DamagePlayer)e).bounceAfterTakingDamage();
            doDamage(damage);

            if (doKnockback)
            {
                GameObject damager = ((DamagePlayer)e).getDamager();

                if (damager.tag.Equals("Enemy"))
                {
                    Vector2 direction = new Vector2(transform.position.x - damager.transform.position.x,
                                                    transform.position.y - damager.transform.position.y);
                    rigidbody2D.AddForce(direction * bounceForce);
                }
                else
                {
                    Vector2 direction = rigidbody2D.velocity.normalized * -1;;
                    rigidbody2D.AddForce(direction * bounceForce);
                }
            }
        }
        else if (e.GetType().Name.Equals("EnterRoom"))
        {
            bool isFirstTime = ((EnterRoom)e).isFirstTime();
            if (isFirstTime)
            {
                gainShieldCharge();
            }
        }
        else if (e.GetType().Name.Equals("CollectPower"))
        {
            shipSounds.playPowerup();
            int type = ((CollectPower)e).getPowerupType();
            if (type == 1)
            {
                gainShield();
            }
            else if (type == 2)
            {
                gainDamage();
            }
            else if (type == 3)
            {
                gainRateofFire();
            }
            else if (type == 4)
            {
                has5Shot = true;
            }
        }
    }
Beispiel #6
0
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("Restart"))
     {
         Application.LoadLevel(2);
     }
     if (e.GetType().Name.Equals("Win"))
     {
         Invoke("TriggerWin", 3f);
     }
 }
Beispiel #7
0
 public void receiveEvent(GameEvents.GameEvent e)
 {
     if (e.GetType().Name.Equals("EnterRoom"))
     {
         target = ((EnterRoom)e).getNewRoom();
     }
     if (e.GetType().Name.Equals("CameraShake"))
     {
         jiggleAmt = ((CameraShake)e).getAmount();
         StartCoroutine(jiggleCam2(((CameraShake)e).getDuration()));
     }
 }
        public static void post(GameEvent e)
        {
            //Filter out the dead weak references
             var alive_list = (from el in listeners
                           where el.IsAlive
                           select el);

             //store the alive references
             listeners = alive_list.ToList();

             //iterate through alive references
             foreach(WeakReference wref in alive_list)
             {
            //call eventReceived on the listener
            (wref.Target as GameEventListener).eventReceived(e);
             }
        }