// Start is called before the first frame update void Start() { coll = GetComponent <Collider2D>(); rb = GetComponent <Rigidbody2D>(); audioSource = Camera.main.GetComponent <AudioSource>(); startPosition = transform.position; SetAttackTrigger(0); SetBase(); if (name.Contains("Skree")) { skree = true; fp = GetComponent <FlightPattern>(); startPosition = fp.GetFirstWaypoint().position; } else if (name.Contains("Skelly")) { skelly = true; startPosition = transform.position; } else if (name.Contains("Gobby")) { gobby = true; if (isCarried) { rb.gravityScale = 0f; baseGrav = 2f; } startPosition = transform.position; } }
public override void OnObjectReuse(FlightPattern fp, int index) { sleeper = false; newPosition = this.transform.position; startTime = Time.time; cosineValue = 0.0f; sleepInterpolator = 0.0f; offsetSpawn = fp.offsetSpawn; verticalSpeed = fp.verticalSpeed; originalMagnitude = magnitude = (index % 2 != 0 && fp.alternatingMagnitude) ? fp.alternateMagnitude : fp.magnitude; originalFrequency = frequency = (index % 2 != 0 && fp.alternatingFrequency) ? fp.alternateFrequency : fp.frequency; if (fp.sleeper) { sleeper = fp.sleeper; timeToWake = fp.timeToWake; transitionSpeed = fp.transitionSpeed; wokeVerticalSpeed = fp.wokeVerticalSpeed; wokeFrequency = (index % 2 != 0 && fp.wokeAlternatingFrequency) ? fp.wokeAlternateFrequency : fp.wokeFrequency; wokeMagnitude = (index % 2 != 0 && fp.wokeAlternatingMagnitude) ? fp.wokeAlternateMagnitude : fp.wokeMagnitude; originalVerticalSpeed = verticalSpeed; } if (fp.clamp) { clamp = fp.clamp; minClamp = fp.minClampValue; maxClamp = fp.maxClampValue; } }
public void Reuse(Vector3 position, Quaternion rotation, FlightPattern flightPattern, int index) { gameObject.SetActive(true); if (hasPoolObjectComponent) { poolObject.DisableComponents(); } transform.position = position; transform.rotation = rotation; if (hasPoolObjectComponent) { poolObject.OnObjectReuse(flightPattern, index); } }
public virtual void OnObjectReuse(FlightPattern flightPattern, int index) { }
public void ReuseObject(GameObject prefab, Vector3 position, Quaternion rotation, FlightPattern flightPattern, int index) { int poolKey = prefab.GetInstanceID(); if (poolDictionary.ContainsKey(poolKey)) { ObjectInstance objectToReuse = poolDictionary[poolKey].Dequeue(); poolDictionary[poolKey].Enqueue(objectToReuse); objectToReuse.Reuse(position, rotation, flightPattern, index); } }