void checkCube() { if (Input.GetKeyDown(KeyCode.Space) || EmoFacialExpression.isBlink && timeLag > processInterval) { timeLag = 0f; if (!hasCube) // Connect gyro to cube to allow movement { RaycastHit hit; //Debug.DrawRay(transform.position, transform.forward, Color.magenta); if (Physics.Raycast(transform.position, transform.forward, out hit, range)) { if (hit.collider.gameObject.CompareTag("CUBE")) { cubeScript = hit.collider.gameObject.GetComponent <CubeControl>(); cubeScript.aquire(); hasCube = true; } } } else //Drop cube { cubeScript.drop(); hasCube = false; } } }
void OnTriggerExit(Collider coll) { if (coll.transform.CompareTag("TurnCubeInMultiple")) { coll.GetComponent <FixedBlock> ().IsPlayerOn = false; } if (coll.transform.CompareTag("MovableSingle")) { CubeControl ctrl = coll.gameObject.GetComponent <CubeControl> (); if (ctrl != null) { ctrl.enabled = true; } } else if (coll.transform.CompareTag("MovableMulti")) { Transform form = coll.transform; foreach (Transform k in form) { CubeControl ctrl = k.GetComponent <CubeControl> (); if (ctrl != null) { ctrl.enabled = true; k.gameObject.GetComponent <FixedBlock> ().enabled = false; } } } }
//游戏结束地雷全部标识出来 private void gameOver() { for (int i = 0; i < Cubes.Length; ++i) { CubeControl temp = Cubes[i]; if (temp.statusMine == (int)StatusEnum.activeMine) { temp.activeMine.SetActive(true); } else if (temp.statusMine == (int)StatusEnum.disableMine) { temp.disableMine.SetActive(true); temp.flagMine.SetActive(false); } else if (temp.statusMine == (int)StatusEnum.burstMine) { temp.burstMine.SetActive(true); } else if (temp.statusMine == (int)StatusEnum.initialCube) { expand(temp.row, temp.col); //temp.tileMine.SetActive(false); //temp.textMine.GetComponent<Text>().text = "" + neighborCount(temp.row,temp.col); } } }
// Use this for initialization void Start() { this.scrambleButton = this.transform.FindChild("ScrambleButton").gameObject; this.undoButton = this.transform.FindChild("UndoButton").gameObject; this.redoButton = this.transform.FindChild("RedoButton").gameObject; CubeTargetControl = CubeTarget.GetComponent<CubeControl>(); }
// Use this for initialization void Start() { m_cc = GetComponentInParent <CubeControl>(); m_text = GetComponent <Text>(); m_scoreMultiplier = PlayerPrefs.GetInt("PlayerMult", 0); m_score = PlayerPrefs.GetInt("PlayerScore", 0); m_multText.text = "x" + m_scoreMultiplier; m_text.text = m_score.ToString(); }
//鼠标点击了 一个cube public void OnClick(CubeControl temp) { Debug.Log("此类型:" + temp.statusMine.ToString()); //左键 if (temp.clickType == LEFT_CLICK) { //若是初始状态 if (temp.statusMine == (int)StatusEnum.initialCube) { expand(temp.row, temp.col); } else if (temp.statusMine == (int)StatusEnum.activeMine) { temp.statusMine = (int)StatusEnum.burstMine; gameOver(); } } //标旗 if (temp.clickType == RIGHT_CLICK) { if (temp.statusMine == (int)StatusEnum.initialCube || temp.statusMine == (int)StatusEnum.activeMine) { //bool flagstatus; //flagstatus = temp.flagMine.activeInHierarchy; //temp.flagMine.SetActive(!flagstatus); if (temp.flagMine.activeInHierarchy == true) { temp.flagMine.SetActive(false); } else { temp.flagMine.SetActive(true); } //格子状态切换 if (temp.flagMine.activeInHierarchy == true) { if (temp.statusMine == (int)StatusEnum.activeMine) { temp.statusMine = (int)StatusEnum.disableMine; } } else { if (temp.statusMine == (int)StatusEnum.disableMine) { temp.statusMine = (int)StatusEnum.activeMine; } } } } }
void OnTriggerEnter(Collider cube) //If a cube enters //HiddenGameManager.Instance.scoredCube = cube.gameObject.tag; //pass the tag to gamemanager { cubecontrol = cube.GetComponent <CubeControl>(); if (cubecontrol != null) { cubecontrol.CubeWakeUp(); } if (OnCubeEnter != null) { OnCubeEnter(cube.gameObject.tag.ToString()); } }
// Use this for initialization void Start () { if (width % 2 == 0) { ++width; } if (height % 2 == 0) { ++width; } maze = new int[width, height]; StartCells = new List<Cell>(); CurrentWallCells = new Stack<Cell>(); random = new Random(); cube = (GameObject)Resources.Load("Cube"); upDownCube = (GameObject)Resources.Load("UpDownCube"); for (var k = 0; k < level; k++) { CreateMaze(); maze[1, 1] = 1; maze[width - 2, height - 2] = 1; for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { if (maze[i, j] == 0) { Instantiate(cube, new Vector3(i, floorHeight * k, j), Quaternion.identity); } } } if(k % 2 == 0) { GameObject obj = Instantiate(upDownCube, new Vector3(width - 2, floorHeight * k, height - 2), Quaternion.identity) as GameObject; CubeControl cubeControl = obj.GetComponent<CubeControl>(); cubeControl.movement = new Vector3(0, floorHeight, 0); } else { GameObject obj = Instantiate(upDownCube, new Vector3(1, floorHeight * k, 1), Quaternion.identity) as GameObject; CubeControl cubeControl = obj.GetComponent<CubeControl>(); cubeControl.movement = new Vector3(0, floorHeight, 0); } } }
// Update is called once per frame void Update() { if (MouseFlag == true) { timer += Time.deltaTime; } if (timer > 0.7f) { MouseFlag = false; timer = .0f; CubeControl temp = this.GetComponent <CubeControl> (); if (temp != null && IsPlayerOn == false) { temp.LongClickEvent.Invoke(); } } }
private void expand(int row, int col) { if (row >= 0 && row < rowNum && col >= 0 && col < colNum) { CubeControl temp = Cubes[row * colNum + col]; if (temp.isBomb == false && temp.statusMine == (int)StatusEnum.initialCube) { temp.statusMine = (int)StatusEnum.emptyCube; int num = neighborCount(row, col); if (num != 0) { //if(temp.tileMine.activeInHierarchy==true) temp.tileMine.SetActive(false); //if(temp.textMine.activeInHierarchy==false) temp.textMine.SetActive(true); temp.textMine.GetComponent <Text>().text = "" + num; } else { //if (temp.tileMine.activeInHierarchy == true) temp.tileMine.SetActive(false); //if (temp.textMine.activeInHierarchy == false) temp.textMine.SetActive(true); temp.textMine.GetComponent <Text>().text = "" + 0; expand(row - 1, col - 1); expand(row - 1, col); expand(row - 1, col + 1); expand(row, col - 1); expand(row, col + 1); expand(row + 1, col - 1); expand(row + 1, col); expand(row + 1, col + 1); } } } }
// Start is called before the first frame update void Start() { theCube = FindObjectOfType <CubeControl>(); myCamera = Camera.main.GetComponent <CameraControl>(); }
public JobStabilize(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; }
public JobRotateFface(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube, float degreesLeft, float rotationVelocity) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; this.degreesLeft = degreesLeft; this.rotationVelocity = rotationVelocity; }
public JobRotateByMouse(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube, bool isClockwise, bool isMainMouseX) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; this.isClockwise = isClockwise; this.isMainMouseX = isMainMouseX; }
public JobReassignFaces(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; }