//public bool rbFirst; void Start() { segments = new List <Vector2>(); mcm = p.GetComponent <MainCharacterMovement>(); //gameObject.AddComponent<LineRenderer>(); line = gameObject.AddComponent <LineRenderer>(); }
void ResetLevel() { GameObject currLevel = GameObject.FindGameObjectWithTag("level"); GameObject pacmanSpawned = GameObject.FindGameObjectWithTag("pacman"); MainCharacterMovement pacmanScript = pacmanSpawned.GetComponent <MainCharacterMovement> (); Destroy(pacmanSpawned); GameObject[] ghosts = GameObject.FindGameObjectsWithTag("ghost"); foreach (GameObject ghost in ghosts) { Destroy(ghost); } StreamReader inp_strm = new StreamReader(filePath); int boardHeight = 0; while (!inp_strm.EndOfStream) { string line = inp_strm.ReadLine(); for (int i = 0; i < line.Length; ++i) { char c = line [i]; if (c == '.') { GameObject pelletSpawned = Instantiate(pellet, currLevel.transform); pelletSpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'I') { GameObject inkySpawned = Instantiate(inky, currLevel.transform); inkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'P') { GameObject inkySpawned = Instantiate(pinky, currLevel.transform); inkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'B') { GameObject inkySpawned = Instantiate(blinky, currLevel.transform); inkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'C') { GameObject inkySpawned = Instantiate(clyde, currLevel.transform); inkySpawned.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); } else if (c == 'M') { GameObject newPacman = Instantiate(pacman, currLevel.transform); newPacman.transform.position = new Vector3(topLeftX + cellSize * i, topLeftY - cellSize * boardHeight); pacmanScript = newPacman.GetComponent <MainCharacterMovement> (); } } ++boardHeight; } inp_strm.Close(); ui.ReadHighScore(); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); cooldown = false; an = GetComponent <Animator>(); pacman = FindObjectOfType <MainCharacterMovement>(); }
private void Start() { _controller = GetComponent <CharacterController>(); mainCharacterMovement = gameObject.AddComponent <MainCharacterMovement>(); mainCharacterMovement.Init(_controller); gravity = gameObject.AddComponent <Gravity>(); gravity.Init(_controller); }
public void Horizontal_Main_Character_Movement_Test() { //Arrange GameObject gameObject = MonoBehaviour.Instantiate(GameObject.Find("Protagonista")); var horizontalInput = Input.GetAxis("Horizontal"); mainCharacter = gameObject.GetComponent <MainCharacterMovement>(); float speed = 1.5f; //Act mainCharacter.CharacterMove(speed); Wait(15f); //Assert var initialPosition = mainCharacter.transform.position.y; Assert.Less(mainCharacter.transform.position.y, initialPosition); GameObject.Destroy(mainCharacter.gameObject); }