コード例 #1
0
ファイル: SnakeView.cs プロジェクト: leitmotive/Snake
    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
ファイル: SnakeBodyView.cs プロジェクト: leitmotive/Snake
 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");
 }