예제 #1
0
        public void Initialize(ExploderObject exploder)
        {
            if (initialized)
            {
                return;
            }

            initialized = true;
            parameters  = new ExploderParams(exploder);

            // init pool
            FragmentPool.Instance.Reset(parameters);
            frameWatch     = new Stopwatch();
            explosionWatch = new Stopwatch();

            crackManager = new CrackManager(this);

            bakeSkinManager = new BakeSkinManager(this);

            //
            // init queue
            //
            queue = new ExploderQueue(this);

            //
            // init tasks
            //
            tasks = new ExploderTask[(int)TaskType.TaskMax];

            tasks[(int)TaskType.Preprocess] = new Preprocess(this);

#if DISABLE_MULTITHREADING
            tasks[(int)TaskType.ProcessCutter] = new CutterST(this);
#else
            if (parameters.ThreadOptions == ExploderObject.ThreadOptions.Disabled)
            {
                tasks[(int)TaskType.ProcessCutter] = new CutterST(this);
            }
            else
            {
                tasks[(int)TaskType.ProcessCutter] = new CutterMT(this);
            }
#endif

            tasks[(int)TaskType.IsolateMeshIslands] = new IsolateMeshIslands(this);
            tasks[(int)TaskType.PostprocessExplode] = new PostprocessExplode(this);
            tasks[(int)TaskType.PostprocessCrack]   = new PostprocessCrack(this);

            PreAllocateBuffers();

            audioSource = gameObject.AddComponent <AudioSource>();
        }
예제 #2
0
 public void Initialize(ExploderObject exploder)
 {
     if (this.initialized)
     {
         return;
     }
     this.initialized = true;
     this.parameters  = new ExploderParams(exploder);
     FragmentPool.Instance.Reset(this.parameters);
     this.frameWatch      = new Stopwatch();
     this.explosionWatch  = new Stopwatch();
     this.crackManager    = new CrackManager(this);
     this.bakeSkinManager = new BakeSkinManager(this);
     this.queue           = new ExploderQueue(this);
     this.tasks           = new ExploderTask[6];
     this.tasks[1]        = (ExploderTask) new Preprocess(this);
     this.tasks[2]        = this.parameters.ThreadOptions != ExploderObject.ThreadOptions.Disabled ? (ExploderTask) new CutterMT(this) : (ExploderTask) new CutterST(this);
     this.tasks[3]        = (ExploderTask) new IsolateMeshIslands(this);
     this.tasks[4]        = (ExploderTask) new PostprocessExplode(this);
     this.tasks[5]        = (ExploderTask) new PostprocessCrack(this);
     this.PreAllocateBuffers();
     this.audioSource = (AudioSource)((Component)this).get_gameObject().AddComponent <AudioSource>();
 }
예제 #3
0
        public void Initialize(ExploderObject exploder)
        {
            if (initialized)
            {
                return;
            }

            initialized = true;
            parameters  = new ExploderParams(exploder);

            // init pool
            FragmentPool.Instance.Allocate(parameters.FragmentPoolSize, parameters.MeshColliders, parameters.Use2DCollision, parameters.FragmentPrefab);
            FragmentPool.Instance.SetDeactivateOptions(parameters.DeactivateOptions, parameters.FadeoutOptions, parameters.DeactivateTimeout);
            FragmentPool.Instance.SetExplodableFragments(parameters.ExplodeFragments, parameters.DontUseTag);
            FragmentPool.Instance.SetFragmentPhysicsOptions(parameters.FragmentOptions, parameters.Use2DCollision);
            FragmentPool.Instance.SetSFXOptions(parameters.SFXOptions);
            frameWatch     = new Stopwatch();
            explosionWatch = new Stopwatch();

            crackManager = new CrackManager();

            //
            // init queue
            //
            queue = new ExploderQueue(this);

            //
            // init tasks
            //
            tasks = new ExploderTask[(int)TaskType.TaskMax];

            tasks[(int)TaskType.Preprocess] = new Preprocess(this);

#if DISABLE_MULTITHREADING
            tasks[(int)TaskType.ProcessCutter] = new CutterST(this);
#else
            if (parameters.ThreadOptions == ExploderObject.ThreadOptions.Disabled)
            {
                tasks[(int)TaskType.ProcessCutter] = new CutterST(this);
            }
            else
            {
                tasks[(int)TaskType.ProcessCutter] = new CutterMT(this);
            }
#endif

            tasks[(int)TaskType.IsolateMeshIslands] = new IsolateMeshIslands(this);
            tasks[(int)TaskType.PostprocessExplode] = new PostprocessExplode(this);
            tasks[(int)TaskType.PostprocessCrack]   = new PostprocessCrack(this);
            tasks[(int)TaskType.PartialSeparator]   = new PartialSeparator(this);

            PreAllocateBuffers();

            if (parameters.SFXOptions.ExplosionSoundClip)
            {
                audioSource = gameObject.GetComponent <AudioSource>();

                if (!audioSource)
                {
                    audioSource = gameObject.AddComponent <AudioSource>();
                }
            }
        }