예제 #1
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");
        }
    }
예제 #2
0
    public void UpdateScore()
    {
        Scorer scorer = SnakeApplication.GetInstance().model.scorer;

        ScoreLabel.text    = scorer.Score.ToString();
        TopScoreLabel.text = scorer.TopScore.ToString();
    }
예제 #3
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");
 }
예제 #4
0
    void SwallowFood(Vector3Int position)
    {
        Level level = SnakeApplication.GetInstance().model.level;

        level.RemoveElementWithPosition(position);
        app.Notify(SnakeNotifications.FoodSpawn);
    }
예제 #5
0
    private static Scorer GetScorer()
    {
        SnakeModel model = SnakeApplication.GetInstance().model;

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

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