public static void BeginGame() { //Clean up screen and game settings if a previous game was played Console.Clear(); Input.GameRunning = true; Ticker.StartTicker(); ScoreKeeper.Score = 0; if (SnakeControl.tailPoints.Count > 0) { SnakeControl.tailPoints.RemoveRange(0, SnakeControl.tailPoints.Count - 1); } Input.CurrentDirectionPressed = "none"; //Set up game settings Board.SetBoardSize(10); Pickup.SpawnPickup(); SnakeControl.SnakeSetup(); Ticker.OnTick += UpdateBoard; SnakeControl.OnTailCollision += EndGame; }
void Start() { paused = false; timerInSeconds = 0; snakeScript = snakeObject.GetComponent <SnakeControl>(); timerText.text = timerInSeconds.ToString(); StartCoroutine(SystemTimer()); }
static void UpdateBoard() { SnakeControl.UpdateSnakePosition(); SnakeControl.CheckCollisionWithTail(); SnakeControl.CheckCollisionWithPickup(); Draw.DrawBoard(); }
void Start() { Controller = GameObject.Find ("GameManager"); snake = Controller.GetComponent<SnakeControl> (); Head = GameObject.Find ("SnakeHead"); move = new bool[4]; move[0] = Head.GetComponent<HeadMove>().move[0]; move[1] = Head.GetComponent<HeadMove>().move[1]; move[2] = Head.GetComponent<HeadMove>().move[2]; move[3] = Head.GetComponent<HeadMove>().move[3]; }
private SnakeControl GetUserInput() { SnakeControl turnDir = SnakeControl.Invalid; if (KeyboardInput.IsKeyDown(Key.Left)) { turnDir = SnakeControl.TurnLeft; } if (KeyboardInput.IsKeyDown(Key.Right)) { turnDir = SnakeControl.TurnRight; } return(turnDir); }
void Start() { Controller = GameObject.Find ("GameManager"); Trigger = new GameObject[5]; Body = Resources.Load ("Prefabs/SnakeBody") as GameObject; Trigger[1] = Resources.Load ("Prefabs/Trigger1") as GameObject; Trigger[2] = Resources.Load ("Prefabs/Trigger2") as GameObject; Trigger[3] = Resources.Load ("Prefabs/Trigger3") as GameObject; Trigger[4] = Resources.Load ("Prefabs/Trigger4") as GameObject; timer = new int[100]; move = new bool[4]; snake = Controller.GetComponent<SnakeControl> (); move[0] = false; move[1] = false; move[2] = false; move[3] = false; }
/// <summary> /// Update rotation /// </summary> /// <param name="turnDirection">Turn direction</param> /// <param name="speed">speed in points</param> public void UpdateRotation(SnakeControl turnDirection, float speed) { if (turnDirection == SnakeControl.TurnLeft) { Rotation -= _turnRate; } if (turnDirection == SnakeControl.TurnRight) { Rotation += _turnRate; } var heading = Utils.DirectionToVector(Rotation, speed); X += heading.X; Y += heading.Y; }
void Awake() { Time.timeScale = 1; _instance = this; InitSprites(); }
void Start() { snakeControl = GetComponent <SnakeControl>(); }