public void FireCannon(AlertAnswer answer) { GameObject message = Instantiate(messagePrefab, transform.position + -transform.right * 1.5f, Quaternion.LookRotation(transform.forward)); message.GetComponent <MessageBehaviour>().answer = answer; CanonAudioSource.Play(); }
private float animOffset = 0.05f; //value in animation "time" in between two cans = distance between cans public void AddCannister(AlertAnswer message) { Cannister newCan = Instantiate(cannisterPrefab, this.transform, true); float canPosition = 0.6f; if (visibleCannisterList.Count > 0) { Cannister previousCan = visibleCannisterList[visibleCannisterList.Count - 1]; float slidePos = previousCan.slidePos - animOffset; if (previousCan.goingDown > 0) { slidePos = previousCan.goingDownStart + animOffset * previousCan.goingDown - animOffset; } canPosition = Mathf.Min(0.6f - animOffset, slidePos); } newCan.Initialize(message, canPosition); visibleCannisterList.Add(newCan); }
public void Initialize(AlertAnswer a, float n) { message = a; slidePos = n; }