/// <summary> /// Initialisation du Flock /// </summary> public void InitializeFlock(FlockSettings newFlockSettings, BezierSolution.BezierSpline spawnSpline, Vector3Int sensitivity) { flockSettings = newFlockSettings; flockInitialRot = transform.rotation; inAttack = false; isSpawning = true; _Player = GameObject.FindGameObjectWithTag("Player"); transform.position = spawnSpline.GetPoint(0); bezierWalkerTime.SetNewSpline(spawnSpline); bezierWalkerTime.NormalizedT = 0; bezierWalkerTime.travelTime = flockSettings.spawnTimer; _mainGuide = gameObject.transform; //Main guide prends la valeur de this (CF : Variable _mainGuide) _GuideList = new List <Transform>(); //Instanciation de la guide list _curCurveDistanceList = new List <Vector3>(); // Instanciation de la list de distance sur les courbes pour chaque guide _BoidSettings = new BoidSettings[6][]; spawnSettings = flockSettings.spawnSettings; roamSettings = flockSettings.roamSettings; attackSettings = flockSettings.attackSettings; destructionSettings = flockSettings.destructionSettings; getAwaySettings = flockSettings.getAwaySettings; hitReactionSettings = flockSettings.hitReactionSettings; _BoidSettings[0] = spawnSettings; _BoidSettings[1] = roamSettings; _BoidSettings[2] = attackSettings; _BoidSettings[3] = destructionSettings; _BoidSettings[4] = getAwaySettings; _BoidSettings[5] = hitReactionSettings; _KoaManager = Instantiate(_KoaPrefab, transform); //Instantiate Koa _SCKoaManager = _KoaManager.GetComponent <SC_KoaManager>(); //Récupère le Koa manager du koa instancié _SCKoaManager.Initialize(_mainGuide, flockSettings.boidSpawn, spawnSettings[0], newFlockSettings, sensitivity); //Initialise le Koa | paramètre : Guide a suivre <> Nombre de Boids a spawn <> Comportement des boids voulu flockWeaponManager.Initialize(flockSettings, KoaMainAnimator, KoaEmissiveAnimator); _splineTab = new BezierSolution.BezierSpline[flockSettings.splines.Length]; for (int i = 0; i < flockSettings.splines.Length; i++) { if (flockSettings.splines[i] != null) { _splineTab[i] = Instantiate(flockSettings.splines[i]); } } Invoke("ActivateFlock", flockSettings.spawnTimer); }
/// <summary> /// Avant le start, instanciation /// </summary> public void Initialize(Transform newGuide, int newSpawnCount, BoidSettings newSettings, FlockSettings flockSettings) { regeneration = true; curRecoveryTimer = 0; recoveryDuration = 1.5f; flockManager = newGuide.GetComponent <SC_FlockDisplay>(); curFlockSettings = flockSettings; spawnCount = newSpawnCount; Player = GameObject.FindGameObjectWithTag("Player"); switch (flockSettings.attackType) { case FlockSettings.AttackType.none: koaCharID = 'A'; break; case FlockSettings.AttackType.Bullet: koaCharID = 'B'; break; case FlockSettings.AttackType.Laser: koaCharID = 'C'; break; } koaNumID = SC_BoidPool.Instance.GetFlockID(); koaID = koaCharID + "#" + koaNumID; //Instanciation des list de Boid et de Guide _boidsTab = SC_BoidPool.Instance.GetBoid(curFlockSettings.maxBoid); _guideList = new List <Transform>(); //Récupération du comportement initial curBoidSettings = newSettings; sensitivity = new Vector3Int(3, 5, 4); //Ajout du premier guide a la liste _guideList.Add(newGuide); respawnTimer = 0; _koa = Instantiate(_koaPrefab); _koa.transform.position = transform.position; Invoke("InitBoids", 1f); }
/// <summary> /// Initialisation du Flock /// </summary> public void InitializeFlock() { flockSettings = flockDisplay; flockInitialRot = transform.rotation; inAttack = false; _mainGuide = gameObject.transform; //Main guide prends la valeur de this (CF : Variable _mainGuide) _GuideList = new List <Transform>(); //Instanciation de la guide list _curCurveDistanceList = new List <Vector3>(); // Instanciation de la list de distance sur les courbes pour chaque guide _BoidSettings = new BoidSettings[5][]; spawnSettings = flockSettings.spawnSettings; roamSettings = flockSettings.roamSettings; attackSettings = flockSettings.attackSettings; destructionSettings = flockSettings.destructionSettings; reactionSettings = flockSettings.getAwaySettings; _BoidSettings[0] = spawnSettings; _BoidSettings[1] = roamSettings; _BoidSettings[2] = attackSettings; _BoidSettings[3] = destructionSettings; _BoidSettings[4] = reactionSettings; _KoaManager = Instantiate(_KoaPrefab, transform); //Instantiate Koa _SCKoaManager = _KoaManager.GetComponent <SC_KoaManagerDisplay>(); //Récupère le Koa manager du koa instancié _SCKoaManager.Initialize(_mainGuide, flockSettings.boidSpawn, spawnSettings[0], flockSettings); //Initialise le Koa | paramètre : Guide a suivre <> Nombre de Boids a spawn <> Comportement des boids voulu _splineTab = new BezierSolution.BezierSpline[_BoidSettings.Length]; for (int i = 0; i < flockSettings.splines.Length; i++) { if (flockSettings.splines[i] != null) { _splineTab[i] = Instantiate(flockSettings.splines[i]); } } _curSpline = splineLine; bezierWalkerSpeed.SetNewSpline(_curSpline); ActivateFlock(); isActive = true; }
public void Initialize(FlockSettings curFlockSettings, Animator mainAnimator, Animator emissiveAnimator) { flockSettings = curFlockSettings; switch (flockSettings.attackType) { case FlockSettings.AttackType.Bullet: //Bullet InitBulletPool(); break; case FlockSettings.AttackType.none: //Bullet InitBulletPool(); break; case FlockSettings.AttackType.Laser: //Laser InitLaser(); break; } this.mainAnimator = mainAnimator; this.emissiveAnimator = emissiveAnimator; }
//---------------------------------------------------------------------// //---------------------------------------------------------------------// //--------------------------- UTILITIES -------------------------------// //---------------------------------------------------------------------// #region Utilites /// <summary> /// Invoque un nouveau Flock /// </summary> void SpawnNewFlock(FlockSettings flockSettings, int index, bool backup = false) { Vector3Int newSensitivity = new Vector3Int(0, 0, 0); Vector3Int baseSensitivity = new Vector3Int(0, 0, 0); switch (flockSettings.attackType) { case FlockSettings.AttackType.none: baseSensitivity = sensitivityA; break; case FlockSettings.AttackType.Bullet: baseSensitivity = sensitivityB; break; case FlockSettings.AttackType.Laser: baseSensitivity = sensitivityC; break; case FlockSettings.AttackType.Kamikaze: baseSensitivity = sensitivityD; break; } int[] tabValue = new int[3]; tabValue[0] = baseSensitivity.x; tabValue[1] = baseSensitivity.y; tabValue[2] = baseSensitivity.z; int remainingOffset = 2; for (int i = 0; i < 3; i++) { if (remainingOffset > 0) { int newValue = GetVariationSensitivity(tabValue[i]); if (newValue != tabValue[i]) { tabValue[i] = newValue; remainingOffset -= 1; } if (i == 2 && remainingOffset > 0) { i = 0; } } } newSensitivity = new Vector3Int(tabValue[0], tabValue[1], tabValue[2]); //Instantiate new flock GameObject curFlock = Instantiate(_FlockPrefab); //Add new flock to the flock list _FlockList.Add(curFlock); BezierSolution.BezierSpline spawnSpline; if (backup) { spawnSpline = spawnSplines[_curWaveSettings.backupSpawnPosition[index]]; } else { spawnSpline = spawnSplines[_curWaveSettings.initialSpawnPosition[index]]; } //Initialize flock curFlock.GetComponent <SC_FlockManager>().InitializeFlock(flockSettings, spawnSpline, newSensitivity); }
/// <summary> /// Avant le start, instanciation /// </summary> public void Initialize(Transform newGuide, int newSpawnCount, BoidSettings newSettings, FlockSettings flockSettings, Vector3Int newSensitivity) { GetReferences(); regeneration = true; curRecoveryTimer = 0; recoveryDuration = 1.5f; flockManager = newGuide.GetComponent <SC_FlockManager>(); curFlockSettings = flockSettings; spawnCount = newSpawnCount; switch (flockSettings.attackType) { case FlockSettings.AttackType.none: koaCharID = "Neutral"; type = 0; break; case FlockSettings.AttackType.Bullet: koaCharID = "Bullet"; type = 1; break; case FlockSettings.AttackType.Laser: koaCharID = "Laser"; type = 2; break; case FlockSettings.AttackType.Kamikaze: koaCharID = "Kamikaze"; type = 3; break; } koaNumID = SC_BoidPool.Instance.GetFlockID(); koaID = koaCharID + " #" + koaNumID; //Instanciation des list de Boid et de Guide _boidsTab = SC_BoidPool.Instance.GetBoid(curFlockSettings.maxBoid); _guideList = new List <Transform>(); //Récupération du comportement initial curBoidSettings = newSettings; if (SC_EnemyManager.Instance.curPhaseIndex != 0) { sensitivity = newSensitivity; } else { sensitivity = new Vector3Int(3, 5, 4); } //Ajout du premier guide a la liste _guideList.Add(newGuide); respawnTimer = 0; if (_koaPrefab != null) { _koa = NetPSpawnKoa.SpawnKoa(); _koa.transform.position = transform.position; _koa.GetComponent <SC_KoaCollider>().Initialize(this); flockManager.KoaMainAnimator = _koa.transform.GetChild(0).GetComponent <Animator>(); koaEmissiveAnimator = _koa.transform.GetChild(0).GetChild(0).GetComponent <Animator>(); flockManager.KoaEmissiveAnimator = koaEmissiveAnimator; vfx_Hit = _koa.GetComponent <ParticleSystem>(); syncVarKoa = _koa.GetComponent <SC_MoveKoaSync>(); flockManager.moveKoaSync = syncVarKoa; syncVarKoa.InitOPKoaSettings(sensitivity, flockSettings.spawnTimer, koaID, KoaLife, maxLife, type, newGuide); syncVarKoa.curboidNumber = spawnCount; syncVarKoa.curboidNumber = flockSettings.maxBoid; } }