Exemplo n.º 1
0
        void Update()
        {
            if (!Spawned)
            {
                Progress.text = ProgressText;
                if (ReadyToPlay)
                {
                    Progress.transform.parent.gameObject.SetActive(false);
                    Spawned = true;
                    if (CollectorInstance)
                    {
                        Destroy(CollectorInstance.gameObject);
                    }
                    if (DispenserInstance)
                    {
                        Destroy(DispenserInstance.gameObject);
                    }
                    CollectorInstance            = Instantiate(Menu.Instance.Collector).GetComponent <ScoreCollector>();
                    DispenserInstance            = Instantiate(Menu.Instance.Dispenser).GetComponent <CubeDispenser>();
                    DispenserInstance.Boxes      = Boxes;
                    DispenserInstance.Song       = Song;
                    DispenserInstance.OnSongEnd += CollectorInstance.GameOver;
                    if (!DebugMode)
#pragma warning disable CS0162 // Unreachable code detected
                    {
                        Destroy(gameObject);
                    }
#pragma warning restore CS0162 // Unreachable code detected
                }
            }
            if (Spawned && !DispenserInstance)
            {
                Destroy(gameObject);
            }
        }
Exemplo n.º 2
0
 void Start()
 {
     ScoreDisplay.transform.parent.SetParent(null); // Connected for single prefab, needs to be disconnected for Canvas display
     ScoreDisplay.text = "0";
     if (Instance)
     {
         Destroy(Instance);
     }
     Instance     = this;
     ElemsPerLane = LaneElements.Length / LaneCount;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="title"> Level title.</param>
        /// <param name="game"> Game.</param>
        public Level(string title, SuperPlatformerGame game)
        {
            CurrentTime = 0;
            Gravity     = 550;

            // Create the lists.
            _entities        = new List <Entity>();
            _pendingEntities = new List <Entity>();
            _decorations     = new List <MonoSprite>();
            _backgroundTiles = new List <Tile>();

            // Time moves on.
            _time = new TimedEvent(OnTimeTick, 1000);
            _time.Enable();

            // Time to respawn
            _respawnTimer = new TimedEvent(OnRespawnTimerElapsed, 3000);

            // Wait X seconds before switching to end level scene on level finished.
            _endTimer = new TimedEvent(() =>
            {
                game.SceneActivator.ActivateScene(new EndLevelScene(game));
            }, 4000);

            _scale = SuperPlatformerGame.SCALE;

            _viewport = game.GraphicsDevice.Viewport;

            _title = title;

            _collisions = new CollisionTester();

            _camera = new Camera2D(_viewport);

            Player = new Player(game.Content.Load <Texture2D>("Images/Player/Protagonist"), Vector2.Zero, 16, 22, game.KeyboardDevice, this, game.Content);

            // Listen to some player events
            Player.OnSizeChanged += OnPlayerSizeChange;
            Player.OnDied        += OnPlayerDeath;

            Score = new ScoreCollector();

            TypePlayer = PlayerType.PROTAGONIST;

            Display = new HUD(this, _camera, game.Content);

            _collidables = new List <Entity>();

            _camera.Follow(Player);
        }
Exemplo n.º 4
0
    public void WinScreen()
    {
        ScoreCollector temp = GameObject.Find("Player").GetComponentInChildren <ScoreCollector>();

        PlayerScoreProgress tmp = highScores.GetComponentInChildren <PlayerScoreProgress>();

        tmp.AddScore(temp.GetScoreCount());

        //PlayerPrefs.SetInt("HighScores", temp.GetScoreCount());
        // Set game over message
        gameOverMessage.SetText("You finished with " + temp.GetScoreCount() + " points!");

        gameState = GameState.WIN;
        EndGame();
    }
Exemplo n.º 5
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="position"> Location in game.</param>
        /// <param name="content"> The content manager to get the texture from.</param>
        /// <param name="level"> The level the coin is in.</param>
        public Coin(Vector2 position, ContentManager content, Level level) :
            base(position, 12, 16, level)
        {
            _score = level.Score;

            Sprite = new MonoSprite(content.Load <Texture2D>("Images/Item/Coin"), new Rectangle(0, 0, 12, 16), position, 12, 16);

            // Make it float.
            Gravity = 0;

            // Coin is not solid.
            Solid = false;

            // Coin does't check for collisions on its own.
            CheckCollisions = false;

            // Set max spawn distance to 20.
            _maxSpawnDistance = 20;

            // Set max spawn speed to 100.
            _spawnSpeed = 100;

            _disappearSound = content.Load <SoundEffect>("Audio/smw_coin");

            // Add rotating animation.
            Animations.Add(new Animation(
                               id: (int)CoinAnimation.ROTATING,
                               baseFrame: Vector2.Zero,
                               frameSize: new Vector2(12, 16),
                               rows: 1,
                               columns: 4,
                               msPerFrame: 125
                               ));

            // Add spawning animation.
            Animations.Add(new Animation(
                               id: (int)CoinAnimation.SPAWNING,
                               baseFrame: Vector2.Zero,
                               frameSize: new Vector2(12, 16),
                               rows: 1,
                               columns: 1,
                               msPerFrame: 0
                               ));

            // On default start the rotating animation.
            Animations.Play((int)CoinAnimation.ROTATING);
        }
 void Awake()
 {
     Instance      = this;
     statsRecorder = Academy.Instance.StatsRecorder;
 }
Exemplo n.º 7
0
 void Awake()
 {
     Instance = this;
 }