コード例 #1
0
ファイル: TargetSpawner.cs プロジェクト: arraz610/FPSproject
    // Start is called before the first frame update
    void Awake()
    {
        path.Init(transform);

        m_SpawnQueue = new Queue <SpawnQueueElement>();

        foreach (var e in spawnEvents)
        {
            for (int i = 0; i < e.count; ++i)
            {
                SpawnQueueElement element = new SpawnQueueElement()
                {
                    obj           = Instantiate(e.targetToSpawn),
                    remainingTime = e.timeBetweenSpawn
                };
                element.rb     = element.obj.GetComponent <Rigidbody>();
                element.target = element.obj.GetComponentInChildren <Target>();
                element.obj.SetActive(false);
                element.obj.transform.position = transform.position;
                element.obj.transform.rotation = transform.rotation;

                path.InitData(element.pathData);

                m_SpawnQueue.Enqueue(element);
            }
        }

        if (m_SpawnQueue.Count == 0)
        {
            Destroy(gameObject);
        }
        else
        {
            m_ActiveElements = new List <SpawnQueueElement>();
            Dequeue();
        }
    }
コード例 #2
0
 void Start()
 {
     path.Init(transform);
     path.InitData(pathData);
 }