Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

64,24): warning CS0219: The variable `nextTetromino' is assigned but its value is never used, (131,163): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

$
0
0
here is the script i am doing for a class, its two parts, also whenever i go to said errors to find out what is going on and even go back to video from class everything on my professor end looks the same as mine so i am not sure what i did wrong - this is the game script using UnityEngine; using System.Collections; public class Game : MonoBehaviour { public static int gridWidth = 10; public static int gridHeight = 20; public static Transform[,] grid = new Transform[gridWidth, gridHeight]; // Use this for initialization void Start () { SpawnNextTetromino (); } // Update is called once per frame void Update () { } public void updateGrid (Tetromino tetromino) { for (int y = 0; y gridHeight - 1) { return null; } else { return grid [(int)pos.x, (int)pos.y]; } } public void SpawnNextTetromino () { GameObject nextTetromino = (GameObject)Instantiate(Resources.Load(GetRandomTetromino(), typeof(GameObject)), new Vector2 (5.0f, 20.0f), Quaternion.identity); } public bool CheckIsInsideGrid (Vector2 pos) { return ((int)pos.x >= 0 && (int)pos.x < gridWidth && (int)pos.y >= 0); } public Vector2 Round (Vector2 pos) { return new Vector2 (Mathf.Round(pos.x), Mathf.Round(pos.y)); } string GetRandomTetromino () { int RandomTetromino = Random.Range (1, 8); string RandomTetrominoName = "Prefabs/Tetromino_T"; switch (RandomTetromino) { case 1: RandomTetrominoName = "Prefabs/Tetromino_T"; break; case 2: RandomTetrominoName = "Prefabs/Tetromino_Long"; break; case 3: RandomTetrominoName = "Prefabs/Tetromino_Square"; break; case 4: RandomTetrominoName = "Prefabs/Tetromino_J"; break; case 5: RandomTetrominoName = "Prefabs/Tetromino_L"; break; case 6: RandomTetrominoName = "Prefabs/Tetromino_S"; break; case 7: RandomTetrominoName = "Prefabs/Tetromino_Z"; break; } return RandomTetrominoName; } } and this is the tetromino script using UnityEngine; using System.Collections; public class Tetromino : MonoBehaviour { float fall = 0; public float fallSpeed = 1; public bool allowRotation = true; public bool limitRoatation = false; // Use this for initialization void Start () { } // Update is called once per frame void Update () { CheckUserInput (); } void CheckUserInput () { if (Input.GetKeyDown(KeyCode.RightArrow)) { transform.position += new Vector3(1, 0, 0); if (CheckIsValidPosition()) { FindObjectOfType().updateGrid(this); } else { transform.position += new Vector3(-1, 0, 0); } } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += new Vector3(-1, 0, 0); if (CheckIsValidPosition()) { FindObjectOfType().updateGrid(this); } else { transform.position += new Vector3(1, 0, 0); } } else if (Input.GetKeyDown(KeyCode.UpArrow)) { if (allowRotation) { if (limitRoatation) { if (transform.rotation.eulerAngles.z >= 90) { transform.Rotate(0, 0, -90); } else { transform.Rotate(0, 0, 90); } } else { transform.Rotate (0, 0, 90); } if (CheckIsValidPosition()) { FindObjectOfType().updateGrid(this); } else { if (transform.rotation.eulerAngles.z >= 90) { transform.Rotate(0, 0, -90); } else { if (limitRoatation) { transform.Rotate (0, 0, 90); } transform.Rotate (0, 0, -90); } } } } else if (Input.GetKeyDown(KeyCode.DownArrow) || Time.time - fall >= fallSpeed) { transform.position += new Vector3(0, -1, 0); if (CheckIsValidPosition()) { FindObjectOfType().updateGrid(this); } else { transform.position += new Vector3(0, 1, 0); enabled = false; FindObjectOfType().SpawnNextTetromino(); } fall = Time.time; } } bool CheckIsValidPosition () { foreach (Transform mino in transform) { Vector2 pos = FindObjectOfType().Round (mino.position); if (FindObjectOfType().CheckIsInsideGrid (pos) == false) { return false; } if (FindObjectOfType().GetTransformAtGetPosition(pos) != null && FindObjectOfType().GetTransformAtGetPosition(pos).parent != Transform) { return false; } } return true; } } if anyone can help me i would appreciate it thanks in advance

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>