Esempio n. 1
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Player" && !_isDead)
     {
         _isDead = true;
         EventAggregator.SendMessage(new HitPlayerMessage());
         EventAggregator.SendMessage(new EarnMoneyMessage {
             Money = Money
         });
         EventAggregator.SendMessage(new PlaySoundMessage {
             Clip = PlayerHitSound
         });
     }
 }
Esempio n. 2
0
        private void UpdateRocket()
        {
            if (!CanFireRocket() || !_isPlayerInput)
            {
                return;
            }

            EventAggregator.SendMessage(new PlaySoundMessage {
                Clip = RocketSound
            });
            Player.IsRocketFiring = true;
            _rocketStart          = Time.fixedTime;
            Player.RemainingRockets--;
        }
Esempio n. 3
0
 private void OnTriggerEnter(Collider col)
 {
     if (!_isDeleted)
     {
         EventAggregator.SendMessage(new EarnMoneyMessage {
             Money = Money
         });
         EventAggregator.SendMessage(new PlaySoundMessage {
             Clip = Sound
         });
         Destroy(gameObject);
         _isDeleted = true;
     }
 }
Esempio n. 4
0
        public void Break(Vector3 position, float distance)
        {
            IsBroken = true;

            var direction = position - transform.position;

            rigidbody2D.AddForceAtPosition(direction.normalized * Force * -1, position);

            SpawnParticles();
            ChangeSkin();

            EventAggregator.SendMessage(new ObjectBrokenMessage {
                Points = Points
            });
        }
Esempio n. 5
0
        public void Handle(HitPlayerMessage message)
        {
            if (Health > 0)
            {
                Health--;
            }

            if (Health <= 0)
            {
                EventAggregator.SendMessage(new PlayerDiedMessage());
                var feet = GameObject.FindGameObjectWithTag("PlayerFeet");
                if (feet != null)
                {
                    Destroy(feet);
                }
            }
        }
Esempio n. 6
0
        private void OnTriggerEnter(Collider col)
        {
            // don't interact with a dead player
            if (col.tag != "PlayerFeet")
            {
                return;
            }

            var player = col.transform.parent;

            // platforms only work if you "fall" into them
            if (player.collider.rigidbody.velocity.y < 0)
            {
                // play jump sound
                EventAggregator.SendMessage(new PlaySoundMessage {
                    Clip = JumpSound
                });

                // push player up
                var boostLevel = PlayerContext.Get(UpgradeType.Jump);
                player.collider.rigidbody.velocity = new Vector3(player.collider.rigidbody.velocity.x, Boost + boostLevel, 0);

                // send message to give player money
                EventAggregator.SendMessage(new EarnMoneyMessage {
                    Money = Money
                });

                // spawn particle effects
                Enumerable.Range(0, 10).Each(x =>
                {
                    var c = (GameObject)Instantiate(Coin);
                    c.transform.position = transform.position - new Vector3(UnityEngine.Random.Range(-1, 1), 0, 0);
                    c.rigidbody.AddForce(UnityEngine.Random.Range(-150, 150), UnityEngine.Random.Range(200, 350), 0);
                });

                // destroy the platform
                Destroy(gameObject);
            }
        }
Esempio n. 7
0
        void Bomb()
        {
            IsDead = true;

            // Spawn Shrapnel
            Enumerable.Range(0, ShrapnelCount).Each(x =>
            {
                var s = (GameObject)Instantiate(Resources.Load("Objects/Shrapnel"));
                s.transform.position = transform.position;
            });

            // Destroy anything within kill radius
            FindObjectsOfType <BreakableObject>().Each(x =>
            {
                var distance = Vector3.Distance(x.transform.position, transform.position);
                if (distance <= KillRadius)
                {
                    x.Break(transform.position, distance);
                }
            });

            EventAggregator.SendMessage(new TurnOffSpawnersMessage());
        }
Esempio n. 8
0
 public void LaunchParachute()
 {
     EventAggregator.SendMessage(new LaunchParachuteMessage());
 }
Esempio n. 9
0
 public void LaunchRocket()
 {
     EventAggregator.SendMessage(new LaunchRocketMessage());
 }