private void OnEnabledCube(CubeBehavior obj) { if (lastEventText) { lastEventText.text = "The cube named " + obj.gameObject.name + " is enabled"; } }
void Fire() { Transform cam = Camera.main.transform; nextFire = Time.time + fireRate; Vector3 rayorigin = cam.position; laserline.SetPosition(0, transform.up * -10); RaycastHit hit; if (Physics.Raycast(rayorigin, cam.forward, out hit, FireRange)) { laserline.SetPosition(1, hit.point); CubeBehavior cubecrtl = hit.collider.GetComponent <CubeBehavior>(); if (cubecrtl != null) { if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * HitForce); cubecrtl.Hit(LaserDamage); } } } else { laserline.SetPosition(1, cam.forward * FireRange); } StartCoroutine("LaserFX"); }
void Update() { if (!mIsShowingBoard) { if (Input.GetMouseButtonUp(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000.0f)) { GameObject hitObject = hit.collider.gameObject; if (hitObject != null && hitObject.name == "BoardAugmentationObject") { CubeBehavior cube = hitObject.GetComponent <CubeBehavior>(); if (cube) { cube.OnUserClicked(); } } } } } /* * if ( mIsShowingBookData ) * { * if (Input.GetMouseButtonUp(0)) * { * RaycastHit hit; * Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); * if (Physics.Raycast (ray, out hit, 1000.0f)) { * GameObject hitObject = hit.collider.gameObject; * if (hitObject != null && hitObject.name == "BookInformation" ) * { * if (mBookData != null && mIsShowingMenu == false) * { * Application.OpenURL(mBookData.BookDetailUrl); * } * } * } * } * } * * if (mIsLoadingBookThumb) * { * LoadBookThumb(); * } */ // Show/hide loading progress spinner if we are loading book data or thumb //SetLoadingSpinnerVisibile (mIsLoadingBookData || mIsLoadingBookThumb); // Show cancel button if the Cloud Reco is not enabled, otherwise hide it //SetCancelButtonVisible(mCloudRecoBehaviour.CloudRecoInitialized && !mCloudRecoBehaviour.CloudRecoEnabled); //SetLoadingSpinnerVisibile (true); //SetBoardUIVisible (true); }
public void NSwitch() { generator_now.Generate(); cube_now = generator_now.cube.GetComponent <CubeBehavior>(); if (cube_now.GetDir() == 0) { target = null; } else { target = generator_now.neighbors[cube_now.GetDir() - 1]; } }
// Use this for initialization void Start() { generator_now = StartGenerator.GetComponent <CubeGenerator> (); generator_now.SetMoving(true); cube_now = generator_now.cube.GetComponent <CubeBehavior>(); if (cube_now.GetDir() == 0) { target = null; } else { target = generator_now.neighbors[cube_now.GetDir() - 1]; } }
void AddEnemy() { if (enemyPrefab) { totalEnemyCount += 1; GameObject newEnemy = Instantiate(enemyPrefab, new Vector3(-30, 0.5f, 0), Quaternion.identity); enemyList.Add(newEnemy); CubeBehavior enemyScript = newEnemy.GetComponent <CubeBehavior>(); if (enemyScript) { enemyScript.speed = enemySpeed + Random.Range(-1f, 0.5f); } Destroy(newEnemy, 18f - (enemySpeed / 5f)); } }
public void SwitchG(GameObject next_generator) { generator_now.SetMoving(false); next_generator.GetComponent <CubeGenerator> ().SetLast(generator_now.gameObject); generator_now = next_generator.GetComponent <CubeGenerator>(); generator_now.SetMoving(true); cube_now = generator_now.cube.GetComponent <CubeBehavior>(); if (cube_now.GetDir() == 0) { target = null; } else { target = generator_now.neighbors[cube_now.GetDir() - 1]; } }
public void OnCubeClicked(CubeBehavior cube) { if (cube.myColor == 0) { if (activeCube != null) { if (Mathf.Abs(activeCube.myX - cube.myX) <= 1 && Mathf.Abs(activeCube.myY - cube.myY) <= 1) { cube.setColor(activeCube.myColor); activeCube.setColor(0); } } } else { (cube.GetComponent("Halo") as Behaviour).enabled = true; (activeCube.GetComponent("Halo") as Behaviour).enabled = false; activeCube = cube; } }
// Use this for initialization void Start() { getFlag = getFlag.GetComponent <CubeBehavior>(); value = true; this.gameObject.transform.rotation = Quaternion.identity; }
void Cube_Reactions() { //0(Left),1(right),2(Up),3(Down) //Reds can only clear when 3 of them at a side. if ((Cube_Contacts [0] != null) && (Cube_Contacts [1] != null)) { if ((Cube_Contacts [0].tag == "Red") && (Cube_Contacts [1].tag == "Red") && (this.gameObject.tag == "Red")) { C_B = Cube_Contacts [0].GetComponent <CubeBehavior> (); Cube_Contacts [0].SetActive(false); C_B.MeshTagUpdate = true; C_B.IsMoving = true; // C_B = Cube_Contacts [1].GetComponent <CubeBehavior> (); Cube_Contacts [1].SetActive(false); C_B.MeshTagUpdate = true; C_B.IsMoving = true; // this.gameObject.SetActive(false); MeshTagUpdate = true; IsMoving = true; A_C_C.CubesActive -= 3; A_C_C.Score += 100; A_C_C.CubesDestroyed += 3; } } //Blues can only clear when 3 of them stacked on top of each other if ((Cube_Contacts [2] != null) && (Cube_Contacts [3] != null)) { if ((Cube_Contacts [2].tag == "Blue") && (Cube_Contacts [3].tag == "Blue") && (this.gameObject.tag == "Blue")) { C_B = Cube_Contacts [2].GetComponent <CubeBehavior> (); Cube_Contacts [2].SetActive(false); C_B.MeshTagUpdate = true; C_B.IsMoving = true; // C_B = Cube_Contacts [3].GetComponent <CubeBehavior> (); Cube_Contacts [3].SetActive(false); C_B.MeshTagUpdate = true; C_B.IsMoving = true; // this.gameObject.SetActive(false); MeshTagUpdate = true; IsMoving = true; A_C_C.CubesActive -= 3; A_C_C.Score += 200; A_C_C.CubesDestroyed += 3; } else if ((Cube_Contacts [3].tag == "Ground") && (this.gameObject.tag == "Grey")) { Greys = GameObject.FindGameObjectsWithTag("Grey"); for (int Grey_Count = 0; Grey_Count < Greys.Length; Grey_Count++) { C_B = Greys [Grey_Count].GetComponent <CubeBehavior> (); C_B.MeshTagUpdate = true; } this.gameObject.SetActive(false); MeshTagUpdate = true; IsMoving = true; } } }
private void OnEnable() { t = ((CubeBehavior)target).transform; c = ((CubeBehavior)target); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1) && m_Mode == Mode.Edit_Environment) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out m_HitObject)) { if (m_HitObject.transform.gameObject.CompareTag("Ground") && m_HitObject.transform.position.y > m_CellSize * 0.5f) { GameObject.Destroy(m_HitObject.transform.gameObject); } } } if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out m_HitObject)) { if (m_HitObject.transform.gameObject.CompareTag("Ground")) { Vector3 position = m_HitObject.transform.position; if (m_Mode == Mode.Edit_Environment) { CubeBehavior behavior = m_HitObject.transform.parent.gameObject.GetComponent <CubeBehavior>(); if (!Physics.Raycast(new Ray(position, Vector3.up), out m_HitObject)) { position.y += m_CellSize * 0.5f; GameObject temp = GameObject.Instantiate(m_Cell); temp.transform.parent = GridRoot.transform; temp.transform.position = position; if (behavior.Type == CubeType.White) { temp.GetComponent <CubeBehavior>().Type = CubeType.Black; temp.GetComponentInChildren <Renderer>().material = m_Black; } else { //No need to change material as default material is white temp.GetComponent <CubeBehavior>().Type = CubeType.White; } } } else if (m_Mode == Mode.Spawn_Green_Dominos) { position.y += m_CellSize * 0.6f;//Little bit of drop effect . 0.5 will make it spawn exactly on ground . 0.6 bit above the ground GameObject temp = GameObject.Instantiate(m_GreenDomino); temp.transform.parent = DominosRoot.transform; temp.transform.position = position; temp.transform.right = GameCamera.transform.right; } else if (m_Mode == Mode.Spawn_Red_Dominos) { position.y += m_CellSize * 0.6f; GameObject temp = GameObject.Instantiate(m_RedDomino); temp.transform.parent = DominosRoot.transform; temp.transform.position = position; temp.transform.right = GameCamera.transform.right; } else if (m_Mode == Mode.Spawn_Ball) { position.y += m_CellSize * 1.5f; GameObject ballObject = GameObject.Instantiate(m_Ball); ballObject.transform.position = position; Rigidbody rigidbody = ballObject.GetComponent <Rigidbody>(); rigidbody?.AddForce(GameCamera.transform.right * 170, ForceMode.Force); } } } } }
public void OnEnable() { cubeBehavior = target as CubeBehavior; cubeTransform = cubeBehavior.transform; }