// Use this for initialization void Start() { // Initialise the spheres' pool spheres = new PoolingManager<GameObject>(spherePrefab); // Initialise the cubes' pool cubes = new PoolingManager<GameObject>(cubePrefab); // Initialise the capsules' pool capsules = new PoolingManager<Rigidbody>(capsulePrefab); }
public void setPoolParent(PoolingManager parent) { poolParent = parent; }
private void Awake() { _instance = this; }
void Awake() { if (current == null) { current = this; pooledObjectParent = GameObject.Find ("PooledObjects").transform; //DontDestroyOnLoad (gameObject); } else if (current != this) { Destroy (gameObject); } indexedPools.Clear (); pools.Clear (); // On nettoie tout pour éviter qu'il y ait des blocs actifs quand on reboot foreach (Transform obj in pooledObjectParent.GetComponentInChildren<Transform> ()) { obj.gameObject.SetActive (false); } foreach(PoolingScript pool in poolCollection) { pool.Init(); pools.Add(pool.poolName, pool); // S'il y a un index, on ajoute dans un dictionnaire de listes if( "" != pool.poolIndex ) { OrderedPools orderedPools; // On vérifie si la valeur existe déjà, et on ajoute dans la bonne key if( !indexedPools.TryGetValue( pool.poolIndex, out orderedPools ) ) { orderedPools = new OrderedPools (new List<PoolingScript>()); //indexedPools.Add( pool.poolIndex, list ); indexedPools.Add( pool.poolIndex, orderedPools ); } orderedPools.pools.Add (pool); } } // On mélange une première fois les listes indexées foreach (KeyValuePair<string, OrderedPools> entry in indexedPools) { ShuffleList (entry.Value.pools, true); } }
public override void Activated(PoolingManager manager) { base.Activated(manager); currentState = IGridCell.State.InactiveNew; //Debug.Log("Activated() called"); }
private void Start() { poolingManager = FindObjectOfType <PoolingManager>(); }
/// <summary> /// Lance une salve /// </summary> /// <param name="salvo">Salve à lancer</param> public void Shoot(Salvo salvo) { currentTimeBeforeNextSalvo = currentShootParameters.GetTimeBewteenSalvos; currentShootParameters.IncreaseSalvoIndex(); shootedPositions = new List <List <Vector3> >(); #region Calculate Directions PoolingManager poolManager = GameManager.gameManager.PoolManager; Projectile shootProjectilePrefab = poolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.PeekFromPool); bool isBoulder = shootProjectilePrefab.IsBoulder; List <Vector3> allShootDirections = isBoulder ? GetAllShootPositions(salvo) : GetAllShootDirections(salvo); float projectilesSpacing = salvo.GetProjectilesSpacing; foreach (Vector3 direction in allShootDirections) { List <Vector3> thisShootedPos = new List <Vector3>(); /**/ List <Vector3> allPossiblePositions = CirclePositionsGenerator.GetAllPositionsInCircle(salvo.GetProjectileParameters.GetCurrentProjectileSize, projectilesSpacing, salvo.GetImprecisionParameter); for (int i = 0; i < salvo.GetNumberOfProjectiles; i++) { Projectile shootProjectile = poolManager.GetProjectile(salvo.GetProjectileType, PoolInteractionType.GetFromPool); shootProjectile.transform.position = transform.position; shootProjectile.transform.rotation = Quaternion.identity; if (relatedShip != null) { shootProjectile.SetSource(relatedShip); } else if (relatedTurret != null) { shootProjectile.SetSource(relatedTurret); } if (isBoulder) { //List<Vector3> allPossiblePositions //Vector3 modifiedPosition = direction + new Vector3(Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter), 0, Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter)); /**/ int randomIndex = Random.Range(0, allPossiblePositions.Count); Vector3 modifiedPosition = direction + allPossiblePositions[randomIndex] + new Vector3(Random.Range(-projectilesSpacing / 2, projectilesSpacing / 2), 0, Random.Range(-projectilesSpacing / 2, projectilesSpacing / 2)); allPossiblePositions.RemoveAt(randomIndex); /**/ shootProjectile.ShootProjectile(salvo.GetProjectileParameters, transform.position, modifiedPosition); thisShootedPos.Add(modifiedPosition); } else { Vector3 modifiedDirection = Quaternion.Euler(0, Random.Range(-salvo.GetImprecisionParameter, salvo.GetImprecisionParameter), 0) * direction; shootProjectile.ShootProjectile(salvo.GetProjectileParameters, modifiedDirection, GameManager.gameManager.Player.GetShipVelocity); } shootProjectile.SetProjectileTag(currentShootParameters.GetProjectileTag); #region Special Parameters if (projectileSpecialParameters != null) { shootProjectile.SetProjectileSpecialParameters( new ProjectileSpecialParameters( new ShipSpeedModifier(projectileSpecialParameters.GetSpeedModifier), new ProjectilePiercingParameters(projectileSpecialParameters.GetPiercingParameters), new ProjectileSkeweringParameters(projectileSpecialParameters.GetSkeweringParameters), projectileSpecialParameters.GetExplosionParameters, new SmokeZoneParameters(projectileSpecialParameters.GetSmokeZoneParameters), new SlowingZoneParameters(projectileSpecialParameters.GetSlowingZoneParameters) )); shootProjectile.GetProjectileSpecialParameters.GetSkeweringParameters.SetSourceProjectile(shootProjectile); } #endregion if (allPossiblePositions.Count == 0 && isBoulder) { Debug.LogWarning("couldn't shoot all boulders"); break; } } shootedPositions.Add(thisShootedPos); } #endregion #region Feedback if (shootParticleSystem != null) { //ParticleSystem.EmitParams parameters = shootParticleSystem.emission.; //if (shootParticleSystem.isPlaying) //{ //Debug.Log("ui"); //shootParticleSystem.Stop(); //shootParticleSystem.Play(); //shootParticleSystem.Emit(8); //waitingTimeToRelaunchShootEffect = 0.05f; /*} * else * shootParticleSystem.Play();*/ shootParticleSystem.Emit(2); } if (currentShootParameters.GetProjectileTag == AttackTag.Player) { Vibration.Vibrate(shootVibrationDuration); GameManager.gameManager.ScrshkManager.StartScreenshake(shootShakeParameters); } if (shootAudioSource != null) { shootAudioSource.PlaySound(currentShootParameters.GetShootSound); } #endregion if (currentShootParameters.GetCurrentSalvoIndex > 1) { ContinueLaunchedPreview(salvo); } }