/* * Returns the first powerup in the list * */ public PowerupBase GetPowerUp(PowerUpsDirectoryType type) { // the Powerup we're potientially returning PowerupBase currPU = null; if (!_allowSpawn) { return(null); } // testing with custom memory manager /* * Using the passed in type, use type as index to the next available type */ PowerupMemoryList currList = null; currList = objectListMemTypes[(int)type]; if (currList != null) { currPU = objectListMemTypes[(int)type].GetNext(); if (currPU) { currPU.SetIsBackAtSpawner(false); poolUnavailablePowerUps.Add(currPU); } } return(currPU); }
private void ActivatePowerup(PowerupBase powerup, ChromieController chromieController) { if (!powerup.AllowMultiple) { foreach (PowerupBase activePowerup in _activePowerups) { if (activePowerup.GetType() == powerup.GetType()) { // stop the powerup from activate, there is alrady one active! Debug.Log("stopped powerup: " + powerup.name + " from activate!"); return; } } } PowerupBase powerupInstance = powerup.StartPowerup(chromieController); _activePowerups.Add(powerupInstance); if (_powerupActivationEffectprefab != null) { GameObject powerupEffect = Lean.LeanPool.Spawn(_powerupActivationEffectprefab, chromieController.transform.position, Quaternion.identity); powerupEffect.GetComponent<ParticleSystem>().startColor = chromieController.ChromieDefenition.ColorValue; Lean.LeanPool.Despawn(powerupEffect, 2.0f); } }
public void makeAPowerUpFree(PowerupBase powerUp) { bool flag = false; switch (powerUp.type) { case (PowerupBase.EType.BLOCK): flag = currentTutorial.freeBlocks; break; case (PowerupBase.EType.BOMB): flag = currentTutorial.freeBombs; break; case (PowerupBase.EType.DESTROY): flag = currentTutorial.freeDestroy; break; case (PowerupBase.EType.ROTATE): flag = currentTutorial.freeRotates; break; case (PowerupBase.EType.WILDCARD): flag = currentTutorial.freeWildCard; break; case (PowerupBase.EType.HINT_WORD): flag = currentTutorial.freeHint; break; } powerUp.makePowerUpFree(flag); }
/// <summary> /// Returns one of the available targets from the specified powerup type /// </summary> /// <param name="chosenPowerup">The powerup type to choose from</param> /// <returns>The chosen target</returns> private PowerupTarget ChooseRandomPowerupTarget(PowerupBase chosenPowerup) { // TODO there should be added a reference to ball, so that when lastPlayerHit is null, the player target cannot be used List <PowerupTarget> validTargets = PowerupVals.powerupTargets[chosenPowerup.powerupType]; return(validTargets[Random.Range(0, validTargets.Count)]); }
public void EndPowerup() { if (currentPowerup != null) { currentPowerup.End(); } currentPowerup = new PowerupBase.EmptyPowerup(gameObject); }
public void SetLastingPowerup(PowerupBase pwrup) { if (lastingPowerup != null) { lastingPowerup.End(); } lastingPowerup = pwrup; }
public void SetPowerup(PowerupBase pwrup) { //if(currentPowerup != pwrup) //if the powerup shouldnt be refreshed in case of timers, cooldowns and sprite updates if (currentPowerup != null) { currentPowerup.End(); } currentPowerup = pwrup; }
public void Spawn(Transform trans = null, PowerupFactory.PowerUpsDirectoryType newSpawnType = PowerupFactory.PowerUpsDirectoryType.RANDOM) { if (_active && maxSpawnCount < 0 || currSpawnCount <= maxSpawnCount) { if (PowerupFactory.GetPUF() == null) { return; } int randType = 0; if (newSpawnType == PowerupFactory.PowerUpsDirectoryType.RANDOM) //spawnRandom){ { randType = Random.Range(0, PowerupFactory.GetPUF().powerUpRootTypes.Count); } else { randType = (int)newSpawnType; //(int)spawnType; } // PowerupBase spawnPU = PowerupFactory.GetPUF().GetPowerUp((PowerupFactory.PowerUpsDirectoryType)randType); if (spawnPU) { // make sure its active spawnPU.gameObject.SetActive(true); // who ever triggers spawn can set it to a transform if (trans != null) { spawnPU.transform.position = trans.position; } else { spawnPU.transform.position = this.transform.position; } spawnPU.ProcessReleased(); if (spawnPU.GetComponent <Rigidbody>()) { float randX = Random.Range(0, spawnForceX); float randY = Random.Range(0, spawnForceY); float randZ = Random.Range(0, spawnForceZ); spawnPU.GetComponent <Rigidbody>().AddForce(randX, randY, randZ); } releasedPowerUpTime = Time.time; currSpawnCount++; } else { releasedPowerUpTime = 0; } } }
public void AddMemObject(PowerupBase obj) { // assuming the new object already has its type set // and all other default values if (obj) { listOfRootType.Add(obj); } // print ("MemoryList " + listOfRootType.Count); }
void GetPU() { _powerup = IconLocTarget.GetComponent <PowerupBase>(); if (_powerup != null) { _powerUpSpriteName = _powerup.PowerUpTextureName; mySprite.spriteName = _powerUpSpriteName; isFullyInit = true; } }
public void ProbabilityDrop(Vector3 position) { increasingProbability++; if (Random.Range(0, 100) < startingProbability + increasingProbability) { increasingProbability = 0; GameObject go = Instantiate(availablePowerUpsPrefabs[SelectRandomPowerUp()], transform); PowerupBase powerUp = go.GetComponent <PowerupBase>(); powerUp.Drop(position); } }
private void SpawnPowerup() // TODO this should be broken up into more methods { while (true) { // Stop if no powerups can be spawned if (unavailablePowerups.Count == enabledPowerups.Length) { unavailablePowerups.Clear(); break; } // Determine powerup type and spawn location Vector2 spawnLocation = Random.insideUnitCircle * spawnRadius + levelCenter; // TODO implement system so that powerups do not spawn on top of one another GameObject gameObjToSpawn = unavailablePowerups.Count == 0 ? ChooseRandomPowerupType() : ChooseRandomPowerupType(unavailablePowerups); PowerupBase powerupToSpawn = gameObjToSpawn.GetComponent <PowerupBase>(); // Check if powerup can be spawned in current conditions. Continue if condition is not met and add to unavailable switch (powerupToSpawn.spawnConditions) { case SpawnConditions.NotInCircle: if (InGameManager.isCircle || InGameManager.shouldLerpToCircle) { unavailablePowerups.Add(powerupToSpawn.powerupType); continue; } break; case SpawnConditions.NeedsMultipleBalls: if (GameObject.FindGameObjectsWithTag("Ball").Length < 2) { unavailablePowerups.Add(powerupToSpawn.powerupType); continue; } break; } powerupToSpawn.target = ChooseRandomPowerupTarget(powerupToSpawn); // Check for spawnlimit on selected powerup type if (GameObject.FindGameObjectsWithTag("Powerup").Count(o => o.GetComponent <PowerupBase>()?.powerupType == powerupToSpawn.powerupType) < powerupToSpawn.spawnLimit) { unavailablePowerups.Clear(); StartCoroutine(TryDestroyPowerup(powerupToSpawn.despawnTime, Instantiate(gameObjToSpawn, spawnLocation, Quaternion.identity))); } else { unavailablePowerups.Add(powerupToSpawn.powerupType); continue; } break; } }
void CheckPowerupAvailability() { // for now, go through the list of unavailable for (int i = 0; i < poolUnavailablePowerUps.Count; i++) { PowerupBase currPu = poolUnavailablePowerUps[i]; if (currPu.IsBackAtSpawner()) { // then the PU needs to go back into the available pool poolUnavailablePowerUps.Remove(currPu); //poolAvailablePowerUps.Add(currPu); } } }
public void ConsumePowerup(PowerupBase powerup) { // Duration zero powerups don't need to be added to the list since they'd just get // popped instantly powerup.ApplyStart(this); if (powerup.GetDuration() != 0f) { powerups.Add(new PowerupRecord(powerup)); } else { // Since it's "popped instantly" powerup.ApplyEnd(this); } }
public void activatePowerUp(PowerupBase.EType wichOne, bool canUse) { if (allowPowerUps) { powerup = getPowerupByType(wichOne); if (powerup == null) { cancelPowerup(); } else { powerup.activate(canUse); } } }
public void EndAllPowerups() { if (currentPowerup != null) { currentPowerup.End(); } if (lastingPowerup != null) { lastingPowerup.End(); } currentPowerup = new PowerupBase.EmptyPowerup(gameObject); lastingPowerup = new PowerupBase.EmptyPowerup(gameObject); BombExplode BE = GetComponentInChildren <BombExplode>(); if (BE) { GameObject.Destroy(BE.gameObject); } }
public void CreateMemObjects(int count, PowerupBase prefab, Transform parent) { for (int i = 0; i < count; i++) { PowerupBase newPU = MonoBehaviour.Instantiate(prefab, Vector3.zero, Quaternion.identity) as PowerupBase; // makes sure the Powerup Starts in active newPU.gameObject.SetActive(false); // set its type and parent newPU.type = prefab.type; newPU.transform.parent = parent; listOfRootType.Add(newPU); //objectListMemTypes[i].AddMemObject(newPU)/ } }
private void Awake() { if (powerupsActivatedState.Count > 0) { return; } // Add all targets to PowerupVals foreach (GameObject powerupObj in powerups) { PowerupBase powerup = powerupObj.GetComponent <PowerupBase>(); powerupTargets.Add(powerup.powerupType, powerup.validTargets.ToList()); } foreach (Powerups item in Enum.GetValues(typeof(Powerups))) { // All powerups are enabled by default powerupsActivatedState.Add(item, true); } }
public PowerupBase GetNext() { // pop the next one // TODO: if we have none we have to make one or tell the factory to. PowerupBase nextPU = null; for (int i = 0; i < listOfRootType.Count; i++) { nextPU = listOfRootType[i]; if (nextPU.IsBackAtSpawner()) { return(nextPU); } } // if (listOfRootType.Count > 0){ // System.Predicate<PowerupRoot> puPredicate; // //puPredicate = new System.Predicate<PowerupRoot>(); // nextPU = listOfRootType[0]; // } return(null); }
private void OnPowerupStartedHandler(PowerupBase powerup) { }
public void PowerupStopped(PowerupBase powerup) { if (OnPowerupStopped != null) { OnPowerupStopped(powerup); } }
private void OnPowerupStoppedHandler(PowerupBase powerup) { if (_activePowerups.Contains(powerup)) { _activePowerups.Remove(powerup); } }
public PowerupRecord(PowerupBase powerup) { this.powerup = powerup; pickupTime = Time.time; }
public static void SendPowerupStopped(PowerupBase powerup) { GameplayEventsDispatcher.Instance.PowerupStopped(powerup); }