Ejemplo n.º 1
0
        protected override void KeyboardInput(InputEventArgs <TKey> args)
        {
            var moved = false;

            if (KeyboardAdapter.IsUp(args.Input))
            {
                moved = Level.TryMoveUp();
            }
            else if (KeyboardAdapter.IsLeft(args.Input))
            {
                moved = Level.TryMoveLeft();
            }
            else if (KeyboardAdapter.IsDown(args.Input))
            {
                moved = Level.TryMoveDown();
            }
            else if (KeyboardAdapter.IsRight(args.Input))
            {
                moved = Level.TryMoveRight();
            }

            if (moved && Level.IsCompleted)
            {
                OnLevelCompleted?.Invoke(this);
            }
        }
Ejemplo n.º 2
0
        private void LevelController_OnLevelCompleted(object sender, LevelExitData e)
        {
            int levelPass = sectionService.Level;

            sectionService.Level++;
            int bonus = 0;

            if (e.currentLevelState.deadEnemies == e.currentLevelState.totalEnemies)
            {
                playerController.Lives++;
                bonus = pointsBonus * sectionService.Level;
                sectionService.Points += bonus;
            }


            OnLevelCompleted?.Invoke(this, new LevelResult(
                                         level: levelPass,
                                         score: sectionService.Points,
                                         bonus: bonus,
                                         exit: e.exit,
                                         totalEnemies: e.currentLevelState.totalEnemies,
                                         enemiesDead: e.currentLevelState.deadEnemies,
                                         currentlevel: sectionService.Level,
                                         nextLevel: levelService.GetLevelRecipie(sectionService.Level))
                                     );
        }
Ejemplo n.º 3
0
    private void LevelCompleted(Robot robot)
    {
        Debug.Log("Robot " + robot.ToString() + " completed level " + ToString());

        playerManager.CleanUp();

        levelActive = false;
        OnLevelCompleted?.Invoke(this);
    }
 private void AllEnemiesKilled(OnLevelCompleted eventData)
 {
     if (!gameEnded)
     {
         Vector3 temp = PlayerController.Instance.transform.position;
         temp.y += 5;
         Instantiate(portal, temp, Quaternion.identity);
     }
 }
 public void LevelComplete()
 {
     IntroLevelCanvasController.Instance.Hide();
     LevelCompleteCanvasController.Instance.Show();
     LevelFailController.Instance.Hide();
     InLevelCanvasController.Instance.Hide();
     OnLevelCompleted?.Invoke();
     _currentLevel++;
 }
Ejemplo n.º 6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Robot robot = collision.gameObject.GetComponent <Robot>();

        if (robot == null)
        {
            return;
        }

        OnLevelCompleted?.Invoke(robot);
    }
Ejemplo n.º 7
0
        private IEnumerator LevelCompleteRoutine(bool success)
        {
            yield return(SceneController.Instance.LoadSceneAdditiveRoutine("Results"));

            OnLevelCompleted?.Invoke();

            if (success)
            {
                EventManager.TriggerEvent("Level Success");
                UpdateLevelData();
                SaveGameManager.Instance.SaveGameDataWithJSON();
            }
            else
            {
                EventManager.TriggerEvent("Level Failed");
            }
        }
Ejemplo n.º 8
0
    public void UpdateObjectives()
    {
        int completedObjectives = 0;

        foreach (Objective objective in objectiveList)
        {
            if (objective.completed)
            {
                completedObjectives++;
            }
        }

        if (completedObjectives >= objectiveList.Count)
        {
            if (OnLevelCompleted != null)
            {
                OnLevelCompleted.Invoke();
            }
        }
    }
Ejemplo n.º 9
0
 // Invokes the OnLevelCompleted event action
 public void InvokeOnLevelCompleted()
 {
     OnLevelCompleted?.Invoke(this);
     Debug.Log("We completed the level");
 }
Ejemplo n.º 10
0
 public void LevelComplete()
 {
     OnLevelCompleted?.Invoke(); won = true;
 }
Ejemplo n.º 11
0
        public override void Intersection(Collision c, GraphicObject g)
        {
            base.Intersection(c, g);
            switch (g.OT)
            {
            case ObjectType.OT_Exit:
            {
                if (EnterPressed)
                {
                    EnterPressed = false;
                    OnLevelCompleted?.Invoke();
                    //System.Windows.Forms.MessageBox.Show("Very Good !");
                }
                break;
            }

            case ObjectType.OT_Flower:
            {
                ((Flower)g).Visible = false;
                if (Type != MarioType.MT_Fire)
                {
                    Type = MarioType.MT_Fire;
                    SetMarioProperties();
                    Media.PlaySound(Media.SoundType.ST_Mush);
                }
                break;
            }

            case ObjectType.OT_Mush:
            {
                ((MushRed)g).Visible  = false;
                ((MushRed)g).Animated = false;
                ((MushRed)g).Live     = false;
                if (Type == MarioType.MT_Small)
                {
                    Type = MarioType.MT_Big;
                    SetMarioProperties();
                    Media.PlaySound(Media.SoundType.ST_Mush);
                }
                break;
            }

            case ObjectType.OT_MushLife:
            {
                ((MushLife)g).Visible  = false;
                ((MushLife)g).Animated = false;
                ((MushLife)g).Live     = false;
                LevelManager.Instance.MarioLives++;
                break;
            }

            case ObjectType.OT_Coin:
            {
                ((CoinBlock)g).Animated = false;
                ((CoinBlock)g).Visible  = false;
                Media.PlaySound(Media.SoundType.ST_Coin);
                NumberOfCollectedCoins++;
                break;
            }

            case ObjectType.OT_Goomba:
            {
                if (c.Dir == CollisionDirection.CD_Up)
                {
                    if (((MonsterGoomba)g).FallDie == false)        // Jump On Goomba with Up Presses
                    {
                        if (UpPressed)
                        {
                            StartJump(true, 0);
                        }
                        else
                        {
                            StartJump(true, -20);
                        }

                        ((MonsterGoomba)g).GoombaDie();
                        Media.PlaySound(Media.SoundType.ST_Stomp);
                    }
                }
                break;
            }

            case ObjectType.OT_Pirana:
            {
                if (c.Dir == CollisionDirection.CD_Up)          // Jump On Piranah with Up Presses
                {
                    if (UpPressed)
                    {
                        StartJump(true, 0);
                    }
                    else
                    {
                        StartJump(true, -20);
                    }

                    ((MonsterPiranah)g).PiranahDie();
                    Media.PlaySound(Media.SoundType.ST_Stomp);
                }
                break;
            }

            case ObjectType.OT_Koopa:
            {
                if (c.Dir == CollisionDirection.CD_Up)      // Jump On Koopa with Up Presses
                {
                    if (((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_Walking)
                    {
                        if (UpPressed)
                        {
                            StartJump(true, 0);
                        }
                        else
                        {
                            StartJump(true, -20);
                        }

                        ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_Shield);
                        Media.PlaySound(Media.SoundType.ST_Stomp);
                    }
                    else
                    {
                        if ((((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_Shield) && (((MonsterKoopa)g).ReturningTime >= 3))
                        {
                            ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_ShieldMoving);
                        }
                        else if (((MonsterKoopa)g).State == MonsterKoopa.KoopaState.KS_ShieldMoving)
                        {
                            if (UpPressed)
                            {
                                StartJump(true, 0);
                            }
                            else
                            {
                                StartJump(true, -20);
                            }

                            ((MonsterKoopa)g).SetKoopaState(MonsterKoopa.KoopaState.KS_Shield);
                        }
                    }
                }
                break;
            }

            case ObjectType.OT_MovingBlock:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_SolidBlock:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_PipeUp:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_BlockQuestion:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_BlockQuestionHidden:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_Brick:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_Grass:
            {
                SetDirections();

                if (c.Dir == CollisionDirection.CD_TopLeft)
                {
                    if (g.OT == ObjectType.OT_Brick)
                    {
                        //if (MoveState == MarioMoveState.J_Right)
                        //    x -= (int)XAdd;
                        //if (MoveState == MarioMoveState.J_Left)
                        //    x += (int)XAdd;

                        //Intersection_None();
                    }
                }
                if (c.Dir == CollisionDirection.CD_Up)
                {
                    if (g.OT == ObjectType.OT_MovingBlock)
                    {
                        this.y = g.newy - this.height;
                        ((BlockMoving)g).MarioOn = true;
                    }
                    else
                    {
                        if (State != MarioJumpState.J_None)
                        {
                            this.y = g.newy - this.height;
                        }
                    }
                    if (State != MarioJumpState.J_None)
                    {
                        State = MarioJumpState.J_None;
                    }
                    SetDirections();
                }

                if (c.Dir == CollisionDirection.CD_Left)
                {
                    this.x = g.newx - width;
                    //if (g.OT == ObjectType.OT_SolidBlock)
                    //    Intersection_None();
                    if (g.OT == ObjectType.OT_Brick)
                    {
                        //if (MoveState == MarioMoveState.J_Right)
                        //    x -= (int)XAdd;
                        //if (MoveState == MarioMoveState.J_Left)
                        //    x += (int)XAdd;
                        this.x = g.newx - width;
                    }
                }

                if (c.Dir == CollisionDirection.CD_Down)
                {
                    if (State == MarioJumpState.J_Up)
                    {
                        State         = MarioJumpState.JDown;
                        StartPosition = y;
                        TimeCount     = 0;
                        StartVelocity = 0;
                        if (g.OT == ObjectType.OT_BlockQuestion || g.OT == ObjectType.OT_BlockQuestionHidden)
                        {
                            ((BlockQuestion)g).isMonsterExist();
                            ((BlockQuestion)g).StartMove();
                            if (((BlockQuestion)g).HiddenObject.OT != ObjectType.OT_Coin)
                            {
                                Media.PlaySound(Media.SoundType.ST_Block);
                            }
                            else
                            {
                                NumberOfCollectedCoins++;
                                Media.PlaySound(Media.SoundType.ST_Coin);
                            }
                        }
                        if (g.OT == ObjectType.OT_Brick)
                        {
                            if (Type == MarioType.MT_Big || Type == MarioType.MT_Fire)
                            {
                                ((BlockBrick)g).BreakBrick();
                                Media.PlaySound(Media.SoundType.ST_Brick);
                            }
                            else
                            {
                                Media.PlaySound(Media.SoundType.ST_Block);
                            }
                        }
                    }
                }
                if (c.Dir == CollisionDirection.CD_Right)
                {
                    this.x = g.newx + g.width;
                    //if (g.OT == ObjectType.OT_SolidBlock)
                    //    Intersection_None();
                    //XAdd = 0;
                }
                break;
            }
            }
        }
Ejemplo n.º 12
0
 private void ShowLevelCompletedMessage(OnLevelCompleted eventData)
 {
     message.text = OnLevelCompletedMessage;
     animator.SetTrigger(LevelCompletedTrigger);
 }
Ejemplo n.º 13
0
 private void StopMusic(OnLevelCompleted data)
 {
     musicSpeaker.Stop();
 }
Ejemplo n.º 14
0
 private void PlayerDoneMoving()
 {
     OnLevelCompleted?.Invoke();
 }
Ejemplo n.º 15
0
 void LevelCompleted()
 {
     gameState = GameState.CompletedLevel;
     OnLevelCompleted?.Invoke();
 }