private void spawn() { if (_spawnCount > 0) { if (_startWaypoint != null) { int element = Random.Range(0, 1000); if (element < elementaryAffection.instance.airChance) { element = 0; } if (element >= elementaryAffection.instance.airChance && element < (elementaryAffection.instance.airChance + elementaryAffection.instance.earthChance)) { element = 1; } if (element >= (elementaryAffection.instance.airChance + elementaryAffection.instance.earthChance) && element < (elementaryAffection.instance.airChance + elementaryAffection.instance.earthChance + elementaryAffection.instance.fireChance)) { element = 2; } if (element >= (elementaryAffection.instance.airChance + elementaryAffection.instance.earthChance + elementaryAffection.instance.fireChance)) { element = 3; } if (_invadertypes == null || _invadertypes.Length <= element) { Debug.LogError("(wavesystem:spawn) Keine Invasoren zum erstellen verfügbar."); return; } GameObject invader = null; GameObject healthbar = null; switch (element) { case 0: invader = poolmanager.instance.getPooledObject("airInvader"); break; case 1: invader = poolmanager.instance.getPooledObject("earthInvader"); break; case 2: invader = poolmanager.instance.getPooledObject("fireInvader"); break; case 3: invader = poolmanager.instance.getPooledObject("waterInvader"); break; default: break; } healthbar = poolmanager.instance.getPooledObject("healthbar"); if (invader) { invader newInvader = invader.GetComponent <invader>(); followtarget follow = healthbar.GetComponent <followtarget>(); healthbar bar = healthbar.GetComponent <healthbar>(); if (newInvader) { newInvader.transform.position = _startWaypoint.transform.position; newInvader.movement.currentWaypoint = null; newInvader.movement.nextWaypoint = null; /* * * SKALIERUNG * */ newInvader.health.maximumHealth = 100.0f; //newInvader.health.reset(); newInvader.movement.movementSpeed = 1; newInvader.lifedamage.damage = 1; newInvader.elementalenergy.energy = 10; //modmanage.anwenden(IDS, newInvader); /* * * ENDE * */ newInvader.gameObject.SetActive(true); if (bar) { bar.healthObject = newInvader.health; bar.reset(); } if (follow) { follow.targetToFollow = newInvader.transform; follow.Update(); follow.gameObject.SetActive(true); } _spawnCount--; } } } } }