public bool is_grounded() { if (pos[1] == 0) { return(true); } else if (Block_Pos.is_occupy(pos[0], pos[1] - 1)) { return(true); } else { return(false); } }
void Generate_virus() { //Set random and send to virus GameObject hmm = (GameObject)Instantiate(virus); hmm.name = "BasicVirus"; int x, y, z; x = Random.Range(0, 8); y = Random.Range(0, 8); while (Block_Pos.is_occupy(x, y)) { x = Random.Range(0, 8); y = Random.Range(0, 8); } hmm.SendMessage("Set_x", x); hmm.SendMessage("Set_y", y); z = Random.Range(0, 3); hmm.SendMessage("Set_type", z); Block_Pos.make_occupy(x, y, hmm); }
void control() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { //Need to check for avaible if (!Block_Pos.is_occupy(pos[0] - 1, pos[1])) { pos[0] = pos[0] - 1; transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1); } } if (Input.GetKeyDown(KeyCode.RightArrow)) { //Need to check for avaible if (!Block_Pos.is_occupy(pos[0] + 1, pos[1])) { pos[0] = pos[0] + 1; transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1); } } if (Input.GetKeyDown(KeyCode.Space)) { pos[1] = Block_Pos.check_down(pos[0], pos[1]); transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 2f); landing(pos[0], pos[1], gameObject); } if (Input.GetKeyDown(KeyCode.DownArrow)) { if (!Block_Pos.is_occupy(pos[0], pos[1] - 1)) { pos[1] = pos[1] - 1; transform.position = Vector3.Lerp(transform.position, Block_Pos.get_pos(pos[0], pos[1]), 1); } if (Block_Pos.is_occupy(pos[0], pos[1] - 1)) { landing(pos[0], pos[1], gameObject); } } }