protected virtual void SpawnUnit(CardData unitData, Vector3 position) { NonControllableUnit unit = Instantiate <NonControllableUnit>( (NonControllableUnit)unitData.unit, spawnPosition, board.Value.npcSpawnPosition.rotation ); unit.Initialize(playerHero, unitData.unitStats, "EnemyTeam"); npcUnits.Add(unit); }
private void Update() { if (timerEvent > 0f) { timerEvent -= Time.deltaTime; if (timerEvent <= 0f) { lastWave = encounterEvent.NextPhase(ref nextSpawn); if (!lastWave) { timerSpawn = Time.deltaTime; } else { NonControllableUnit tmp = Instantiate((NonControllableUnit)boss.unit, bossSpawnPoint); tmp.Initialize(activeHero, boss.unitStats, "EnemyTeam"); enemyUnits.Add(tmp);//TODO EVENT CLEAR } } } if (timerSpawn > 0f) { timerSpawn -= Time.deltaTime; if (timerSpawn <= 0f) { timerSpawn = SpawnUnit(nextSpawn[0]); nextSpawn.RemoveAt(0); timerEvent -= timerSpawn; if (nextSpawn.Count == 0) { timerEvent *= -1f; timerSpawn = -1f; } } } }
private void OnTriggerEnter(Collider other) { Unit unit = other.gameObject.GetComponent <Unit>(); if (unit != null && unit.GetComponent <UnitHealth>().alive) { if (playerSide.items.Contains(unit)) { playerSide.Remove(unit); NPCSide.Add(unit); } else { NPCSide.Remove(unit); playerSide.Add(unit); } } }
private void Update() { if (isSpawning) { Vector3 boardPosition; bool validRayCastHit; validRayCastHit = rayCast.BoardRayCast(out boardPosition, spawnLayer.Value); unit.transform.position = new Vector3(boardPosition.x, unitSizeOffset, boardPosition.z); if (validRayCastHit && Input.GetMouseButtonDown(0)) { ((NonControllableUnit)unit).Initialize(npcHero, selectedCard.unitStats, "PlayerTeam"); playerSide.Add(unit); unit = null; isSpawning = false; } } commander.Think(); }
private void Awake() { rayCast = this.GetComponent <Prototype.RayCast>(); joystickController = new JoystickController(); keyboardController = new KeyboardController(rayCast); spellCasting = new SpellCasting(this); playerUnits.items.Clear(); for (int i = 0; i < units.Length && units[i] != null; i++) { unitPortraits[i].gameObject.SetActive(true); units[i] = Instantiate(units[i]); units[i].gameObject.SetActive(false); units[i].Initialize(this, unitPortraits[i]); } currentUnit = units[0]; currentAnimator = currentUnit.GetComponentInChildren <Animator>(); currentUnit.transform.position = playerSpawn; currentUnit.gameObject.SetActive(true); playerUnits.Add(currentUnit); GetComponent <CameraController>().UpdateTarget(currentUnit.gameObject); spellCasting.UpdateSpellBook(ref currentUnit.spellBook); }