void tailFun() { SnakeController tmpSnake = tail; tail = tail.getNext(); tmpSnake.rmTail(); }
private void Update() { if (pauseGame) { Time.timeScale = 0; } else { Time.timeScale = currentTimeScale; } if (dead || pauseGame) { return; } Timer(); currentTimeScale = Mathf.Clamp(currentTimeScale, 0, 20f); if (Input.GetKeyDown(KeyCode.Escape)) { gameBoard.SetActive(true); resultText.text = "Pause"; PauseGame(); } lengthText.text = SnakeController.BodyLength().ToString(); }
void Start() { SnakeMain = GameObject.FindGameObjectWithTag("SnakeMain").GetComponent <SnakeController>(); MoveSpeed = SnakeMain.MoveSpeed + 0.5f; tailTargetObject = SnakeMain.tailObj[SnakeMain.tailObj.Count - 2]; ID = SnakeMain.tailObj.IndexOf(gameObject); }
//private DebugUI debugUI; void Awake() { snake = GameObject.Find("_GM").GetComponent <SnakeController>(); gameOverAnimator = GameObject.Find("GameOver").GetComponent <Animator>(); inGameScore = scoreGameObject.GetComponent <Text>(); gameOverScore = gameOverScoreGameObject.GetComponent <Text>(); gameOverScreenRecord = lastRecordGameObject.GetComponent <Text>(); newRecord = newRecordGameObject.GetComponent <Text>(); score = 0; // set the debug ui component //debugUI = GameObject.Find("_GM").GetComponent<DebugUI>(); highScores = new int[11]; highScores[0] = PlayerPrefs.GetInt("score01"); highScores[1] = PlayerPrefs.GetInt("score02"); highScores[2] = PlayerPrefs.GetInt("score03"); highScores[3] = PlayerPrefs.GetInt("score04"); highScores[4] = PlayerPrefs.GetInt("score05"); highScores[5] = PlayerPrefs.GetInt("score06"); highScores[6] = PlayerPrefs.GetInt("score07"); highScores[7] = PlayerPrefs.GetInt("score08"); highScores[8] = PlayerPrefs.GetInt("score09"); highScores[9] = PlayerPrefs.GetInt("score10"); // this is to hold the last score. When we sort it later // if still less than all the scores, will be left out. highScores[10] = 0; // Start to get the last records records = new WWW(recordsURL); }
/// <summary> /// Contructor. Inits floor, snake parts, camera controller and move controller. /// </summary> public GameController() { _floor = new Floor(); foodSpawningController = new FeedSpawningController(_floor); _snakeController = new SnakeController(_floor); _cameraController = new CameraController(); }
private void LoadingState() { DebugExecute("Loading"); if (async.isDone) { switch (currentLevel) { case "Splash Screen": break; case "Map Screen": currentState = GameState.MapScreen; break; default: // SET LEVEL REFERENCES /////////////////////////////////////////////////////////////// snake = GameObject.Find("Player Snake").GetComponent <SnakeController>(); exit = GameObject.FindWithTag("Exit"); //////////////////////////////////////////////////////////// EO SET LEVEL REFERENCES // currentState = GameState.NewGame; break; } } }
public void StartGame() { Time.timeScale = 1; hasCollided = false; isCongradulated = false; foodEaten = 0; snakeController = transform.GetComponent <SnakeController>(); snakeController.DestroySnake(); snakeController.CreateSnake(); snakeHead = transform.GetChild(0).gameObject; mobileControls = GetComponent <MobileControls>(); //pool CreatePlayField(); if (pool) { pool.Reset(); } pool.Create(); Destroy(blockContainer); blockContainer = new GameObject("BlockContainer"); GenerateFood(); }
public virtual void DoStep() { UpdateSnake(); ItemSpawner.TrySpawnItems(); SnakeController.ReverseControlsTick(); LevelModifier.Tick(); }
void Move() { GameObject tmp; nextP = head.transform.position; switch (dir) { case 0: nextP = new Vector2(nextP.x, nextP.y + 1); break; case 1: nextP = new Vector2(nextP.x + 1, nextP.y); break; case 2: nextP = new Vector2(nextP.x, nextP.y - 1); break; case 3: nextP = new Vector2(nextP.x - 1, nextP.y); break; } tmp = (GameObject)Instantiate(snake, nextP, transform.rotation); head.setNext(tmp.GetComponent <SnakeController>()); head = tmp.GetComponent <SnakeController>(); }
// Use this for initialization void Start() { snakeController = snakes.gameObject.GetComponent <SnakeController>(); themeSound = GameObject.Find("ThemeSound").GetComponent <AudioSource>(); themeSound.volume = 0.15f; StartGame(); }
void Start() { snakes = GameObject.Find("Snakes"); snakeController = snakes.GetComponent <SnakeController>(); gameController = GameObject.Find("GameController"); gameControllerScript = gameController.GetComponent <GameController>(); }
void Start() { levelManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <LevelManager>(); inputManager = GameObject.FindGameObjectWithTag("InputManager").GetComponent <InputManager>(); snakeController = levelManager.getSnake().GetComponent <SnakeController>(); moves = 0; hasSnakeMoved = true; }
void OnTriggerEnter(Collider other) { //Debug.Log (other.tag); if (other.CompareTag("Body") == true) { SnakeController snakeController = gameObject.GetComponentInParent <SnakeController> (); snakeController.OnSnakeCollision(); } }
void Start() { text = GetComponent <Text>(); currentTime = maxTime; snake = FindObjectOfType <SnakeController>(); fadeTimer = fadeDelay; img1.enabled = false; img2.enabled = false; }
private void OnTriggerEnter(Collider collider) { if (collider.gameObject == head) { SnakeController snakeController = collider.transform.parent.GetComponent <SnakeController>(); snakeController.AddBodyPart(); Destroy(gameObject); } }
private void Awake() { tailSize = insSnakeTailSize; instance = this; snake = GetComponent <SnakeEatController>(); snakeController = GetComponent <SnakeController>(); SnakeCreatePart(); }
public static void BonusLength(SnakeController gameObject, GameObject bonus) { bonus.transform.position = gameObject.addTailPossition; bonus.name = $"Tail {gameObject.Tails.Count + 1}"; gameObject.Targets.AddLast(gameObject.Tails[gameObject.Tails.Count - 1].transform.position); gameObject.Tails.Add(bonus); gameObject.TailsLength++; gameObject.uiManager.SendMessage("UpdateLengthText", gameObject.TailsLength + 1); }
// Use this for initialization void Start() { instance = this; if (GameManager.instance.snakeSpawned) { theSnake.Add(GameManager.instance.snakeHeadInstance); gotSnakeHead = true; } timeBetweenMovesCounter = timeBetweenMoves; }
private void Timer() { timer -= Time.deltaTime / Time.timeScale; timerText.text = ((int)timer).ToString(); if (timer < 0) { SnakeController.EatSelf(); ResetTimer(); } }
private void OnTriggerEnter(Collider collider) { if (collider.CompareTag("Head")) { SnakeController.Die(transform.parent.gameObject); } else if (collider.CompareTag("PickUp")) { SnakeController.BonusLength(ReferenceContainer.SnakeController, collider.gameObject); } }
// Use this for initialization void Start() { _head = transform.parent.FindChild("Head").transform; _snakeController = transform.parent.Find("Head").GetComponent <SnakeController>(); _lineRenderer = GetComponent <LineRenderer>(); _col = GetComponent <EdgeCollider2D>(); _points = new List <Vector2>(); ChanceBetweenGap = Random.Range(30, 51); AddPoint(); InvokeRepeating("InvokeCreateGap", TimeBetweenCreateGap, TimeBetweenCreateGap); }
public void StartGame() { ArrangeGrid(); pizzaSliceObject = GameObject.Instantiate(pizzaSlizePrefab); coroutineForPizza = reposPizzaObj(0); StartCoroutine(coroutineForPizza); SnakeController snakeObject = GameObject.Instantiate(snakprefab); scoreText.text = "0"; ControllerObject.transform.parent.gameObject.SetActive(true); }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log("被吃掉啦"); ChangePosition(); SnakeController.GenerateBody(); GameManager.SpeedUp(); GameManager.RamdomBackground(); GameManager.ResetTimer(); GameManager.SetMessage("吃到食物,时间重置"); GameManager.EatFood(); SoundManager.PlayEatFood(); }
// UNITY METHODS /////////////////////////////////////////////////////////////// void Awake() { // Get snake controller reference snakeController = GetComponent <SnakeController>(); // Get head cell reference _head = GetComponent <SnakeBodyCell>(); _head.body = this; // Initialize body Init(); }
void Start() { if (_instance = null) { _instance = this; } Debug.Log(GetPlayerData()); PlayerScore = 0; UIManager.Instance.OpenPanel(1); UIManager.Instance.SetHighScore(PlayerScore); }
private void Awake() { Field = new FieldController(); m_food = new FoodController(Field); Snakes = new SnakeController(Field); m_camMove = Camera.main.GetComponent <CameraMovement>(); m_canvas = FindObjectOfType <UICanvas>(); }
//Triggers on 2D Collision private void OnTriggerEnter2D(Collider2D collision) { //Getting instance of SnakeContoller Object to see if the collision is null SnakeController sc = collision.gameObject.GetComponent <SnakeController>(); //If gameobject is not equal to null call Snake Controller eat method. if (sc != null) { sc.Eat(); } MoveToNewSpace(); }
private void spawnTail() { if (Tail) { Tail.spawnTail(); } else { SnakeController tail = Instantiate(FindObjectOfType <LevelHandler>().SnakePrefab, transform.position - (-transform.right.normalized) * Time.deltaTime, Quaternion.identity).GetComponent <SnakeController>(); Tail = tail; tail.Head = this; SetTailPosition(); } }
public void EatFoodAtLocation(int foodGameX, int foodGameY, SnakeController snakeEating) { foreach (Food food in Program.Food) { if (food.X == foodGameX && food.Y == foodGameY) { Program.DebugLog("Growing!"); Program.Food.Remove(food); snakeEating.Grow(); //make the snake move faster Program.TickRate += 0.25f; break; } } }
// Use this for initialization void Start() { Button btnRestart = btn1.GetComponent <Button> (); Button btnExit = btn2.GetComponent <Button> (); snkCtr = GameObject.Find("/Player/Snake").GetComponent <SnakeController> (); scoreCtr = GameObject.Find("/Canvas/ScoreValue").GetComponent <ScoreCtr> (); soundCtr = GameObject.Find("/Scene/Sound").GetComponent <SceneSoundCtr> (); sceneCtr = GameObject.Find("/Scene/SceneController").GetComponent <SceneCtr> (); btnRestart.onClick.AddListener(RestartTask); btnExit.onClick.AddListener(ExitTask); Debug.Log(score.name); score.SetActive(false); }
void Start() { controller = gameObject.GetComponent<SnakeController>(); controller.controlType = SnakeController.ControlType.RandomAI; }
void Start() { controller = gameObject.GetComponent<SnakeController>(); controller.controlType = SnakeController.ControlType.KeyboardRotation; }
void Start() { snake = FindObjectOfType<SnakeController>(); speedLocker = FindObjectOfType<RotateForward>(); inputDriver = FindObjectOfType<InputDriver>(); }
void Start() { system = FindObjectOfType<LevelingSystem>(); snake = FindObjectOfType<SnakeController>(); checkNExecuteDeactivationCondition(); }
void Awake() { if (instance == null) { instance = this; } }
void Awake() { instance = this; }
void Start() { controller = gameObject.GetComponent<SnakeController>(); controller.controlType = SnakeController.ControlType.KeyboardPosition; levelManager = GameObject.Find("LevelManager").GetComponent<LevelManager>(); }