Пример #1
0
    public static void PlayUI(this ParticleLoader loader, Renderer r, int deltaRQ, Action <ParticleControl> loadCallback = null, Action <ParticleControl> endCallback = null)
    {
        if (loader == null)
        {
            return;
        }
        UIPanel p = loader.GetComponentInParent <UIPanel>();

        if (p != null)
        {
            loader.Play(particle =>
            {
                if (particle != null)
                {
                    particle.SetRqDelta(r, deltaRQ);
                }
                else
                {
                    Assert.IsNotNull(particle);
                }
                loadCallback.Call(particle);
            }, endCallback);
        }
        else
        {
            loader.Play(loadCallback, endCallback);
        }
    }
Пример #2
0
 private void Awake()
 {
     if (M == null)
     {
         M = this;
     }
     else if (M != this)
     {
         Destroy(this);
     }
 }
Пример #3
0
 public static void PlayUI(this ParticleLoader loader, int deltaRQ, Action <ParticleControl> loadCallback = null, Action <ParticleControl> callback = null)
 {
     if (loader == null)
     {
         return;
     }
     loader.Play(particle =>
     {
         loadCallback.Call(particle);
         particle.PlayUI(deltaRQ, callback);
     }, null);
 }
Пример #4
0
 public void StartProjectile(Vector2Int Position, SRotation Direction)
 {
     MovementScript                     = GetComponent <TileMovingObjectScript>();
     MovementScript.MotionSpeed         = 12f;
     MovementScript.SpecialObjectIgnore = true;
     MovementScript.JumpToTile(Position.x, Position.y);
     this.Direction = Direction;
     CanMove        = true;
     particleSystem = GetComponentInChildren <ParticleSystem>();
     if (particleSystem != default)
     {
         ParticleLoader.SetBurst(particleSystem, 4);
     }
 }
Пример #5
0
    Coin newCoin(Vector3 init_pos, Vector3 ripple_target_pos, Vector3 move_target_pos, float layer, float spring_delay)
    {
        Coin coin = new Coin();

        coin.RippleTargetPostion       = ripple_target_pos;
        coin.OriginRippleTargetPostion = ripple_target_pos;
        coin.InitPostion        = init_pos;
        coin.MoveTargetPostion  = move_target_pos;
        coin.totalRippleSeconds = mRippleDuration;
        coin.totalMoveSeconds   = mMoveDuration;
        coin.mSpringTimeCounter.totalSeconds = mSprintDuration;
        coin.layer            = layer;
        coin.mSpringEachDelay = spring_delay;
        coin.Particle         = ParticleLoader.Load(getPrefabName(), init_pos);

        return(coin);
    }
Пример #6
0
 public static void PlayUI(this ParticleLoader loader, Action <ParticleControl> loadCallback = null, Action <ParticleControl> endCallback = null)
 {
     PlayUI(loader, 1, loadCallback, endCallback);
 }
Пример #7
0
            // Parser Apply Event
            public void Apply (ConfigNode node)
            {
                // If we have a template, generatedBody *is* the template body
                if (template != null) 
                {
                    generatedBody = template.body;

                    // Patch the game object names in the template
                    generatedBody.name = name;
                    generatedBody.celestialBody.bodyName = name;
                    generatedBody.celestialBody.transform.name = name;
                    generatedBody.celestialBody.bodyTransform.name = name;
                    generatedBody.scaledVersion.name = name;
                    if (generatedBody.pqsVersion != null)
                    {
                        generatedBody.pqsVersion.name = name;
                        generatedBody.pqsVersion.gameObject.name = name;
                        generatedBody.pqsVersion.transform.name = name;
                        foreach (PQS p in generatedBody.pqsVersion.GetComponentsInChildren(typeof (PQS), true))
                            p.name = p.name.Replace (template.body.celestialBody.bodyName, name);
                    }

                    // If we've changed the name, reset use_The_InName
                    if (generatedBody.name != template.body.name)
                    {
                        generatedBody.celestialBody.use_The_InName = false;
                    }
                    
                    // If this body has an orbit, create editor/loader
                    if (generatedBody.orbitDriver != null) 
                    {
                        orbit = new OrbitLoader(generatedBody);
                    }

                    // If this body has a PQS, create editor/loader
                    if (generatedBody.pqsVersion != null)
                    {
                        pqs = new PQSLoader(generatedBody.pqsVersion);

                        // If this body has an ocean PQS, create editor/loader
                        if (generatedBody.celestialBody.ocean == true)
                        {
                            foreach (PQS PQSocean in generatedBody.pqsVersion.GetComponentsInChildren<PQS>(true))
                            {
                                if (PQSocean.name == name + "Ocean")
                                {
                                    ocean = new OceanPQS(PQSocean);
                                    break;
                                }
                            }
                        }
                    }

                    // Create the scaled version editor/loader
                    scaledVersion = new ScaledVersion(generatedBody.scaledVersion, generatedBody.celestialBody, template.type);
                }

                // Otherwise we have to generate all the things for this body
                else 
                {
                    // Create the PSystemBody object
                    GameObject generatedBodyGameObject = new GameObject (name);
                    generatedBodyGameObject.transform.parent = Utility.Deactivator;
                    generatedBody = generatedBodyGameObject.AddComponent<PSystemBody> ();
                    generatedBody.flightGlobalsIndex = 0;

                    // Create the celestial body
                    GameObject generatedBodyProperties = new GameObject (name);
                    generatedBodyProperties.transform.parent = generatedBodyGameObject.transform;
                    generatedBody.celestialBody = generatedBodyProperties.AddComponent<CelestialBody> ();
                    generatedBody.resources = generatedBodyProperties.AddComponent<PResource> ();
                    generatedBody.celestialBody.progressTree = null;

                    // Sensible defaults 
                    generatedBody.celestialBody.bodyName = name;
                    generatedBody.celestialBody.atmosphere = false;
                    generatedBody.celestialBody.ocean = false;

                    // Create the scaled version
                    generatedBody.scaledVersion = new GameObject(name);
                    generatedBody.scaledVersion.layer = Constants.GameLayers.ScaledSpace;
                    generatedBody.scaledVersion.transform.parent = Utility.Deactivator;

                    // Create the scaled version editor/loader
                    scaledVersion = new ScaledVersion(generatedBody.scaledVersion, generatedBody.celestialBody, BodyType.Atmospheric);
                }

                // Create property editor/loader objects
                properties = new Properties (generatedBody.celestialBody);

                // Atmospheric settings
                atmosphere = new Atmosphere(generatedBody.celestialBody, generatedBody.scaledVersion);

                // Particles
                particle = new ParticleLoader(generatedBody.scaledVersion.gameObject);
            }
            /// <summary>
            /// Saves the celestial body into a Kopernicus formatted ConfigNode.
            /// </summary>
            public static void SaveCelestial(CelestialBody planet)
            {
                // Create the main node
                ConfigNode root = new ConfigNode("@Kopernicus:NEEDS[!Kopernicus]");
                ConfigNode body = root.AddNode("Body");

                // Create the body
                body.AddValue("name", planet.name);

                // Properties
                ConfigNode properties = WriteObjectToConfigNode("Properties", ref body, new PropertiesLoader(planet));

                // Properties.Biomes
                if (planet.BiomeMap != null)
                {
                    ConfigNode biomes = properties.AddNode("Biomes");
                    foreach (CBAttributeMapSO.MapAttribute biome in planet.BiomeMap.Attributes)
                    {
                        WriteObjectToConfigNode("Biome", ref biomes, new BiomeLoader(biome));
                    }
                }

                // Properties.ScienceValues
                if (planet.scienceValues != null)
                {
                    WriteObjectToConfigNode("ScienceValues", ref properties, new ScienceValuesLoader(planet.scienceValues));
                }

                // Orbit
                if (planet.orbitDriver)
                {
                    WriteObjectToConfigNode("Orbit", ref body, new OrbitLoader(planet));
                }

                // Atmosphere
                if (planet.atmosphere)
                {
                    ConfigNode atmo = WriteObjectToConfigNode("Atmosphere", ref body, new AtmosphereLoader(planet));

                    // Atmosphere.AtmosphereFromGround
                    if (planet.afg != null)
                    {
                        WriteObjectToConfigNode("AtmosphereFromGround", ref atmo, new AtmosphereFromGroundLoader(planet));
                    }
                }

                // ScaledVersion
                ScaledVersionLoader scaledLoader = new ScaledVersionLoader(planet);
                ConfigNode          scaled       = WriteObjectToConfigNode("ScaledVersion", ref body, scaledLoader);

                // ScaledVersion.Material
                Material material = planet.scaledBody.GetComponent <Renderer>().sharedMaterial;

                if (scaledLoader.type == BodyType.Star)
                {
                    WriteObjectToConfigNode("Material", ref scaled, new EmissiveMultiRampSunspotsLoader(material));

                    // ScaledVersion.Light
                    WriteObjectToConfigNode("Light", ref scaled, new LightShifterLoader(planet));

                    // ScaledVersion.Coronas
                    if (planet.scaledBody.GetComponentsInChildren <SunCoronas>().Length != 0)
                    {
                        ConfigNode coronas = scaled.AddNode("Coronas");
                        foreach (SunCoronas corona in planet.scaledBody.GetComponentsInChildren <SunCoronas>(true))
                        {
                            WriteObjectToConfigNode("Corona", ref coronas, new CoronaLoader(corona));
                        }
                    }
                }
                else if (scaledLoader.type == BodyType.Atmospheric)
                {
                    WriteObjectToConfigNode("Material", ref scaled, new ScaledPlanetRimAerialLoader());
                }
                else
                {
                    WriteObjectToConfigNode("Material", ref scaled, new ScaledPlanetSimpleLoader(material));
                }

                // Particles
                ConfigNode particles = body.AddNode("Particles");

                foreach (PlanetParticleEmitter e in planet.scaledBody.GetComponentsInChildren <PlanetParticleEmitter>(true))
                {
                    ParticleLoader loader = new ParticleLoader(e);
                    WriteObjectToConfigNode("Particle", ref particles, loader);
                }

                // Rings
                if (planet.scaledBody.GetComponentsInChildren <Ring>(true).Length != 0)
                {
                    ConfigNode rings = body.AddNode("Rings");
                    foreach (Ring ring in planet.scaledBody.GetComponentsInChildren <Ring>(true))
                    {
                        WriteObjectToConfigNode("Ring", ref rings, new RingLoader(ring));
                    }
                }

                // PQS
                if (planet.pqsController)
                {
                    WritePQSToConfigNode(planet.pqsController, ref body, false);
                }

                // Ocean
                if (planet.ocean)
                {
                    WritePQSToConfigNode(planet.pqsController.ChildSpheres[0], ref body, true);
                }

                // Save the node
                Directory.CreateDirectory(KSPUtil.ApplicationRootPath + "/GameData/KittopiaTech/Config/");
                ConfigNode save = new ConfigNode();

                save.AddNode(root);
                save.Save("GameData/KittopiaTech/Config/" + planet.name + ".cfg", "KittopiaTech - a Kopernicus Visual Editor");
            }