public void Initial() { map = GlobalMap.GetMap(); mapSize = GlobalMap.GetMapSize(); mapIndex = 0; resurrectionIndex = 0; GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); GlobalMap.SetWinFlag(0); transform.position = new Vector3(0, 0, 0); now_x = transform.position.x; //now_y = transform.position.y; now_z = transform.position.z; ground_index = 0; resurrectionPoint = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5); ground[ground_index] = new MyPoint((int)now_x, (int)now_z, 2.5, 2.5); ground[1 - ground_index] = new MyPoint((int)now_x + dx, (int)now_z + dz, 2.5, 2.5); rotation_count = 0; isalive = 1; speed = spee_default; max_x = min_x = (int)now_x; max_z = min_z = (int)now_z; nowScore = 0; lastScore = 0; continueCount = 3; ui_gameSystem.ContinueTextUpdate(continueCount); transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); }
public bool onContinue() { int ddx, ddz, ans; if (continueCount > 0) { continueCount--; ui_gameSystem.ContinueTextUpdate(continueCount); } else { return(false); } rotation_count = 0; mapIndex = resurrectionIndex; GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); ground [ground_index].Set(resurrectionPoint); ground [1 - ground_index].Set(resurrectionPoint); ground [1 - ground_index].Updata(dx, dz); GlobalMap.ChangeDxy(map [mapIndex + 1].dxDz, out ddx, out ddz); //transform.position.Set(ground [ground_index].x,0,ground [ground_index].z); transform.position = new Vector3(ground [ground_index].x, 0, ground [ground_index].z); //transform.rotation = Quaternion.AngleAxis((dx-dz)/5*90, new Vector3(0,1,0)); if (ddz != 0) { ans = (ddz) / 5 * 90 - 90; } else { ans = 0; } if (ddx != 0) { ans += (ddx) / 5 * 90; } transform.rotation = Quaternion.Euler(new Vector3(0, ans, 0)); Debug.Log("dx:" + ddx + " dz:" + ddz); //speed = spee_default; isalive = 1; nowScore = lastScore; speed = spee_default; return(true); }
void CloneObject() { cloneObj = Instantiate(cloneGround[map[mapIndex].cubeType]) as GameObject; cloneObj.transform.position = new Vector3(now_x, now_y, now_z); //if (map [mapIndex].materialType != 0) { cloneObj.GetComponent <Renderer> ().material = material [map [mapIndex].materialType]; //} if (map [mapIndex].dxDz == 0) { cloneObj.transform.Rotate(new Vector3(0, 90, 0)); } else if (map [mapIndex].dxDz == 1) { cloneObj.transform.Rotate(new Vector3(0, 270, 0)); } else if (map [mapIndex].dxDz == 2) { cloneObj.transform.Rotate(new Vector3(0, 180, 0)); } else if (map [mapIndex].dxDz == 3) { cloneObj.transform.Rotate(new Vector3(0, 0, 0)); } groundQueue.Enqueue(cloneObj); groundList.Add(cloneObj); if (map[mapIndex].rewardType != 0) { cloneObj = Instantiate(cloneScore) as GameObject; cloneObj.transform.position = new Vector3(now_x + Random.value * 4 - 2, (float)(now_y + 2.5), now_z + Random.value * 4 - 2); scoreQueue.Enqueue(cloneObj); } GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); if (mapIndex < mapSize) { mapIndex++; } now_x += dx; now_z += dz; }
// Update is called once per frame void Update() { now_x = transform.position.x; now_z = transform.position.z; if (isalive == 1 && !ground [ground_index].IsInPoint(now_x, now_z)) { if (!ground [1 - ground_index].IsInPoint(now_x, now_z)) { speed = 0; isalive = 0; ui_gameSystem.ActiveContinuePanel(true); } else { if (mapIndex == mapSize - 1 && !GlobalMap.GetWinFlag()) { speed = 0; isalive = 0; myCamera.transform.position = new Vector3((min_x + max_x) >> 1, 300, (min_z + max_z) >> 1); myCamera.transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0)); GlobalMap.SetWinFlag(1); ui_gameSystem.ActiveEndPanel(true); //Debug.Log ("ENDENDEND"); } else { if (map [mapIndex].materialType == 2) { resurrectionIndex = mapIndex; resurrectionPoint.Set(ground [ground_index]); lastScore = nowScore; } if (now_x > max_x) { max_x = (int)now_x; } if (now_x < min_x) { min_x = (int)now_x; } if (now_z > max_z) { max_z = (int)now_z; } if (now_z < min_z) { min_z = (int)now_z; } mapIndex++; GlobalMap.ChangeDxy(map [mapIndex].dxDz, out dx, out dz); //ChangeDxy (); //Debug.Log ("dx:"+dx+" dz:"+dz); ground_index = 1 - ground_index; ground [1 - ground_index].Set(ground [ground_index]); ground [1 - ground_index].Updata(dx, dz); //Debug.Log ("dx:"+dx+" dz:"+dz); //Debug.Log ("now_x:"+ now_x+" now_z:"+ now_z); //Debug.Log ("x0:"+ground [ground_index].x+" z0:"+ground [ground_index].z+" x1:"+ground [1 - ground_index].x+" z1:"+ground [1 - ground_index].z); speed += 0.1; nowScore += 10; tmpScore = nowScore - 5; } } } else { if (dx != 0) { tmpScore = nowScore + (int)((transform.position.x - ground [ground_index].x) * 10 / dx); } else { tmpScore = nowScore + (int)((transform.position.z - ground [ground_index].z) * 10 / dz); } } ui_gameSystem.ScoreTextUpdate(tmpScore); if (scoreQueue.Count > 0) { scoreTransform = scoreQueue.Peek().transform; if (GlobalMap.ReachTest(scoreTransform, this.transform)) { speed = spee_default; Destroy(scoreQueue.Peek()); //Debug.Log ("this:"+this.transform.position.x+" " + this.transform.position.z); //Debug.Log ("score:"+scoreTransform.position.x+" " + scoreTransform.position.z); //Debug.Log ("dx:"+dx+" dz:"+dz); Debug.Log("reach"); scoreQueue.Dequeue(); } else if (GlobalMap.OverTest(this.transform, scoreTransform, dx, dz)) { //Debug.Log ("this:"+this.transform.position.x+" " + this.transform.position.z); //Debug.Log ("score:"+this.scoreTransform.position.x+" " + this.scoreTransform.position.z); //Debug.Log ("dx:"+dx+" dz:"+dz); Debug.Log("over"); Destroy(scoreQueue.Peek(), 2); scoreQueue.Dequeue(); } } if (!GlobalMap.GetWinFlag()) { transform.Translate(Vector3.forward * (float)speed * Time.deltaTime, Space.Self); } while (groundQueue.Count > 0 && ground [ground_index].IsInPoint(groundQueue.Peek().transform.position.x, groundQueue.Peek().transform.position.z)) { groundQueue.Dequeue(); } }