///<description>Spawn Plane with these parametes</description> public Plane SpawnPlane(PlaneSOData planeSOData, APlaneContoller planeContoller, Transform spawnPosRot) { Plane plane = GetNextUnusedPooledObject(); plane.InitPlane(planeSOData, planeContoller, spawnPosRot); return(plane); }
///<description>Pseudo Pool for Player plane</description> ///<param name="playerPlaneDataAndControl">Plane Data and Keyboard controller </param> ///<param name="planeContoller">Plane Contoller</param> ///<param name="onDeathCallback">onDeathCallback</param> ///<param name="playerNumber">Player Number</param> public Plane SpawnPlayerPlanes(PlayerDataAndControl playerPlaneDataAndControl, APlaneContoller planeContoller, System.Action <Plane> onDeathCallback, int playerNumber = 1) { playerPlanesPool[playerNumber - 1].InitPlane(playerPlaneDataAndControl.planeSOData, planeContoller, playerSpawnPosition[playerNumber - 1]); ((PlayerPlane)playerPlanesPool[playerNumber - 1]).keyControls = playerPlaneDataAndControl.keyBoardControl; playerPlanesPool[playerNumber - 1].onDeath += onDeathCallback; playerPlanesPool[playerNumber - 1].gameObject.SetActive(true); return(playerPlanesPool[playerNumber - 1]); }
public override void InitPlane(PlaneSOData PlaneData, APlaneContoller PlaneContoller, Transform spawnPosRot = null) { enemyPlane = ((AIPlaneController)PlaneContoller).GetRandomEnemyPlane(); if (enemyPlane == null) { DisablePlane(); } base.InitPlane(PlaneData, PlaneContoller, spawnPosRot); activateTime = Time.time; }
public virtual void InitPlane(PlaneSOData planeData, APlaneContoller PlaneContoller, Transform spawnPosRot = null) { ResetParams(); EnablePlane(); this.planeData = planeData; this.planeContoller = PlaneContoller; transform.name = planeData.planeName; healthModel.InitParams(this, planeData.maxHealth, OnPlaneDeath); planeSprite.color = planeData.planeColor; if (spawnPosRot != null) { transform.position = spawnPosRot.position; transform.rotation = spawnPosRot.rotation; } }
///<description>Pseudo Pool for Player plane</description> ///<param name="planeContoller">Plane Contoller</param> ///<param name="levelData">level Data contatining spawn frequency and wave delays</param> ///<param name="onDeathCallback">onDeathCallback</param> public IEnumerator SpawnPlanesForLevel(APlaneContoller planeContoller, LevelData levelData, System.Action <Plane> onDeathCallback) { currentSpawnIndex = 0; Plane tempPlane; foreach (AIWaveData aIWaveData in levelData.enemySpawnSequence) { for (int i = 0; i < aIWaveData.numberOfSpawns; i++) { tempPlane = aIPlanePool.SpawnPlane(aIWaveData.aIPlaneSOData, planeContoller, aISpawnPositions[currentSpawnIndex]); tempPlane.onDeath += onDeathCallback; currentSpawnIndex = (currentSpawnIndex + 1) % aISpawnPositions.Length; yield return(new WaitForSeconds(aIWaveData.timeDiffToSpawn)); } yield return(new WaitForSeconds(levelData.timeDiffBetweenWaves)); } }