void Start() { seeSaw = GameObject.Find("seesaw"); seeSawMoverTag = "AffectSeesaw"; playerBody = transform.Find("Body").transform; grabSphere = transform.Find("grabSphere").GetComponent<ColliderCheck>(); grabSphere.grabThreshold = grabThreshold; originUp = transform.up; charController = this.GetComponent<CharacterController>(); }
IEnumerator CalAmountBuilding() { //配置 for (int i = 0; i < 8; i++) { AddRightBuilding(this.defaultPosBuilding_Right[i]); } for (int i = 0; i < 8; i++) { AddLeftBuilding(this.defaultPosBuilding_Left[i]); } this.currentSpawnObj = GameObject.Instantiate(this.spawnObj_Pref); this.currentSpawnObj.transform.position = new Vector3(0, 0, GlobalDefine.floorPosInterval); this.currentColliderCheck = this.currentSpawnObj.GetComponentInChildren <ColliderCheck>(); StartCoroutine(WaitCheckFloor()); yield return(0); }
//添加区块 void AddRegion(float startZPos) { Vector3 pos = Vector3.zero; pos.z = startZPos + GlobalDefine.floorPosInterval / 2; //添加地块 GameObject floor = Instantiate <GameObject>(this.floor_Pref); floor.transform.position = pos; this.regionList.Add(floor); //添加建筑 for (int i = 0; i < 8; i++) { //左 Vector3 leftBuildingPos = new Vector3(-3, 0, startZPos + GlobalDefine.defaultBuildingInterval * i); GameObject leftBuilding = AddLeftBuilding(leftBuildingPos); leftBuilding.transform.parent = floor.transform; //右 Vector3 rightBuildingPos = new Vector3(3, 0, 4 + startZPos + GlobalDefine.defaultBuildingInterval * i); GameObject rightBuilding = AddRightBuilding(rightBuildingPos); rightBuilding.transform.parent = floor.transform; } //添加道具 float itemInterval = GlobalDefine.floorPosInterval / GlobalDefine.itemNumPerFloor; int lastCoinPos = 0;//-1,0,1 for (int i = 0; i < GlobalDefine.itemNumPerFloor; i++) { //------------之后要改为生成多种道具。目前只生成硬币 Vector3 itemPos = pos; itemPos.z += i * itemInterval; //随机左右 float rand = Random.value; if (rand > 0.8) { int randomPosNum = Mathf.FloorToInt(Random.Range(0, 3) - 1);//-1,0,1 if (lastCoinPos + randomPosNum == 0) { randomPosNum = 0; } lastCoinPos = randomPosNum; } itemPos.x = lastCoinPos * 1.8f; AddCoin(floor, itemPos); } //添加检测 GameObject spawnObj = Instantiate <GameObject>(this.spawnObj_Pref); spawnObj.transform.position = pos + new Vector3(0, 0, GlobalDefine.floorPosInterval / 2); this.spawnObjList.Add(spawnObj); //配置当前检测 if (this.spawnObjList.Count >= beforehandFloorNum) { this.currentSpawnObj = this.spawnObjList[spawnObjList.Count - beforehandFloorNum];//为倒数第三个进行检测 this.currentColliderCheck = this.currentSpawnObj.GetComponentInChildren <ColliderCheck>(); } }
void Awake() { colliderCheck = GetComponent <ColliderCheck> (); spriteRenderer = GetComponent <SpriteRenderer>(); }
private void Awake() { colliderCheck = GetComponent <ColliderCheck>(); }