1234567891011121314151617181920212223242526272829303132 |
- using UnityEngine;
- using System.Collections;
- public class AnnouncementManager : MonoBehaviour
- {
- public Transform announcementsAnchor;
- public PoolObject announcementPrefab;
- Pool _announcementsPool;
- void Awake()
- {
- _announcementsPool = Pool.Create(announcementPrefab, 5);
- NotificationCenter.AddListener(OnAnnouncement, NotificationType.Announcement);
- }
- void OnDestroy()
- {
- NotificationCenter.RemoveListener(OnAnnouncement, NotificationType.Announcement);
- }
- void OnAnnouncement(Notification note)
- {
- string text = (string)note.data;
- TextAnnouncement announcement = _announcementsPool.Spawn().GetComponent<TextAnnouncement>();
- Transform hitPointsBonusTransform = announcement.transform;
- hitPointsBonusTransform.parent = announcementsAnchor;
- announcement.SetText(text);
- hitPointsBonusTransform.localPosition = Vector3.zero;
- }
- }
|