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"); } }
public void UpdateScore() { Scorer scorer = SnakeApplication.GetInstance().model.scorer; ScoreLabel.text = scorer.Score.ToString(); TopScoreLabel.text = scorer.TopScore.ToString(); }
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"); }
void SwallowFood(Vector3Int position) { Level level = SnakeApplication.GetInstance().model.level; level.RemoveElementWithPosition(position); app.Notify(SnakeNotifications.FoodSpawn); }
private static Scorer GetScorer() { SnakeModel model = SnakeApplication.GetInstance().model; if (model != null && model.scorer != null) { return(model.scorer); } else { return(new Scorer()); } }
public void StartNewGame(string difficulty) { HideGameDifficultyWindow(); SnakeApplication.GetInstance().Notify(SnakeNotifications.InitGame, difficulty, "string"); }
public void setDirection(Direction nextDirection) { SnakeApplication.GetInstance().model.snake.SetNextDirection(nextDirection); }
public bool IsAvailableDirection(Direction nextDirection) { Snake snake = SnakeApplication.GetInstance().model.snake; return(SnakesDirectionHelper.IsAvailableDirection(snake.GetCurrentDirection(), nextDirection)); }
public override void InitView() { level = SnakeApplication.GetInstance().model.level; AdjustGameView(); InitObstaclesView(); }
void InitFoodsView() { removeObjects(FoodElementsView); foodModel = SnakeApplication.GetInstance().model.food; syncListView(FoodElementsView, foodModel.GetFood(), foodObject); }
void InitSnakeView() { removeObjects(SnakeElementsView); snake = SnakeApplication.GetInstance().model.snake; syncListView(SnakeElementsView, snake.GetSnake(), snakesBodyObject); }
public override void Interact() { SnakeApplication.GetInstance().Notify(SnakeNotifications.KillSnake); Debug.Log("Die"); }