Example #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>();
        }
Example #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>();
 }
Example #3
0
        private void Awake()
        {
            // init cutter
            cutter = new Core.MeshCutter();
            cutter.Init(512, 512);
            UnityEngine.Random.seed = System.DateTime.Now.Millisecond;

            settings= new ExploderSettings(this);

            var use2d = settings.Use2DCollision;

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

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

            if (settings.ExplodeSelf)
            {
                if (settings.DontUseTag)
                {
                    gameObject.AddComponent<Explodable>();
                }
                else
                {
                    gameObject.tag = "Exploder";
                }
            }

            state = State.DryRun;

            PreAllocateBuffers();

            state = State.None;

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

                if (!audioSource)
                {
                    audioSource = gameObject.AddComponent<AudioSource>();
                }
            }
        }
Example #4
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>();
                }
            }
        }
Example #5
0
    private void Start()
    {
        // init cutter
        cutter = new MeshCutter();
        cutter.Init(512, 512);
        UnityEngine.Random.seed = System.DateTime.Now.Millisecond;

        bool use2d = false;

#if PHYSICS_2D
        use2d = Use2DCollision;
#endif

        // init pool
        FragmentPool.Instance.Allocate(FragmentPoolSize, MeshColliders, use2d);
        FragmentPool.Instance.SetDeactivateOptions(DeactivateOptions, FadeoutOptions, DeactivateTimeout);
        FragmentPool.Instance.SetExplodableFragments(ExplodeFragments, DontUseTag);
        FragmentPool.Instance.SetFragmentPhysicsOptions(FragmentOptions);
        timer = new Stopwatch();

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

        if (DontUseTag)
        {
            gameObject.AddComponent<Explodable>();
        }
        else
        {
            gameObject.tag = "Exploder";
        }

        state = State.DryRun;

        PreAllocateBuffers();

        state = State.None;
    }