Beispiel #1
0
        private void OnTriggerEnter(Collider2D other)
        {
            if (other.Owner is Explosion)
            {
                this.Active = false;

                int xPos  = (int)Transform.Position.X;
                int yPos  = (int)Transform.Position.Y;
                int index = Map.GetIndex(xPos, yPos);

                if (LevelManager.CurrentMap.MapNodes[index] == null)
                {
                    LevelManager.CurrentMap.MapNodes[index] = new Node(1, new Vector2(xPos, yPos));
                }

                LevelManager.CurrentMap.GenerateNeighborNode();

                //this is the random to generate our powerups..
                int randomPw = RandomManager.Instance.Random.Next(0, Enum.GetNames(typeof(PowerUpType)).Length);

                //once the random is thrown we can generate it
                //at the moment we only have 2 active powerups so
                //we make some test using the first one on the enum
                IPowerup p = PowerUpFactory.Get(PowerUpType.PW_MYSTERY);
                p.SetPosition(this.Transform.Position);

                GameObject.Spawn(p as GameObject);
            }
        }