private void AddBodyButton_Click(object sender, EventArgs e)
        {
            CelestialBody body;
            double        distance = double.Parse(SunDistanceBox.Text);

            // Instantiates a new CelestialBody type based off of the selection in the new type box
            // then adds the body to the bodies list
            if (NewTypeBox.SelectedItem.ToString() == "Star")
            {
                var type = (StarType)Enum.Parse(typeof(StarType), NewStarTypeBox.Text);
                body = new Star(NameBox.Text, distance, type);
                bodiesList.Add(body);
            }
            else if (NewTypeBox.SelectedItem.ToString() == "Planet")
            {
                body = new Planet(NameBox.Text, distance, (int)MoonsNumBox.Value);
                bodiesList.Add(body);
            }
            else if (NewTypeBox.SelectedItem.ToString() == "Nebula")
            {
                var type = (Nebula.Constellation)Enum.Parse(typeof(Nebula.Constellation), StarGroupBox.Text);
                body = new Nebula(NameBox.Text, distance, type);
                bodiesList.Add(body);
            }
        }
Beispiel #2
0
        public async Task StopJob_StopStartedJob_ShouldPurgeQueue()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);
            Nebula.RegisterJobProcessor(typeof(FirstJobProcessor), typeof(FirstJobStep));

            var jobManager = Nebula.GetJobManager();
            var jobId      = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                            configuration : new JobConfigurationData
            {
                QueueTypeName = QueueType.InMemory
            });

            var queue = Nebula.JobStepSourceBuilder.BuildInMemoryJobQueue <FirstJobStep>(jobId);

            await jobManager.StartJob(Tenant.Id, jobId);

            await queue.Enqueue(new FirstJobStep { Number = 1 });

            var initialQueueLength = await queue.GetQueueLength();

            await jobManager.StopJob(Tenant.Id, jobId);

            var afterStopQueueLength = await queue.GetQueueLength();

            Assert.AreEqual(1, initialQueueLength);
            Assert.AreEqual(0, afterStopQueueLength);
        }
Beispiel #3
0
        public static CelestialBody GenerateNebula(PhContext db, int distance, Star mainStar)
        {
            var position = new Position();
            // Check for existing Objects that collide
            var    collision = true;
            var    radius    = Utility.GetOrbitalRadius(distance);
            double angle     = Utility.RandomNumber(0, 360);

            while (collision)
            {
                position = Utility.GetOrbitalObjectPosition(radius, angle, new Position()
                {
                    X = 0, Y = 0
                }, 1);
                collision = CheckforSystemCollision(position, mainStar);
            }

            Nebula nebula = db.CelestialBodySet.Create <Nebula>();

            nebula.Star      = mainStar;
            nebula.Type      = GetNebulaType();
            nebula.Name      = GetSystemBodyName(distance, mainStar.Name);
            nebula.Dimension = GetBodyDimension();
            nebula.Angle     = angle;
            nebula.Radius    = radius;

            return(nebula);
        }
        public async Task StartJob_EnqueueOneItem_QueueShouldBeEmpty()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);
            Nebula.RegisterJobProcessor(typeof(FirstJobProcessor), typeof(FirstJobStep));

            var jobManager = Nebula.GetJobManager();
            var jobId      = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                            configuration : new JobConfigurationData {
                QueueTypeName = QueueType.InMemory
            });

            var queue = Nebula.JobStepSourceBuilder.BuildInMemoryJobQueue <FirstJobStep>(jobId);
            await queue.Enqueue(new FirstJobStep { Number = 1 });

            var initialLength = await queue.GetQueueLength();

            await jobManager.StartJob(Tenant.Id, jobId);


            var processedLength = await queue.GetQueueLength();

            var jobRunnerManager = Nebula.ComponentContext.GetComponent <IJobRunnerManager>();

            Assert.IsTrue(jobRunnerManager.IsJobRunnerStarted(jobId));
            Assert.AreEqual(1, initialLength);
            Assert.AreEqual(0, processedLength);
        }
Beispiel #5
0
        public async Task QueueType_CreateCustome_Success()
        {
            //create sample job with custom queue
            Nebula.RegisterJobQueue(typeof(FirstJobQueue <>), QueueTypes.FirstJobQueue);

            var jobManager = Nebula.GetJobManager();
            var jobStore   = Nebula.ComponentContext.GetComponent <IJobStore>();

            var jobId = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(
                string.Empty, "sample-job", nameof(FirstJobStep), new JobConfigurationData
            {
                MaxBatchSize = 100,
                MaxConcurrentBatchesPerWorker = 5,
                IsIndefinite = true,
                MaxBlockedSecondsPerCycle = 300,
                QueueTypeName             = QueueTypes.FirstJobQueue
            });

            var jobData = await jobStore.LoadFromAnyTenant(jobId);

            var jobQueue =
                Nebula.JobStepSourceBuilder.BuildJobStepSource <FirstJobStep>(jobData.Configuration.QueueTypeName);

            Assert.AreEqual(typeof(FirstJobQueue <FirstJobStep>), jobQueue.GetType());
        }
Beispiel #6
0
        public async Task StopJob_NotDefinedJob_InvalidJobIdErrorKey()
        {
            var result = await Nebula.GetJobManager().StopJob(Tenant.Id, "jobId");

            Assert.IsFalse(result.Success);
            Assert.AreEqual(ErrorKeys.InvalidJobId, result.Errors.FirstOrDefault()?.ErrorKey);
        }
Beispiel #7
0
        public async Task StopJob_StopStartedJob_CheckJobState()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);
            Nebula.RegisterJobProcessor(typeof(FirstJobProcessor), typeof(FirstJobStep));

            var jobManager = Nebula.GetJobManager();
            var jobId      = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                            configuration : new JobConfigurationData
            {
                QueueTypeName = QueueType.InMemory
            });

            var queue = Nebula.JobStepSourceBuilder.BuildInMemoryJobQueue <FirstJobStep>(jobId);
            await queue.Enqueue(new FirstJobStep { Number = 1 });

            await jobManager.StartJob(Tenant.Id, jobId);

            await jobManager.StopJob(Tenant.Id, jobId);

            var jobStore = Nebula.ComponentContext.GetComponent(typeof(IJobStore)) as IJobStore;
            var job      = await jobStore.Load(Tenant.Id, jobId);

            Assert.IsNotNull(job);
            Assert.AreEqual(JobState.Stopped, job.Status.State);
        }
Beispiel #8
0
        public async Task StopJob_InCompletePreprocessor_JobActionHasPreprocessorDependencyErrorKey()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);
            Nebula.RegisterJobProcessor(typeof(FirstJobProcessor), typeof(FirstJobStep));

            var jobManager        = Nebula.GetJobManager();
            var preprocessorJobId = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                                   configuration : new JobConfigurationData
            {
                QueueTypeName = QueueType.InMemory
            });

            var jobId = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                       configuration : new JobConfigurationData
            {
                QueueTypeName = QueueType.InMemory
            });

            await jobManager.AddPredecessor(Tenant.Id, jobId, preprocessorJobId);

            var result = await jobManager.StopJob(Tenant.Id, jobId);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(ErrorKeys.JobActionHasPreprocessorDependency, result.Errors.FirstOrDefault()?.ErrorKey);
        }
Beispiel #9
0
        public override bool Convert(ConvertOperation convert)
        {
            if (convert.Result.OfType <ICmpRenderer>().Any() || convert.Result.OfType <Nebula>().Any())
            {
                return(false);
            }
            List <object>     results   = new List <object>();
            List <NebulaType> availData = convert.Perform <NebulaType>().ToList();

            foreach (var nebula in availData)
            {
                GameObject gameobj    = convert.Result.OfType <GameObject>().FirstOrDefault();
                Nebula     background = convert.Result.OfType <Nebula>().FirstOrDefault();

                if (background == null)
                {
                    background         = new Nebula();
                    background.Nebulae = new ContentRef <NebulaType>[] { nebula };
                    results.Add(background);
                }
                convert.SuggestResultName(background, nebula.Name);
                convert.MarkObjectHandled(nebula);
            }
            convert.AddResult(results);
            return(false);
        }
Beispiel #10
0
    void Update()
    {
        Nebula prefabNebula = (Resources.Load("Prefabs/Nebula") as GameObject).GetComponent <Nebula>();
        float  scale        = (float)this.GetComponent <Damageable>().GetCurrentHealth / this.GetComponent <Damageable>().GetMaxHealth;

        this.transform.localScale = prefabNebula.transform.localScale * scale;
    }
Beispiel #11
0
        public async Task PurgeQueue_CustomeJobQueueDefinedInJob_shouldBeEmpty()
        {
            //create sample job with custom queue
            var jobManager = Nebula.GetJobManager();
            var jobStore   = Nebula.ComponentContext.GetComponent <IJobStore>();

            Nebula.RegisterJobQueue(typeof(FirstJobQueue <FirstJobStep>), QueueTypes.FirstJobQueue);

            var jobId = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(
                string.Empty, "sample-job", nameof(FirstJobStep), new JobConfigurationData
            {
                MaxBatchSize = 100,
                MaxConcurrentBatchesPerWorker = 5,
                IsIndefinite = true,
                MaxBlockedSecondsPerCycle = 300,
                QueueTypeName             = QueueTypes.FirstJobQueue
            });

            var jobData = await jobStore.LoadFromAnyTenant(jobId);

            var jobQueue =
                Nebula.JobStepSourceBuilder.BuildJobStepSource <FirstJobStep>(jobData.Configuration.QueueTypeName,
                                                                              jobData.JobId) as IJobQueue <FirstJobStep>;

            await jobQueue.Enqueue(new FirstJobStep());

            await jobQueue.Purge();

            var queueLeghnt = await jobQueue.GetQueueLength();

            Assert.AreEqual(0, queueLeghnt);
        }
Beispiel #12
0
 public override void AddRecipes()
 {
     Nebula.AddRecipes(this);
     Solar.AddRecipes(this);
     Stardust.AddRecipes(this);
     Vortex.AddRecipes(this);
 }
        public void JobStepSourceBuilder_GetInlineJobQueue_TypeShouldBeCorrect()
        {
            Nebula.RegisterJobProcessor(typeof(FirstJobProcessor), typeof(FirstJobStep));
            var queue = Nebula.JobStepSourceBuilder.BuildInlineJobQueue <FirstJobStep>(_jobId);

            Assert.IsNotNull(queue);
            Assert.AreEqual(typeof(InlineJobQueue <FirstJobStep>), queue.GetType());
        }
Beispiel #14
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        neb = target as Nebula;

        EGL.Space();
        EGL.FloatField("Radius", neb.dimensions.magnitude);
    }
        protected override void ConfigureNebula()
        {
            RegisterMockJobStore();
            RegisterMockBackgroundTaskScheduler();
            RegisterMockRedisManager();

            Nebula.RegisterJobQueue(typeof(DelayedJobQueue <>), QueueType.Delayed);
        }
Beispiel #16
0
    void Awake()
    {
        refCam          = Camera.main;
        refCamNebula    = refCam.GetComponent <NebulaCameraFog>();
        refCamTransform = refCam.transform;

        parentNebula = GetComponent <Nebula>();
    }
Beispiel #17
0
        public async Task StopJob_StoppedJob_Success()
        {
            await AddJobToDb(JobState.Stopped);

            var result = await Nebula.GetJobManager().StopJob(Tenant.Id, _jobId);

            Assert.IsTrue(result.Success);
        }
Beispiel #18
0
        protected override void ConfigureNebula()
        {
            RegisterMockRedisManager();
            RegisterMockJobStore();

            Nebula.RegisterJobQueue(typeof(FirstJobQueue <FirstJobStep>), nameof(FirstJobStep));
            Nebula.RegisterJobQueue(typeof(SecondJobQueue <SecondJobStep>), nameof(SecondJobStep));
        }
Beispiel #19
0
        public async Task StopJob_ExpiredJob_InvalidJobStateErrorKey()
        {
            await AddJobToDb(JobState.Expired);

            var result = await Nebula.GetJobManager().StopJob(Tenant.Id, _jobId);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(ErrorKeys.InvalidJobState, result.Errors.FirstOrDefault()?.ErrorKey);
        }
Beispiel #20
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (this.shooter == null)
        {
            return;
        }
        Damageable        damageable         = other.gameObject.GetComponent <Damageable>();
        Rock              rock               = other.gameObject.GetComponent <Rock>();
        UFO               ufo                = other.gameObject.GetComponent <UFO>();
        Nebula            nebula             = other.gameObject.GetComponent <Nebula>();
        ControlledShooter controlled_shooter = this.shooter.gameObject.GetComponent <ControlledShooter>();

        /// The projectile collided with something!
        if (damageable != null)
        {
            damageable.Damage(this.damage);
            if (rock != null)
            {
                if (controlled_shooter != null && controlled_shooter.GetComponent <Scored>() != null)
                {
                    uint value = 0;
                    switch (rock.rock_type)
                    {
                    case Rock.RockType.LARGE:
                        value = controlled_shooter.score_per_large_asteroid_kill;
                        break;

                    case Rock.RockType.MEDIUM:
                        value = controlled_shooter.score_per_medium_asteroid_kill;
                        break;

                    case Rock.RockType.SMALL:
                        value = controlled_shooter.score_per_small_asteroid_kill;
                        break;
                    }
                    controlled_shooter.GetComponent <Scored>().score += value;
                }
            }
            else if (ufo != null && controlled_shooter != null)
            {
                Scored scored = controlled_shooter.GetComponent <Scored>();
                if (scored != null)
                {
                    scored.score += ufo.score_on_hit;
                    if (!ufo.damageable.IsAlive())
                    {
                        controlled_shooter.GetComponent <Scored>().score += ufo.score_on_kill;
                    }
                }
            }
            if (nebula == null)
            {
                Destroy(this.gameObject);
            }
        }
    }
Beispiel #21
0
        public void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            Nebula.RegisterJobQueue(typeof(FirstJobQueue <FirstJobStep>), nameof(FirstJobStep));
            Nebula.RegisterJobQueue(typeof(SecondJobQueue <SecondJobStep>), nameof(SecondJobStep));
            _initialized = true;
        }
Beispiel #22
0
        public void JobProcessor_Instance_Registration_ShouldReturnSameInstances()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);

            Nebula.RegisterJobProcessor(typeof(TransientProcessor1), typeof(FirstJobStep));

            var jobProcessor1 = Nebula.ComponentContext.GetComponent <IJobProcessor <FirstJobStep> >();
            var jobProcessor2 = Nebula.ComponentContext.GetComponent <IJobProcessor <FirstJobStep> >();

            Assert.AreEqual(jobProcessor2, jobProcessor1);
        }
        public async Task CreateJob_jobWithoutJobId_ShouldHaveValue()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);

            var jobManager = Nebula.GetJobManager();
            var jobId      = await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                                            configuration : new JobConfigurationData {
                QueueTypeName = QueueType.InMemory
            });

            Assert.IsTrue(!jobId.IsNullOrWhitespace());
        }
Beispiel #24
0
        public void JobProcessor_InstanceProvider_ReturnsInterface_ShouldReturnDifferentInstances()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);

            Nebula.RegisterJobProcessor(() => _sp.GetService <IJobProcessor <FirstJobStep> >(),
                                        typeof(FirstJobStep));

            var jobProcessor1 = Nebula.ComponentContext.GetComponent <IJobProcessor <FirstJobStep> >();
            var jobProcessor2 = Nebula.ComponentContext.GetComponent <IJobProcessor <FirstJobStep> >();

            Assert.AreNotEqual(jobProcessor2, jobProcessor1);
        }
        public async Task CreateJob_ZeroThrottledMaxBurstSize_ExceptionThrown()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);

            var jobManager = Nebula.GetJobManager();
            await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                           configuration : new JobConfigurationData
            {
                ThrottledMaxBurstSize = JobConfigurationDefaultValues.MinThrottledMaxBurstSize,
                QueueTypeName         = QueueType.InMemory
            });
        }
        public async Task CreateJob_ExpiredJob_ExceptionThrown()
        {
            Nebula.RegisterJobQueue(typeof(InMemoryJobQueue <FirstJobStep>), QueueType.InMemory);

            var jobManager = Nebula.GetJobManager();
            await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                           configuration : new JobConfigurationData
            {
                ExpiresAt     = DateTime.Now.AddDays(-1),
                QueueTypeName = QueueType.InMemory
            });
        }
Beispiel #27
0
        public async Task QueueType_notDefined_ExceptionThrown()
        {
            var jobManager = Nebula.GetJobManager();

            await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(
                string.Empty, "sample-job", nameof(FirstJobStep), new JobConfigurationData
            {
                MaxBatchSize = 100,
                MaxConcurrentBatchesPerWorker = 5,
                IsIndefinite = true,
                MaxBlockedSecondsPerCycle = 300
            });
        }
        protected override void ConfigureNebula()
        {
            Nebula.KafkaConfig = new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("bootstrap.servers", "172.30.3.59:9101"),
                new KeyValuePair <string, object>("group.id", "testGroup"),
                new KeyValuePair <string, object>("auto.offset.reset", "earliest"),
                new KeyValuePair <string, object>("queue.buffering.max.ms", 1),
                new KeyValuePair <string, object>("batch.num.messages", 1),
                new KeyValuePair <string, object>("fetch.wait.max.ms", 5000)
            };

            Nebula.RegisterJobQueue(typeof(KafkaJobQueue <>), QueueType.Kafka);
        }
Beispiel #29
0
        public async Task StartJob_InvalidJobState_ExceptionThrown()
        {
            var jobId    = "jobId";
            var jobStore = Nebula.ComponentContext.GetComponent(typeof(IJobStore)) as IJobStore;
            await jobStore.AddOrUpdateDefinition(new JobData
            {
                TenantId = Tenant.Id,
                JobId    = jobId,
                Status   = new JobStatusData {
                    State = JobState.Failed
                }
            });

            await Nebula.GetJobManager().StartJob(Tenant.Id, jobId);
        }
        public async Task CreateJob_NewJob_QueueExistenceCheck()
        {
            Nebula.RegisterJobQueue(typeof(FirstJobQueue <FirstJobStep>), QueueTypes.FirstJobQueue);

            var jobManager = Nebula.GetJobManager();
            await jobManager.CreateNewJobOrUpdateDefinition <FirstJobStep>(Tenant.Id,
                                                                           configuration : new JobConfigurationData {
                QueueTypeName = QueueTypes.FirstJobQueue
            });

            var queue = Nebula.JobStepSourceBuilder.BuildJobStepSource <FirstJobStep>(QueueTypes.FirstJobQueue) as FirstJobQueue <FirstJobStep>;

            Assert.IsNotNull(queue);
            Assert.IsTrue(queue.QueueExistenceChecked);
        }
Beispiel #31
0
    private static void CloudyNebula( Nebula neb,bool autoCompute)
    {
        // Variation
        if (neb.layers.Count==2){

            // Variation
            neb.layers[0].fractal.seed = (EditorGUILayout.Slider("Variation",neb.layers[0].fractal.seed,1,1000));
            neb.layers[1].fractal.seed = neb.layers[0].fractal.seed;

            GuiTools.DrawSeparatorLine( 30);

            // Color
            neb.layers[0].startColor = EditorGUILayout.ColorField( "Color 1",neb.layers[0].startColor);
            neb.layers[0].endColor = EditorGUILayout.ColorField( "Color 2",neb.layers[0].endColor);

            EditorGUILayout.Space();

            // Mixing color;
            neb.layers[0].fractal.zoom = EditorGUILayout.Slider("Mixing colors",neb.layers[0].fractal.zoom,1,100);
            neb.power = EditorGUILayout.Slider("Power",neb.power,0f,5f);

            GuiTools.DrawSeparatorLine( 30);

            // Overlay
            GUI.backgroundColor = new Color(33f/255f,180f/255f,252f/255f);
            NebulaLayer.OverlayStyle overlay = (NebulaLayer.OverlayStyle)EditorGUILayout.EnumPopup( "Overlay style",neb.layers[1].overlay );
            if (neb.layers[1].overlay!=overlay){
                neb.layers[1].overlay = overlay;
                autoCompute = true;
            }
            GUI.backgroundColor = Color.white;

            // alpha power
            neb.layers[1].threshold = EditorGUILayout.Slider("Alpha power",neb.layers[1].threshold,0f,1f);

            switch (neb.layers[1].overlay){
                case NebulaLayer.OverlayStyle.Style1:
                    neb.layers[1].blend = TextureTools.BlendingMode.Mask;
                    //scale
                    neb.layers[1].fractal.zoom = EditorGUILayout.Slider("scale",neb.layers[1].fractal.zoom-29,0f,300f)+29;
                    // cutout
                    neb.layers[1].fractal.threshold = EditorGUILayout.Slider("Cutout",neb.layers[1].fractal.threshold*-1,0f,1f)*-1;
                    break;
                case NebulaLayer.OverlayStyle.Style2:
                    neb.layers[1].blend = TextureTools.BlendingMode.Alpha;
                    //scale
                    neb.layers[1].fractal.zoom = EditorGUILayout.Slider("scale",neb.layers[1].fractal.zoom-29,0f,300f)+29;
                    // cutout
                    neb.layers[1].fractal.threshold = EditorGUILayout.Slider("Cutout",neb.layers[1].fractal.threshold,0f,1f);
                    break;
            }

            EditorGUILayout.Space();

            if (GUI.changed){
                buttonCloudy=18;
                //SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(14);
            if (GUILayout.Button(new GUIContent( " Render",CosmosInspector.GetIcon(buttonCloudy))) || autoCompute){
                SpaceBox.instance.starfield.Render(true);
                RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
                SpaceBox.instance.UpdateNebulaSkyBox();
                buttonCloudy = 16;
                SpaceBox.instance.nebulaNeed2Save = true;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }
    }
Beispiel #32
0
    private static Color[] RenderNebulaFace(Color[] dest,Nebula neb,Fractal.Face face,int size)
    {
        Color[] source = neb.Render(face,size);

        for(int i=0;i<dest.Length;i++){

            switch (neb.nebulaMode){
            case Nebula.NebulaMode.Color:
                dest[i] += source[i];
                break;
            case Nebula.NebulaMode.ColorMask:
                    float grey  = (source[i].r +  source[i].g + source[i].b)/3f;
                    dest[i] = dest[i] * (Color.white - new Color(grey,grey,grey)*2)  +  source[i]*1.5f;
                break;
            case Nebula.NebulaMode.Mask:
                dest[i] = (dest[i] * source[i])*2;
                break;
            }

            // Original
            //dest[i] = source[i] * TextureTools.GetBlendingFactor( TextureTools.BlendingMode.Color, source[i] , dest[i]) + dest[i] * TextureTools.GetBlendingFactor( TextureTools.BlendingMode.Color, source[i] , dest[i]);
            dest[i].a = (dest[i].r + dest[i].g + dest[i].b)/3f;

        }

        return dest;
    }
Beispiel #33
0
    private static void VeindedNebula( Nebula neb,bool autoCompute)
    {
        if (neb.layers.Count==3){
            // Variation
            neb.layers[0].fractal.seed = (EditorGUILayout.Slider("Variation 1",neb.layers[0].fractal.seed,1f,1000f));
            neb.layers[1].fractal.seed = neb.layers[0].fractal.seed/2 ;
            neb.layers[2].fractal.seed = (EditorGUILayout.Slider("Variation 2",neb.layers[2].fractal.seed,1f,1000f));

            GuiTools.DrawSeparatorLine( 30);

            // Color
            neb.layers[0].endColor = EditorGUILayout.ColorField( "Color 1",neb.layers[0].endColor);
            neb.layers[1].endColor = EditorGUILayout.ColorField( "Color 2",neb.layers[1].endColor);

            EditorGUILayout.Space();

            // Power
            neb.layers[0].fractal.zoom = EditorGUILayout.Slider("Turbulence",neb.layers[0].fractal.zoom,20,70);
            neb.layers[1].fractal.zoom = neb.layers[0].fractal.zoom;
            neb.power = EditorGUILayout.Slider("Power",neb.power,0f,5f);

            GuiTools.DrawSeparatorLine( 30);

            neb.layers[2].fractal.zoom = EditorGUILayout.Slider("scale",neb.layers[2].fractal.zoom-100,0f,200f)+100;
            neb.layers[2].fractal.threshold = EditorGUILayout.Slider("Cutout",neb.layers[2].fractal.threshold,0.1f,1f);

        }

        EditorGUILayout.Space();

        if (GUI.changed){
            buttonVeinded=18;
            //SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        if (GUILayout.Button(new GUIContent( " Render",CosmosInspector.GetIcon(buttonVeinded))) || autoCompute){
            SpaceBox.instance.starfield.Render(true);
            RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
            SpaceBox.instance.UpdateNebulaSkyBox();
            buttonVeinded =16;

        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
    }
        public override void AddItemsToLevel(Nebula.Sprite sprite, float xSL, float ySL)
        {
            //ADDING PLATFORMS
            AddPlatform(new Vector2(xSL / 12, ySL - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2((xSL / 12)*2, ySL - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL / 2, ySL - ySL / 8), true);
            AddPlatform(new Vector2(xSL / 2 + xSL / 4 + myPlatform.myTexture.Width / 8, ySL / 2 + ySL / 4), true);
            AddPlatform(new Vector2(xSL + xSL / 4 - sprite.myTexture.Width, ySL / 2 + ySL / 4), true);
            AddPlatform(new Vector2(xSL + xSL / 2, ySL / 2 + ySL / 16), true);
            AddPlatform(new Vector2(xSL + xSL / 2 + myPlatform.myTexture.Width, ySL / 2 + ySL / 16), false);
            AddPlatform(new Vector2(xSL + xSL / 2 + myPlatform.myTexture.Width * 2, ySL / 2 + ySL / 16), false);
            AddPlatform(new Vector2(xSL + xSL / 2 + myPlatform.myTexture.Width * 3, ySL / 2 + ySL / 16), true);
            AddPlatform(new Vector2(xSL * 2 + myPlatform.myTexture.Width * 3, ySL / 2 + ySL / 4 + myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 2 + myPlatform.myTexture.Width * 4, ySL / 2 + ySL / 4 + myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 2 + myPlatform.myTexture.Width * 5, ySL / 2 + ySL / 4 + myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 2 + myPlatform.myTexture.Width * 6, ySL / 2 + ySL / 4 + myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 2 + myPlatform.myTexture.Width * 7, ySL / 2 + ySL / 4 + myPlatform.myTexture.Height * 2), true);

            AddPlatform(new Vector2(xSL * 3 + xSL / 16, ySL / 2 + ySL / 4), true);
            AddPlatform(new Vector2(xSL * 3 - xSL / 16, ySL / 2 + ySL / 32), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width / 2, ySL / 2), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width, ySL / 2 - myPlatform.myTexture.Height), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 2, ySL / 2 - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 3, ySL / 2 - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 4, ySL / 2 - myPlatform.myTexture.Height * 4), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 5, ySL / 2 - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 6, ySL / 2 - myPlatform.myTexture.Height * 5), true);

            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 11, ySL - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 12, ySL - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 12, ySL - myPlatform.myTexture.Height * 6), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 13, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 14, ySL - myPlatform.myTexture.Height * 14), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 17, ySL - myPlatform.myTexture.Height * 6), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 18, ySL - myPlatform.myTexture.Height * 6), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 19, ySL - myPlatform.myTexture.Height * 6), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 22, ySL - myPlatform.myTexture.Height * 4), true);

            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 23, ySL - myPlatform.myTexture.Height * 4), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 24, ySL - myPlatform.myTexture.Height * 4), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 25, ySL - myPlatform.myTexture.Height * 4), true);

            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 28, ySL - myPlatform.myTexture.Height * 7), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 29, ySL - myPlatform.myTexture.Height * 8), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 30, ySL - myPlatform.myTexture.Height * 8), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 31, ySL - myPlatform.myTexture.Height * 8), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 32, ySL - myPlatform.myTexture.Height * 8), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 32, ySL - myPlatform.myTexture.Height * 10), true);

            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 37, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 38, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 39, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 40, ySL - myPlatform.myTexture.Height * 5), true);

            //ADDING ENEMIES
            AddEnemy(aEnemy, new Vector2(xSL + xSL / 4 - aHero.myTexture.Width / 2,
                   ySL / 2 + ySL / 4 - ySL / 8));

            AddEnemy(aEnemy, new Vector2(xSL * 2 + myPlatform.myTexture.Width * 7,
                    ySL / 2 + ySL / 4 - aEnemy.myTexture.Height / 4));

            AddEnemy(aEnemy, new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 25,
                ySL - myPlatform.myTexture.Height * 4 - aEnemy.myTexture.Height));

            AddEnemy(aEnemy, new Vector2(xSL * 3 + xSL / 4 + myPlatform.myTexture.Width * 32,
                ySL - myPlatform.myTexture.Height * 10 - aEnemy.myTexture.Height));
        }
        public override void AddItemsToLevel(Nebula.Sprite sprite, float xSL, float ySL)
        {
            //Platforms
            AddPlatform(new Vector2(xSL / 12, ySL - myPlatform.myTexture.Height * 2), true);
            AddPlatform(new Vector2((xSL / 12) * 2, ySL - myPlatform.myTexture.Height * 2), true);

            AddPlatform(new Vector2((xSL / 12) * 5, ySL - myPlatform.myTexture.Height * 6), true);

            AddPlatform(new Vector2((xSL / 12) * 9, ySL - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2((xSL / 12) * 12, ySL - myPlatform.myTexture.Height * 3), false);

            AddPlatform(new Vector2((xSL / 12) * 10, ySL - myPlatform.myTexture.Height * 9), true);
            AddPlatform(new Vector2((xSL / 12) * 11, ySL - myPlatform.myTexture.Height * 9), true);

            AddPlatform(new Vector2((xSL / 12) * 12, ySL - myPlatform.myTexture.Height * 12), true);
            AddPlatform(new Vector2((xSL / 12) * 12, ySL - myPlatform.myTexture.Height * 15), true);
            AddPlatform(new Vector2((xSL / 12) * 12, ySL - myPlatform.myTexture.Height * 17), true);

            AddPlatform(new Vector2((xSL / 12) * 15, ySL - myPlatform.myTexture.Height * 12), true);
            AddPlatform(new Vector2((xSL / 12) * 16, ySL - myPlatform.myTexture.Height * 12), false);
            AddPlatform(new Vector2((xSL / 12) * 17, ySL - myPlatform.myTexture.Height * 12), false);
            AddPlatform(new Vector2((xSL / 12) * 18, ySL - myPlatform.myTexture.Height * 12), false);

            AddPlatform(new Vector2((xSL / 12) * 22, ySL - myPlatform.myTexture.Height * 9), true);
            AddPlatform(new Vector2((xSL / 12) * 24, ySL - myPlatform.myTexture.Height * 9), true);
            AddPlatform(new Vector2((xSL / 12) * 25, ySL - myPlatform.myTexture.Height * 9), true);

            AddPlatform(new Vector2((xSL / 12) * 30, ySL - myPlatform.myTexture.Height * 13), true);

            AddPlatform(new Vector2((xSL / 12) * 31, ySL - myPlatform.myTexture.Height * 9), true);

            AddPlatform(new Vector2((xSL / 12) * 28, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 29, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 32, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 33, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 36, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 37, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 40, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 41, ySL - myPlatform.myTexture.Height * 5), false);
            AddPlatform(new Vector2((xSL / 12) * 42, ySL - myPlatform.myTexture.Height * 5), false);

            AddPlatform(new Vector2((xSL / 12) * 34, ySL - myPlatform.myTexture.Height * 12), true);
            AddPlatform(new Vector2((xSL / 12) * 39, ySL - myPlatform.myTexture.Height * 15), true);

            AddPlatform(new Vector2((xSL / 12) * 42, ySL - myPlatform.myTexture.Height * 13), true);
            AddPlatform(new Vector2((xSL / 12) * 47, ySL - myPlatform.myTexture.Height * 14), true);

            AddPlatform(new Vector2((xSL / 12) * 50, ySL - myPlatform.myTexture.Height * 12), false);

            AddPlatform(new Vector2((xSL / 12) * 52, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2((xSL / 12) * 54, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2((xSL / 12) * 56, ySL - myPlatform.myTexture.Height * 10), true);

            AddPlatform(new Vector2((xSL / 12) * 60, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 63, ySL - myPlatform.myTexture.Height * 5), false);
            AddPlatform(new Vector2((xSL / 12) * 64, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 65, ySL - myPlatform.myTexture.Height * 5), true);

            AddPlatform(new Vector2((xSL / 12) * 69, ySL - myPlatform.myTexture.Height * 5), true);
            AddPlatform(new Vector2((xSL / 12) * 71, ySL - myPlatform.myTexture.Height * 7), false);
            AddPlatform(new Vector2((xSL / 12) * 73, ySL - myPlatform.myTexture.Height * 9), true);
            AddPlatform(new Vector2((xSL / 12) * 75, ySL - myPlatform.myTexture.Height * 11), false);
            AddPlatform(new Vector2((xSL / 12) * 77, ySL - myPlatform.myTexture.Height * 13), true);

            AddPlatform(new Vector2((xSL / 12) * 80, ySL - myPlatform.myTexture.Height * 11), true);

            AddPlatform(new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 3), false);
            AddPlatform(new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 7), false);
            AddPlatform(new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 11), false);
            AddPlatform(new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 15), false);

            AddPlatform(new Vector2((xSL / 12) * 87, ySL - myPlatform.myTexture.Height * 5), true);

            //lower
            AddPlatform(new Vector2((xSL / 12) * 89, ySL - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2((xSL / 12) * 92, ySL - myPlatform.myTexture.Height * 1), true);
            AddPlatform(new Vector2((xSL / 12) * 94, ySL - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2((xSL / 12) * 95, ySL - myPlatform.myTexture.Height * 1), false);
            AddPlatform(new Vector2((xSL / 12) * 96, ySL - myPlatform.myTexture.Height * 1), false);
            AddPlatform(new Vector2((xSL / 12) * 97, ySL - myPlatform.myTexture.Height * 1), true);
            AddPlatform(new Vector2((xSL / 12) * 100, ySL - myPlatform.myTexture.Height * 2), false);
            AddPlatform(new Vector2((xSL / 12) * 101, ySL - myPlatform.myTexture.Height * 2), false);
            AddPlatform(new Vector2((xSL / 12) * 102, ySL - myPlatform.myTexture.Height * 2), false);

            //upper
            AddPlatform(new Vector2((xSL / 12) * 90, ySL - myPlatform.myTexture.Height * 8), true);
            AddPlatform(new Vector2((xSL / 12) * 92, ySL - myPlatform.myTexture.Height * 9), false);
            AddPlatform(new Vector2((xSL / 12) * 93, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 94, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2((xSL / 12) * 95, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 96, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2((xSL / 12) * 97, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 98, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 99, ySL - myPlatform.myTexture.Height * 10), true);
            AddPlatform(new Vector2((xSL / 12) * 100, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 101, ySL - myPlatform.myTexture.Height * 10), false);
            AddPlatform(new Vector2((xSL / 12) * 102, ySL - myPlatform.myTexture.Height * 10), true);

            AddPlatform(new Vector2((xSL / 12) * 106, ySL - myPlatform.myTexture.Height * 9), true);
            AddPlatform(new Vector2((xSL / 12) * 109, ySL - myPlatform.myTexture.Height * 7), true);
            AddPlatform(new Vector2((xSL / 12) * 111, ySL - myPlatform.myTexture.Height * 11), true);
            AddPlatform(new Vector2((xSL / 12) * 113, ySL - myPlatform.myTexture.Height * 6), true);
            AddPlatform(new Vector2((xSL / 12) * 114, ySL - myPlatform.myTexture.Height * 15), true);
            AddPlatform(new Vector2((xSL / 12) * 115, ySL - myPlatform.myTexture.Height * 7), true);
            AddPlatform(new Vector2((xSL / 12) * 117, ySL - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2((xSL / 12) * 118, ySL - myPlatform.myTexture.Height * 3), true);
            AddPlatform(new Vector2((xSL / 12) * 119, ySL - myPlatform.myTexture.Height * 3), true);

            //Enemies
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 5, ySL - myPlatform.myTexture.Height * 6 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 9, ySL - myPlatform.myTexture.Height * 3 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 11, ySL - myPlatform.myTexture.Height * 9 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 12, ySL - myPlatform.myTexture.Height * 3 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 25, ySL - myPlatform.myTexture.Height * 9 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 36, ySL - myPlatform.myTexture.Height * 5 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 39, ySL - myPlatform.myTexture.Height * 15 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 40, ySL - myPlatform.myTexture.Height * 5 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 54, ySL - myPlatform.myTexture.Height * 10 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 64, ySL - myPlatform.myTexture.Height * 5 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 77, ySL - myPlatform.myTexture.Height * 13 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 80, ySL - myPlatform.myTexture.Height * 11 - aEnemy.myTexture.Height));

            AddEnemy(aEnemy, new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 7 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 11 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 84, ySL - myPlatform.myTexture.Height * 15 - aEnemy.myTexture.Height));

            AddEnemy(aEnemy, new Vector2((xSL / 12) * 94, ySL - myPlatform.myTexture.Height * 3 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 96, ySL - myPlatform.myTexture.Height * 10 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 97, ySL - myPlatform.myTexture.Height * 1 - aEnemy.myTexture.Height));

            //final wave
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 106, ySL - myPlatform.myTexture.Height * 9 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 109, ySL - myPlatform.myTexture.Height * 7 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 111, ySL - myPlatform.myTexture.Height * 11 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 113, ySL - myPlatform.myTexture.Height * 6 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 114, ySL - myPlatform.myTexture.Height * 15 - aEnemy.myTexture.Height));
            AddEnemy(aEnemy, new Vector2((xSL / 12) * 115, ySL - myPlatform.myTexture.Height * 7 - aEnemy.myTexture.Height));
        }
Beispiel #36
0
    private static void NebulaProperties(Nebula nebula)
    {
        #region Header
        EditorGUILayout.BeginHorizontal();
        Color crossColor = Color.red;

        int width = Screen.width-125;
        if (nebula.isWaitToDelte){
            crossColor= Color.white;
            width =  Screen.width-179;
        }

        // Delete
        if (GuiTools.Button("X",crossColor,19)){
            nebula.isWaitToDelte = !nebula.isWaitToDelte;
        }
        if (nebula.isWaitToDelte){
            if (GuiTools.Button("Delete",Color.red,50)){
                SpaceBox.instance.nebula.Remove( nebula );
                SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
                RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
                SpaceBox.instance.UpdateNebulaSkyBox();
                SpaceBox.instance.starfield.Render(true);
                SpaceBox.instance.starfield.Render();
                EditorGUILayout.EndHorizontal();
                SpaceBox.instance.nebulaNeed2Save = true;
                return;
            }
        }

        nebula.inspectorShowProperties = GuiTools.ChildFoldOut( nebula.inspectorShowProperties,nebula.name + " " + " " + nebula.Type.ToString() + " - " + nebula.nebulaMode.ToString(),new Color(183f/255f,230f/255f,252f/255f),width);

        // Up
        if (GUILayout.Button (new GUIContent("",CosmosInspector.GetIcon(23)),GUILayout.Width(19))){
            int index = SpaceBox.instance.nebula.IndexOf( nebula);
            index--;
            if (index>=0){

                SpaceBox.instance.nebula.Remove( nebula);
                SpaceBox.instance.nebula.Insert( index, nebula);
                SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
                RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
                SpaceBox.instance.UpdateNebulaSkyBox();
                SpaceBox.instance.starfield.Render(true);
                SpaceBox.instance.starfield.Render();
                SpaceBox.instance.nebulaNeed2Save = true;
            }
        }
        // Down
        if (GUILayout.Button (new GUIContent("",CosmosInspector.GetIcon(24)),GUILayout.Width(19))){
            int index = SpaceBox.instance.nebula.IndexOf( nebula);
            index++;
            if (index<SpaceBox.instance.nebula.Count){
                SpaceBox.instance.nebula.Remove( nebula);
                SpaceBox.instance.nebula.Insert( index, nebula);
                SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
                RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
                SpaceBox.instance.UpdateNebulaSkyBox();
                SpaceBox.instance.starfield.Render(true);
                SpaceBox.instance.starfield.Render();
                SpaceBox.instance.nebulaNeed2Save = true;
            }
        }

        // Copy
        if (GUILayout.Button (new GUIContent("C"),GUILayout.Width(19))){
            Nebula newNebula = SpaceBox.instance.AddNebula();
            newNebula.PasteNebula( nebula);
            RenderNebula( SpaceBox.instance.GetNebulaQuality2Int());
            SpaceBox.instance.UpdateNebulaSkyBox();
            SpaceBox.instance.nebulaNeed2Save = true;
        }

        EditorGUILayout.EndHorizontal();
        #endregion

        #region treatment
        if (nebula.inspectorShowProperties){

            EditorGUI.indentLevel++;

            EditorGUILayout.Space();

            // random
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(14);
            bool autoCompute = false;
            bool random = GUILayout.Button(new GUIContent( " Rnd " + nebula.Type.ToString(),CosmosInspector.GetIcon(15)),GUILayout.Width(100));
            bool randomColor = GUILayout.Button(new GUIContent( " Rnd Color",CosmosInspector.GetIcon(14)),GUILayout.Width(100));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            // Enable
            bool enable  = GuiTools.Toggle("Enable",nebula.enable, true);
            if (nebula.enable != enable){
                nebula.enable = enable;
                autoCompute = true;
            }
            EditorGUILayout.Space();

            // Name
            nebula.name = EditorGUILayout.TextField("Name",nebula.name);

            // Mode
            GUI.backgroundColor = new Color(33f/255f,180f/255f,252f/255f);
            Nebula.NebulaMode mode = (Nebula.NebulaMode)EditorGUILayout.EnumPopup("Mode",nebula.nebulaMode);
            if (mode !=  nebula.nebulaMode){
                nebula.nebulaMode = mode;
                autoCompute = true;
            }
            GUI.backgroundColor = Color.white;

            EditorGUILayout.Space();

            // Type
            GUI.backgroundColor = new Color(33f/255f,180f/255f,252f/255f);
            Nebula.NebulaType type = (Nebula.NebulaType)EditorGUILayout.EnumPopup("Type",nebula.Type);
            if (nebula.Type != type){
                nebula.Type = type;
                autoCompute=true;
            }
            GUI.backgroundColor = Color.white;

            if (random || randomColor){
                SpaceBox.instance.Quality = SpaceBox.NebulaQuality.Draft;
            }

            switch(nebula.Type){
                case Nebula.NebulaType.Cloudy:

                    if (random) {nebula.RandomCloudy(nebula.layers[1].overlay);autoCompute=true;}

                    if (randomColor) {nebula.RandomCloudyColor();autoCompute=true;}
                    CloudyNebula( nebula,autoCompute );
                    break;
                case Nebula.NebulaType.Veined:
                    if (random) {nebula.RandomVeined();autoCompute=true;}
                    if (randomColor) {nebula.RandomVeinedColor();autoCompute=true;}
                    VeindedNebula( nebula,autoCompute);
                    break;
            }
            EditorGUI.indentLevel--;
        }
        #endregion
    }