public override bool Update() { object objA = A.Value; object objB = B.Value; if (objA != null && objB != null) { GameObject goA = (GameObject)objA; GameObject goB = (GameObject)objB; //EB.Debug.Log("Equality test: A:"+numA+" B:"+numB); if (goA == goB) { Check1.Invoke(); } if (goA != goB) { Check2.Invoke(); } } else { EB.Debug.Log("Equality test failed, game object A or B is null - Parent:" + Parent.name); } return(false); }
//Take "MoveSpeeed" from Check1 on game start void OnEnable() { GameObject MaintCamera = GameObject.Find("Main Camera"); Check1 speed = MaintCamera.GetComponent <Check1>(); TimeInSecForNextMove = speed.NextMoveInSec; }
// Buttom Play\Reset public void PlayPressed() { SceneManager.LoadScene("Tetris"); //ReloadScene Tetris Time.timeScale = 1; //StopPause GameObject MaintCamera = GameObject.Find("Main Camera"); //Change bool Reset in Check1 Check1 speed = MaintCamera.GetComponent <Check1>(); speed.Reset = true; }
//박스에서 나온다. void OnTriggerExit(Collider other) { if (other.tag == "Player") { Check1.GetComponent <HollCheck>().CheckOff(); Check2.GetComponent <HollCheck>().CheckOff(); BoxIn = false; Go1 = true; Go2 = true; Back1 = true; Back2 = true; } }
public override bool Update() { object objA = A.Value; object objB = B.Value; if (objA != null && objB != null) { float numA = (float)objA; float numB = (float)objB; //EB.Debug.Log("Equality test: A:"+numA+" B:"+numB); if (numA == numB) { Check1.Invoke(); } if (numA > numB) { Check2.Invoke(); } if (numA < numB) { Check3.Invoke(); } if (numA >= numB) { Check4.Invoke(); } if (numA <= numB) { Check5.Invoke(); } if (numA != numB) { Check6.Invoke(); } } else { EB.Debug.Log("Equality test failed, item A or B is null - Parent:" + Parent.name); } return(false); }
void CreatePersistentData() { path_persistnt = Path.Combine(Application.persistentDataPath, "Check_data.json"); if (!File.Exists(path_persistnt)) { string a = JsonUtility.ToJson(d); data2 = JsonUtility.FromJson <Check1> (a); File.CreateText(path_persistnt).Dispose(); SavePdata(); } else { string read = File.ReadAllText(path_persistnt); data2 = JsonUtility.FromJson <Check1> (read); } }
static void ViDu4() { //1. Không quan tâm đến kiểu dữ liệu đầu vào ChaoBan1 chao1 = (string temp) => { Console.WriteLine("Chào bạn " + temp); }; ChaoBan1 chao2 = (temp) => { Console.WriteLine("Chào bạn " + temp); }; //2. Để trống nếu không có tham số () ChaoBan2 chao3 = () => { Console.WriteLine("Chào bạn"); }; //3. Nếu chỉ có một tham số bỏ luôn dấu () ChaoBan1 chao4 = temp => { Console.WriteLine("Chào bạn " + temp); }; //4. Nếu có nhiều tham số ngăn cách bằng dấu , ChaoBan3 chao5 = (x, y, z) => { Console.WriteLine("Chào bạn " + x + y + z); }; //5. Nếu phương thức chỉ có 1 câu lệnh thực thi bỏ dấu {} ChaoBan3 chao6 = (x, y, z) => Console.WriteLine("Chào bạn " + x + y + z); //6. Đối với phương thức return TinhToan tinhToan1 = (x, y) => { return(x + y * 100); }; Check1 check1 = (x, y) => { return(x > 4 && y > 4); }; }
void Update() { //Take "MoveSpeeed" from Check1 when game run GameObject MaintCamera = GameObject.Find("Main Camera"); Check1 speed = MaintCamera.GetComponent <Check1>(); TimeInSecForNextMove = speed.NextMoveInSec; //Move right and lock if on border if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { transform.position += new Vector3(1, 0, 0); if (isValidPosition())//Check position { GridUpdate(); } else { transform.position += new Vector3(-1, 0, 0);//Stop move } } //Move left and lock if on border else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { transform.position += new Vector3(-1, 0, 0); if (isValidPosition()) { GridUpdate(); } else { transform.position += new Vector3(1, 0, 0); } } //Rotate else if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) { transform.Rotate(0, 0, -90); if (isValidPosition()) { GridUpdate(); } else { transform.Rotate(0, 0, 90); } } //Move down 1 block for 1 press else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) { transform.position += new Vector3(0, -1, 0); if (isValidPosition()) { GridUpdate(); } else { transform.position += new Vector3(0, 1, 0); } } //Move down fast else if (Input.GetKey(KeyCode.Space)) { transform.position += new Vector3(0, -1f, 0); if (isValidPosition()) { GridUpdate(); } else { transform.position += new Vector3(0, 1, 0); } } //Move down, delete if horizontal full and spawn new object else if (Time.time - fall >= TimeInSecForNextMove) { transform.position += new Vector3(0, -1, 0); //Move down if (isValidPosition()) { GridUpdate(); } else { transform.position += new Vector3(0, 1, 0); DeleteRow(); //Check if can delete horizontal FindObjectOfType <SpawnBox>().SpawnNewBox(); //spawn new object enabled = false; } fall = Time.time; //Calc time } }
private void Update() { check1 = Check1.GetComponent <HollCheck>().GetCheck(); check2 = Check2.GetComponent <HollCheck>().GetCheck(); //박스에 들어왔음 if (BoxIn) { //2에서 3로 갈때 if (check1) { //플레이어 거리 distance = Vector3.Distance(Check1.transform.position, player.transform.position); if (distance > Go_map3On) { if (Go2) { Go2 = false; SceneMap.GetComponent <SceneOnOffManager>().Map3On(); Remix.isMap3 = true; } } else { Go2 = true; SceneMap.GetComponent <SceneOnOffManager>().Map3Off(); Remix.isMap3 = false; } if (distance > Go_map2Off) { Go1 = true; SceneMap.GetComponent <SceneOnOffManager>().Map2Off(); } else { if (Go1) { Go1 = false; SceneMap.GetComponent <SceneOnOffManager>().Map2On(); } } } //3에서 2로 갈때 if (check2) { distance = Vector3.Distance(Check2.transform.position, player.transform.position); if (distance > Back_map2On) { if (Back1) { Back1 = false; SceneMap.GetComponent <SceneOnOffManager>().Map2On(); } } else { Back1 = true; SceneMap.GetComponent <SceneOnOffManager>().Map2Off(); } if (distance > Back_map3Off) { Back2 = true; SceneMap.GetComponent <SceneOnOffManager>().Map3Off(); } else { if (Back2) { Back2 = false; SceneMap.GetComponent <SceneOnOffManager>().Map3On(); } } } } }