// 抛出飞碟 public void ThrowDisk() { float position_x = 16; if (diskQueue.Count != 0) { diskNumber--; GameObject disk = diskQueue.Dequeue(); // 取出飞碟 diskNotshot.Add(disk); disk.SetActive(true); // 设置飞碟的随机位置 float ran_y = Random.Range(1f, 4f); float ran_x = Random.Range(-1f, 1f) < 0 ? -1 : 1; disk.GetComponent <DiskData>().direction = new Vector3(ran_x, ran_y, 0); Vector3 position = new Vector3(-disk.GetComponent <DiskData>().direction.x *position_x, ran_y, 0); disk.transform.position = position; // 设置飞碟初始所受的力和角度 float power = Random.Range(10f, 15f); float angle = Random.Range(15f, 28f); actionManager.Fly(disk, angle, power); } for (int i = 0; i < diskNotshot.Count; i++) { GameObject temp = diskNotshot[i]; //飞碟飞出摄像机视野也没被打中 if (temp.transform.position.y < -20 && temp.gameObject.activeSelf == true) { diskFactory.FreeDisk(diskNotshot[i]); diskNotshot.Remove(diskNotshot[i]); } } }
public void Fly(GameObject role_, Vector3 emitPosition_, Vector3 emitDirection_) { if (sceneController.getIsPhysics()) { flyActionManager.Fly(role_, emitPosition_, emitDirection_); } else { kinematics.Fly(role_, emitPosition_, emitDirection_); } }
// 实现通用接口 public void Fly(GameObject disk, float angle, float power, bool physics) { if (physics) { physicsActionManager.Fly(disk, angle, power); } else { flyActionManager.Fly(disk, angle, power); } }