private void Awake() { agent = GetComponent <NavMeshAgent>(); _CapSule = GetComponent <CapsuleCollider>(); _Rd = GetComponent <Rigidbody>(); ZombieGenerator = transform.parent.parent.GetComponent <ZombieGenerator>(); zombieAnimator = GetComponent <Animator>(); Application.targetFrameRate = 60; }
public void SpawnZombies() { ZombieGenerator zombieGenerator = FindObjectOfType <ZombieGenerator>();; foreach (EntityData entity in entities) { if (entity.entityType == EntityType.Zombie) { Vector3 position = entity.position; Quaternion rotation = entity.rotation; GameObject zombiePrefab = zombieGenerator.zombie; GameObject zombie = Instantiate(zombiePrefab, position, rotation); break; } } }
// Use this for initialization void Start() { playerGenerator = gameObject.AddComponent <PlayerCombinationScript>(); GameObject.Find("Player").GetComponent <Shoot>().enabled = true; PlayerSelectionScreenListener listener = GameObject.Find("GUI").GetComponent <PlayerSelectionScreenListener>(); playerGenerator.createCombination(GameObject.Find(listener.getPlayer1()).gameObject, GameObject.Find(listener.getPlayer2()).gameObject); player = playerGenerator.getPlayer(); player.AddComponent <PlayerController>(); generator = GetComponent <ZombieGenerator>(); generator.GenerateNewZombies(numStartZombies); updateWaveText(); }
void getGeneratorId(int id, string type)//通过PhotonView的ID使得非主节点获取到生成池实例 { if (PhotonNetwork.isMasterClient) { return; } var ob = PhotonView.Find(id); if (type == "Zombie") { this.m_zombieGenerator = ob.GetComponent <ZombieGenerator>(); } else if (type == "Skeleton") { this.m_skeletonGenerator = ob.GetComponent <ZombieGenerator>(); } //添加骷髅兵 完成并完成生成池对骷髅兵调度(模仿僵尸生成池) }
//初始化怪物生成池 public void initMonsterGenerator() { GameObject ob; if (PhotonNetwork.isMasterClient) { ob = PhotonNetwork.InstantiateSceneObject("ZombieGenerator", Vector3.zero, Quaternion.identity, 0, null); m_zombieGenerator = ob.GetComponent <ZombieGenerator>(); m_zombieGenerator.initGenerator(); photonView.RPC("getGeneratorId", PhotonTargets.All, ob.GetPhotonView().viewID, "Zombie"); //添加骷髅兵 完成并完成生成池对骷髅兵调度(模仿僵尸生成池) ob = PhotonNetwork.InstantiateSceneObject("SkeletonGenerator", Vector3.zero, Quaternion.identity, 0, null); m_skeletonGenerator = ob.GetComponent <ZombieGenerator>(); m_skeletonGenerator.initGenerator(); photonView.RPC("getGeneratorId", PhotonTargets.All, ob.GetPhotonView().viewID, "Skeleton"); } }
protected void InitZombies() { ZombieGenerator zombieGenerator = FindObjectOfType <ZombieGenerator>(); for (int x = 0; x < UnityEngine.Random.Range(0, 2); x++) { float posX = UnityEngine.Random.Range(coord.x * 10.0f - 5, coord.x * 10.0f + 5); float posZ = UnityEngine.Random.Range(coord.z * 10.0f - 5, coord.z * 10.0f + 5); Ray ray = new Ray(new Vector3(posX, (coord.y * 10 - 5), posZ), new Vector3(0, -1, 0)); if (Physics.Raycast(ray, out RaycastHit hit, 10)) { if (hit.transform.tag.Equals("chunk") && hit.point.y > -1 && hit.point.y < 5) { Vector3 position = hit.point; Quaternion rotation = Quaternion.Euler(new Vector3(0, UnityEngine.Random.Range(0, 360), 0)); entities.Add(new EntityData(position, rotation, EntityType.Zombie)); } } } }
public void setZombieGenerator(ZombieGenerator zombieGen) { this.zombieGen = zombieGen; }
public void Init(ZombieGenerator generator){ generator.IncrCount(); this.generator = generator; }
public void Init(ZombieGenerator generator) { generator.IncrCount(); this.generator = generator; }