Ejemplo n.º 1
0
    public void UpdateScore()
    {
        Scorer scorer = SnakeApplication.GetInstance().model.scorer;

        ScoreLabel.text    = scorer.Score.ToString();
        TopScoreLabel.text = scorer.TopScore.ToString();
    }
Ejemplo n.º 2
0
 public override void Interact()
 {
     SnakeApplication.GetInstance().Notify(SnakeNotifications.IncreaseSnake);
     SnakeApplication.GetInstance().Notify(SnakeNotifications.IncreaseSnake);
     SnakeApplication.GetInstance().Notify(SnakeNotifications.FoodSwallow, this.position, "Vector3Int");
     SnakeApplication.GetInstance().Notify(SnakeNotifications.ChangeGameSpeed, 1f, "float");
 }
Ejemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
        {
            SnakeApplication.GetInstance().Notify(SnakeNotifications.PressUp);
        }

        if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
        {
            SnakeApplication.GetInstance().Notify(SnakeNotifications.PressLeft);
        }

        if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
        {
            SnakeApplication.GetInstance().Notify(SnakeNotifications.PressDown);
        }

        if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            SnakeApplication.GetInstance().Notify(SnakeNotifications.PressRight);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            SnakeApplication.GetInstance().Notify(SnakeNotifications.ChangeGameSpeed, 1f, "float");
        }
    }
Ejemplo n.º 4
0
    void SwallowFood(Vector3Int position)
    {
        Level level = SnakeApplication.GetInstance().model.level;

        level.RemoveElementWithPosition(position);
        app.Notify(SnakeNotifications.FoodSpawn);
    }
Ejemplo n.º 5
0
    void Awake()
    {
        application  = this;
        mainObserver = new Notifier();
        controllers  = new List <Controller>();

        RegisterController(new GameStartController());
        Notify(SnakeNotifications.ShowGameDifficultyWindow);
    }
Ejemplo n.º 6
0
    private static Scorer GetScorer()
    {
        SnakeModel model = SnakeApplication.GetInstance().model;

        if (model != null && model.scorer != null)
        {
            return(model.scorer);
        }
        else
        {
            return(new Scorer());
        }
    }
Ejemplo n.º 7
0
 public void StartNewGame(string difficulty)
 {
     HideGameDifficultyWindow();
     SnakeApplication.GetInstance().Notify(SnakeNotifications.InitGame, difficulty, "string");
 }
Ejemplo n.º 8
0
 public void setDirection(Direction nextDirection)
 {
     SnakeApplication.GetInstance().model.snake.SetNextDirection(nextDirection);
 }
Ejemplo n.º 9
0
    public bool IsAvailableDirection(Direction nextDirection)
    {
        Snake snake = SnakeApplication.GetInstance().model.snake;

        return(SnakesDirectionHelper.IsAvailableDirection(snake.GetCurrentDirection(), nextDirection));
    }
Ejemplo n.º 10
0
 public override void InitView()
 {
     level = SnakeApplication.GetInstance().model.level;
     AdjustGameView();
     InitObstaclesView();
 }
Ejemplo n.º 11
0
 void InitFoodsView()
 {
     removeObjects(FoodElementsView);
     foodModel = SnakeApplication.GetInstance().model.food;
     syncListView(FoodElementsView, foodModel.GetFood(), foodObject);
 }
Ejemplo n.º 12
0
 void InitSnakeView()
 {
     removeObjects(SnakeElementsView);
     snake = SnakeApplication.GetInstance().model.snake;
     syncListView(SnakeElementsView, snake.GetSnake(), snakesBodyObject);
 }
Ejemplo n.º 13
0
 public override void Interact()
 {
     SnakeApplication.GetInstance().Notify(SnakeNotifications.KillSnake);
     Debug.Log("Die");
 }