protected void DoSpawn(Vector3 pos) { var effectBag = new GrabBag <Entities.Effect>(true); effectBag.AddItems(effects, effectWeights); steeringBag = new GrabBag <Entities.SteeringEffect>(true); steeringBag.AddItems(steerings, steeringWeights); var maxEnemyIndex = (int)(GameManager.Instance.depth / 100f); maxEnemyIndex = Mathf.Clamp(maxEnemyIndex, 0, enemies.Count - 1); var enemy = enemies[Mathf.Clamp(enemyBag.GetItem(), 0, maxEnemyIndex)]; var numSteerings = rand.RandomIntLessThan((int)steeringsPerDepth.Evaluate(GameManager.Instance.depth)); var numEffects = rand.RandomIntLessThan((int)effectsPerDepth.Evaluate(GameManager.Instance.depth)); var spawned = Instantiate(enemy); var enem = spawned.GetComponent <Entities.BasicEnemy>(); for (int i = 0; i < numSteerings; i++) { if (steeringBag.IsEmpty()) { break; } enem.AddSteering(steeringBag.GetItem()); } for (int i = 0; i < numEffects; i++) { if (effectBag.IsEmpty()) { break; } enem.AddEffect(effectBag.GetItem()); } spawned.transform.position = pos; spawned.transform.parent = holder.transform; }
public void TryPlaceShrine() { for(int i = 0; i < 30; i++) { var chosenX = rand.RandomIntInRange(10, width - 10); var chosenY = rand.RandomIntInRange(10, height - 10); var numOcc = 0; for(int j = -2; j < 2; j++) { for(int k = -2; k < 0; k++) { numOcc += hardness.hardness[chosenX + j + (chosenY + k) * width]; } } if(numOcc == 0) { var spawned = Instantiate(upgradeShrinePrefab); spawned.transform.parent = holder.transform; spawned.transform.position = new Vector3(chosenX, chosenY, -3); var upgrade = spawned.GetComponentInChildren<Powerup>(); upgrade.Setup(powerupBag.GetItem()); return; } } }