Пример #1
0
            public static void Prefix(Comet __instance, Vector3 pos, int cell, int damage)
            {
                if (!Grid.IsValidCell(cell))
                {
                    return;
                }
                if (!MyGrid.IsScaffolding(cell))
                {
                    return;
                }

                GameObject gameObject = Grid.Objects[cell, (int)ObjectLayer.AttachableBuilding];

                if (gameObject != null)
                {
                    BuildingHP component = gameObject.GetComponent <BuildingHP>();
                    if (component != null)
                    {
                        float f = gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Bunker) ? ((float)damage * __instance.bunkerDamageMultiplier) : ((float)damage);
                        component.gameObject.Trigger((int)GameHashes.DoBuildingDamage, new BuildingHP.DamageSourceInfo
                        {
                            damage    = Mathf.RoundToInt(f),
                            source    = BUILDINGS.DAMAGESOURCES.COMET,
                            popString = UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
                        });
                    }
                }
            }
Пример #2
0
    void NewBox(Comet c)
    {
        Vector2 pos = c["Position"].AsVector2();

        boxes.Add(boxes.Count, Instantiate(boxPrefab, new Vector3(pos.x, 3, pos.y), Quaternion.identity).transform);
        SendBoxes();
    }
Пример #3
0
        public static ScriptModules New(
            Random random,
            GameDatabase db,
            AssetDatabase assetdb,
            GameSession game,
            NamesPool namesPool,
            GameSetup gameSetup)
        {
            ScriptModules scriptModules = new ScriptModules();

            scriptModules.VonNeumann      = VonNeumann.InitializeEncounter(db, assetdb);
            scriptModules.Swarmers        = Swarmers.InitializeEncounter(db, assetdb);
            scriptModules.Gardeners       = Gardeners.InitializeEncounter(db, assetdb);
            scriptModules.AsteroidMonitor = AsteroidMonitor.InitializeEncounter(db, assetdb);
            scriptModules.MorrigiRelic    = MorrigiRelic.InitializeEncounter(db, assetdb);
            scriptModules.Slaver          = Slaver.InitializeEncounter(db, assetdb);
            scriptModules.Pirates         = Pirates.InitializeEncounter(db, assetdb);
            scriptModules.Spectre         = Spectre.InitializeEncounter(db, assetdb);
            scriptModules.GhostShip       = GhostShip.InitializeEncounter(db, assetdb);
            scriptModules.MeteorShower    = MeteorShower.InitializeEncounter(db, assetdb);
            scriptModules.SystemKiller    = SystemKiller.InitializeEncounter(db, assetdb);
            scriptModules.Locust          = Locust.InitializeEncounter(db, assetdb);
            scriptModules.Comet           = Comet.InitializeEncounter(db, assetdb);
            if (db.HasEndOfFleshExpansion())
            {
                scriptModules.NeutronStar = NeutronStar.InitializeEncounter(db, assetdb);
                scriptModules.SuperNova   = SuperNova.InitializeEncounter();
            }
            scriptModules.AddEasterEggs(random, db, assetdb, game, namesPool, gameSetup);
            return(scriptModules);
        }
Пример #4
0
        public static ProgressionStar ConvertStar(ProgressionMap map, Star oldStar)
        {
            ProgressionStar newStar = ConvertStarOnly(map, oldStar);

            IDictionary <string, Planet> oldPlanets = oldStar.GetPlanets();

            if (oldPlanets != null)
            {
                foreach (Planet oldPlanet in oldPlanets.Values)
                {
                    ProgressionPlanet newPlanet = ConvertPlanet(map, oldPlanet);
                    newStar.Add(newPlanet);
                }
            }

            IDictionary <string, DwarfPlanet> oldDwarfs = oldStar.GetDwarfPlanets();

            if (oldDwarfs != null)
            {
                foreach (DwarfPlanet oldDwarf in oldDwarfs.Values)
                {
                    // Default handling is that if the DwarfPlanet has satellites convert
                    // it to an Planet otherwise convert to an Asteroid
                    if (oldDwarf.Satellites != null)
                    {
                        ProgressionPlanet newPlanet = ConvertDwarfPlanetasPlanet(map, oldDwarf);
                        newStar.Add(newPlanet);
                    }
                    else
                    {
                        Asteroid newAsteroid = ConvertDwarfPlanetasAsteroid(map, oldDwarf);
                        newStar.Add(newAsteroid);
                    }
                }
            }

            IDictionary <string, Asteroid> oldAsteroids = oldStar.GetAsteroids();

            if (oldAsteroids != null)
            {
                foreach (Asteroid oldAsteroid in oldAsteroids.Values)
                {
                    Asteroid newAsteroid = ConvertAsteroid(map, oldAsteroid);
                    newStar.Add(newAsteroid);
                }
            }

            IDictionary <string, Comet> oldComets = oldStar.GetComets();

            if (oldComets != null)
            {
                foreach (Comet oldComet in oldComets.Values)
                {
                    Comet newComet = ConvertComet(map, oldComet);
                    newStar.Add(newComet);
                }
            }

            return(newStar);
        }
Пример #5
0
        private void cboObject_SelectedIndexChanged(object sender, EventArgs e)
        {
            Timer.Stop();

            SelectedObject = Objects.ElementAt(cboObject.SelectedIndex);
            orbitPanel.LoadPanel(SelectedObject, orbitPanel.ATime);
            orbitPanel.Invalidate();
        }
Пример #6
0
        public static Comet ConvertComet(ProgressionMap map, Comet oldComet)
        {
            Comet newComet = new Comet(oldComet.Name);

            newComet.Properties = oldComet.Properties;
            map.Add(newComet);
            return(newComet);
        }
 public void ComputeStaticDisplay()
 {
     IsStaticComputationExists = false;
     if (!parallelStaticComputation.IsBusy && !parallelAnimationComputation.IsBusy && !IsAnimationComputationInProgress)
     {
         comet      = new Comet(Perihelion, Eccentricity, ForceParameter, OutFlowVelocity);
         tailModels = new List <TailModel>();
         System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
         parallelStaticComputation.RunWorkerAsync();
     }
 }
 // METHODES
 #region Animation display processing
 public void ComputeAnimationDisplay()
 {
     IsStaticComputationExists = false;
     if (!parallelStaticComputation.IsBusy && !parallelAnimationComputation.IsBusy && !IsAnimationComputationInProgress)
     {
         comet      = new Comet(Perihelion, Eccentricity, ForceParameter, OutFlowVelocity);
         tailModels = new List <TailModel>();
         IsAnimationComputationInProgress = true;
         parallelAnimationComputation.RunWorkerAsync();
     }
 }
        private void FireAt(Comet comet, float dt)
        {
            float electricity_used = laser_electricity_consumption * dt;

            if (electricity_available < electricity_used)
            {
                return;
            }
            electricity_available -= electricity_used;

            var primary_element = comet.gameObject.GetComponent <PrimaryElement>();
            var heat_energy     = laser_heat_production * dt;

            if (primary_element.Mass > 100)
            {
                // HACK: Rock comets are hundreds of times more massive than iron comets. Even with the electricity to heat multiplier we couldn't affect them. Apply heat based on mass (Rock Comets are between 4000kg and 7200kg)
                heat_energy *= primary_element.Mass / 10;
            }
            // Use half the heat to ablate the meteor and the rest to warm it.
            var burn_heat_energy = 0.5f * heat_energy;
            var warm_heat_energy = heat_energy - burn_heat_energy;

            primary_element.Temperature += GameUtil.CalculateTemperatureChange(primary_element.Element.specificHeatCapacity, primary_element.Mass, warm_heat_energy / 1000 /*KJ*/);
            var mass_removed = burn_heat_energy / (1000 * primary_element.Element.specificHeatCapacity * (primary_element.Element.highTemp - primary_element.Temperature));

            if (primary_element.Temperature > primary_element.Element.highTemp || primary_element.Mass <= mass_removed)
            {
                ShowExplosion(comet);
                // Drop Resources! :D - If there is a better way to do this, I'm not surprised but I sure couldn't find it (outseeker)
                PrimaryElement component = comet.GetComponent <PrimaryElement>();
                component.Mass        = primary_element.Mass;
                component.Temperature = primary_element.Temperature;
                Element    element   = component.Element;
                Substance  substance = element.substance;
                GameObject go        = substance.SpawnResource(comet.transform.GetPosition(), component.Mass, component.Temperature, byte.MaxValue, 0);
                //Debug.Log("Spawned resource from destroyed comet");
                Util.KDestroyGameObject(comet.gameObject);
                kills += 1;
            }
            else
            {
                primary_element.SetMassTemperature(primary_element.Mass - mass_removed, primary_element.Temperature);
                ShowDamageFx(comet.transform.position);
            }

            float sqrMagnitude = (Vec3To2D(comet.transform.position) - Vec3To2D(transform.position)).sqrMagnitude;

            arm_anim_ctrl.GetBatchInstanceData().SetClipRadius(transform.position.x, transform.position.y, sqrMagnitude, do_clip: true);
            foreach (var beam_seg in beam_segs)
            {
                beam_seg.GetComponent <KBatchedAnimController>().GetBatchInstanceData().SetClipRadius(arm_anim_ctrl.transform.position.x, arm_anim_ctrl.transform.position.y, sqrMagnitude, do_clip: true);
            }
        }
Пример #10
0
        public void Sim33ms(float dt)
        {
            this.ChargeCapacitor(dt);
            var comet = comet_tracker.GetClosestComet(this.transform.position, this.range);

            if (comet != null && this.operational.IsOperational && this.AimAt(comet, dt) && this.HasEnoughElectricity(dt))
            {
                this.FireAt(comet, dt);
                this.overkill_time_left = this.overkill_time;
                if (!this.firing || (this.target != comet))
                {
                    this.firing = true;
                    this.target = comet;
                    this.arm_anim_ctrl.Play("gun_digging", KAnim.PlayMode.Loop);
                    foreach (var beam_seg in this.beam_segs)
                    {
                        var beam_anim_ctrl = beam_seg.GetComponent <KBatchedAnimController>();
                        beam_anim_ctrl.enabled    = true;
                        beam_anim_ctrl.TintColour = this.beam_tint;
                        beam_anim_ctrl.Play("idle", KAnim.PlayMode.Loop);
                    }
                }
            }
            else if (this.overkill_time_left <= dt)
            {
                if (this.firing)
                {
                    this.arm_anim_ctrl.Play("gun", KAnim.PlayMode.Loop);
                    foreach (var beam_seg in this.beam_segs)
                    {
                        var beam_anim_ctrl = beam_seg.GetComponent <KBatchedAnimController>();
                        beam_anim_ctrl.Stop();
                        beam_anim_ctrl.enabled = false;
                    }

                    this.firing = false;
                }
            }
            else
            {
                if (this.overkill_time_left == this.overkill_time)
                {
                    this.arm_anim_ctrl.Play("gun", KAnim.PlayMode.Loop);
                }

                this.overkill_time_left -= dt;
                foreach (var beam_seg in this.beam_segs)
                {
                    var beam_anim_ctrl = beam_seg.GetComponent <KBatchedAnimController>();
                    beam_anim_ctrl.TintColour = this.beam_tint * new Color(1, 1, 1, (this.overkill_time_left + 0.1f) / (this.overkill_time + 0.1f));
                }
            }
        }
Пример #11
0
    public void CreateComet()
    {
        GameObject CometObject = Instantiate(CometPrefab);

        CometObject.transform.SetParent(ParentCanvas.transform);
        CometObject.transform.localScale = new Vector3(10, 10, 10);

        Comet comet = CometObject.GetComponent <Comet>();

        comet.InIComet(Distance, Velocity);
        //comet.Reward = Reward;
    }
Пример #12
0
        public static Comet GetCometDetails(string identifier)
        {
            string queryUrl = NearEarthCometsService + "?designation=" + identifier;

            queryUrl = queryUrl.Replace(" ", "%20");
            JArray cometJson = GetJsonArray(queryUrl).Result;
            Comet  comet     = new Comet()
            {
                name = (string)cometJson[0]["designation"], magnitude = (double)cometJson[0]["h_mag"]
            };

            return(comet);
        }
Пример #13
0
    // Use this for initialization
    void Start()
    {
        boxes = new Dictionary <int, Transform>();

        if (SatelliteLibrary.Running)
        {
            newBoxTopic = new Topic.CometReceiver("NewBox", Topic.CometReceiver.StorageType.QUEUE);

            boxComet = new Comet("Box");

            newBoxTopic.OnCometReceived(NewBox);
        }
    }
Пример #14
0
    void UpdateBox(Comet c)
    {
        int     id  = c["ID"].AsInt();
        Vector2 pos = c["Position"].AsVector2();

        if (boxes.ContainsKey(id))
        {
            boxes[id].transform.localPosition = new Vector3(pos.x, 2, pos.y);
        }
        else
        {
            boxes.Add(id, Instantiate(boxPrefab, new Vector3(pos.x, 2, pos.y), Quaternion.identity).transform);
        }
    }
Пример #15
0
        public static List <Comet> ImportAsteroids()
        {
            string filename = "asteroids.dat";

            List <Comet> list = new List <Comet>();
            Comet        c;

            if (File.Exists(filename))
            {
                string[] lines = File.ReadAllLines(filename);

                foreach (string line in lines)
                {
                    try
                    {
                        string name    = line.Substring(166, line.Length - 166).Trim();
                        string sortKey = GetAsteroidSortKey(name);

                        string ep    = line.Substring(20, 5);
                        ATime  epoch = GetATime(ep);

                        double M = Convert.ToDouble(line.Substring(26, 10).Trim()) * Math.PI / 180.0;
                        double w = Convert.ToDouble(line.Substring(36, 11).Trim()) * Math.PI / 180.0;
                        double N = Convert.ToDouble(line.Substring(47, 11).Trim()) * Math.PI / 180.0;
                        double i = Convert.ToDouble(line.Substring(58, 11).Trim()) * Math.PI / 180.0;
                        double e = Convert.ToDouble(line.Substring(69, 11).Trim());
                        double a = Convert.ToDouble(line.Substring(93, 12).Trim());
                        double n = Astro.GAUSS / (a * Math.Sqrt(a));
                        double q = a * (1.0 - e);

                        ATime T = M < Math.PI
                                                        ? new ATime(epoch.JD - M / n, 0.0)
                                                        : new ATime(epoch.JD + (Math.PI * 2.0 - M) / n, 0.0);

                        double eq = 2000.0;

                        c = new Comet(name, T.JD, e, q, w, N, i, eq, sortKey);
                    }
                    catch
                    {
                        continue;
                    }

                    list.Add(c);
                }
            }

            return(list.OrderBy(x => x.SortKey).ToList());
        }
Пример #16
0
        private ActionResult GetCometDetails(string identifier)
        {
            Comet               comet     = RequestManager.GetCometDetails(identifier);
            List <Event>        events    = db.Events.Where(e => e.CosmicBody == comet.name).Where(e => e.Date > DateTime.Today).ToList();
            CosmicBodyViewModel viewModel = new CosmicBodyViewModel()
            {
                body = comet, events = events
            };

            string userId = User.Identity.GetUserId();

            viewModel.userAddress = db.Users.Where(u => u.Id == userId).Select(u => u.Address).FirstOrDefault();

            return(View("Comet", viewModel));
        }
Пример #17
0
    void createBox(Vector3 screenPos)
    {
        Debug.Log(Camera.main);
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(screenPos); // We use the impact point of the ray with the lava plane

        if (Physics.Raycast(ray, out hit) && SatelliteLibrary.Running)
        {
            Comet c = new Comet("Box");    // We build a comet from the Platform.comet file

            c["Position"].Set(new Vector2(hit.point.x, hit.point.z));

            Topic.SendComet("NewBox", c);
        }
    }
        public Comet GetClosestComet(Vector2 position, float range)
        {
            Comet result  = null;
            float mindist = range;

            foreach (var comet in comets)
            {
                var dist = Vector2.Distance(comet.transform.position, position);
                if (dist < mindist)
                {
                    result  = comet;
                    mindist = dist;
                }
            }
            return(result);
        }
Пример #19
0
        private void FireAt(Comet comet, float dt)
        {
            float electricity_used = this.laser_electricity_consumption * dt;

            if (this.electricity_available < electricity_used)
            {
                return;
            }

            this.electricity_available -= electricity_used;

            var primary_element = comet.gameObject.GetComponent <PrimaryElement>();
            var heat_energy     = this.laser_heat_production * dt;

            if (primary_element.Mass > 100)
            {
                // HACK: Rock comets are hundreds of times more massive than iron comets. Even with the electricity to heat multiplier we couldn't affect them. Boost heat production by 100x.
                heat_energy *= 100;
            }

            // Use half the heat to ablate the meteor and the rest to warm it.
            var burn_heat_energy = 0.5f * heat_energy;
            var warm_heat_energy = heat_energy - burn_heat_energy;

            primary_element.Temperature += GameUtil.CalculateTemperatureChange(primary_element.Element.specificHeatCapacity, primary_element.Mass, warm_heat_energy / 1000 /*KJ*/);
            var mass_removed = burn_heat_energy / (1000 * primary_element.Element.specificHeatCapacity * (primary_element.Element.highTemp - primary_element.Temperature));

            if (primary_element.Temperature > primary_element.Element.highTemp || primary_element.Mass <= mass_removed)
            {
                this.ShowExplosion(comet);
                Util.KDestroyGameObject(comet.gameObject);
                this.kills += 1;
            }
            else
            {
                primary_element.SetMassTemperature(primary_element.Mass - mass_removed, primary_element.Temperature);
                this.ShowDamageFx(comet.transform.position);
            }

            float sqrMagnitude = (Vec3To2D(comet.transform.position) - Vec3To2D(this.transform.position)).sqrMagnitude;

            this.arm_anim_ctrl.GetBatchInstanceData().SetClipRadius(this.transform.position.x, this.transform.position.y, sqrMagnitude, do_clip: true);
            foreach (var beam_seg in this.beam_segs)
            {
                beam_seg.GetComponent <KBatchedAnimController>().GetBatchInstanceData().SetClipRadius(this.arm_anim_ctrl.transform.position.x, this.arm_anim_ctrl.transform.position.y, sqrMagnitude, do_clip: true);
            }
        }
        public static ICollection <Comet> CreateComets(IStellarMap map = null)
        {
            map ??= BaseStellarMap.DefaultMap;

            string[] cometNames = { "Halley's", "Caeser's", "Encke's", "Biela's", "Faye's", "Brorsen's", "d'Arrest's" };

            ICollection <Comet> comets = new List <Comet>();

            foreach (string name in cometNames)
            {
                Comet c = new Comet(name);
                comets.Add(c);
                map.Add(c);
            }

            return(comets);
        }
Пример #21
0
        private bool AimAt(Comet comet, float dt)
        {
            var     arm_offset = this.rotatable.GetRotatedOffset(new Vector3(0, 1, 0));
            Vector3 target_dir = Vector3.Normalize(Vec3To2D(comet.transform.position - this.transform.position - arm_offset));

            this.RotateArm(target_dir, warp: false, dt);

            int x, y, cx, cy;

            Grid.CellToXY(Grid.PosToCell(this.transform.gameObject), out x, out y);
            Grid.CellToXY(Grid.PosToCell(comet.transform.gameObject), out cx, out cy);
            var los = Grid.TestLineOfSight(x, y, cx, cy, Grid.VisibleBlockingCB);

            float target_angle = MathUtil.AngleSigned(Vector3.up, target_dir, Vector3.forward);
            var   rotated      = Mathf.Approximately(MathUtil.Wrap(-180f, 180f, target_angle - this.arm_rot), 0f);

            return(los && rotated);
        }
Пример #22
0
        public static ScriptModules Resume(GameDatabase db)
        {
            ScriptModules scriptModules = new ScriptModules();

            scriptModules.VonNeumann      = VonNeumann.ResumeEncounter(db);
            scriptModules.Swarmers        = Swarmers.ResumeEncounter(db);
            scriptModules.Gardeners       = Gardeners.ResumeEncounter(db);
            scriptModules.AsteroidMonitor = AsteroidMonitor.ResumeEncounter(db);
            scriptModules.MorrigiRelic    = MorrigiRelic.ResumeEncounter(db);
            scriptModules.Slaver          = Slaver.ResumeEncounter(db);
            scriptModules.Pirates         = Pirates.ResumeEncounter(db);
            scriptModules.Spectre         = Spectre.ResumeEncounter(db);
            scriptModules.GhostShip       = GhostShip.ResumeEncounter(db);
            scriptModules.MeteorShower    = MeteorShower.ResumeEncounter(db);
            scriptModules.SystemKiller    = SystemKiller.ResumeEncounter(db);
            scriptModules.Locust          = Locust.ResumeEncounter(db);
            scriptModules.Comet           = Comet.ResumeEncounter(db);
            if (db.HasEndOfFleshExpansion())
            {
                scriptModules.NeutronStar = NeutronStar.ResumeEncounter(db);
                scriptModules.SuperNova   = SuperNova.ResumeEncounter();
            }
            List <PlayerInfo> list = db.GetPlayerInfos().Where <PlayerInfo>((Func <PlayerInfo, bool>)(x =>
            {
                if (!x.isStandardPlayer)
                {
                    return(!x.includeInDiplomacy);
                }
                return(false);
            })).ToList <PlayerInfo>();

            foreach (int playerID in db.GetStandardPlayerIDs().ToList <int>())
            {
                foreach (PlayerInfo playerInfo in list)
                {
                    DiplomacyInfo diplomacyInfo = db.GetDiplomacyInfo(playerID, playerInfo.ID);
                    if (diplomacyInfo.State != DiplomacyState.WAR)
                    {
                        db.UpdateDiplomacyState(playerID, playerInfo.ID, DiplomacyState.WAR, diplomacyInfo.Relations, true);
                    }
                }
            }
            return(scriptModules);
        }
Пример #23
0
        public Stream GetChanges()
        {
            var    arg      = new List <BaseObject>();
            string clientId = Guid.NewGuid().ToString();

            ValuesPusherComet.RegisterCometInstance(clientId, this);

            if (_ev.WaitOne(Comet.TimeOut))
            {
                lock (typeof(Comet))
                {
                    arg = _message;
                }
            }

            Comet.UnregisterCometInstance(clientId);
            var myResponseBody = JsonConvert.SerializeObject(arg);

            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            return(new MemoryStream(Encoding.UTF8.GetBytes(myResponseBody)));
        }
        public void ShowExplosion(Comet comet)
        {
            var    position = comet.transform.GetPosition();
            string sound    = GlobalAssets.GetSound(comet.impactSound);

            if (CameraController.Instance.IsAudibleSound(position, sound))
            {
                EventInstance instance = KFMOD.BeginOneShot(sound, position);
                instance.setParameterByName("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
                KFMOD.EndOneShot(instance);
            }
            var fx_position = position;

            fx_position.z = Grid.GetLayerZ(Grid.SceneLayer.FXFront2);
            var cell = Grid.PosToCell(fx_position);

            if (SafeCell(cell))
            {
                Game.Instance.SpawnFX(comet.explosionEffectHash, fx_position, 0f);
            }
        }
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreateEntity(ID, UI.SPACEDESTINATIONS.COMETS.ROCKCOMET.NAME, true);

        gameObject.AddOrGet <SaveLoadRoot>();
        gameObject.AddOrGet <LoopingSounds>();
        Comet comet = gameObject.AddOrGet <Comet>();
        float mass  = ElementLoader.FindElementByHash(SimHashes.Regolith).defaultValues.mass;

        comet.massRange           = new Vector2(mass * 0.8f * 6f, mass * 1.2f * 6f);
        comet.temperatureRange    = new Vector2(323.15f, 423.15f);
        comet.addTiles            = 6;
        comet.addTilesMinHeight   = 2;
        comet.addTilesMaxHeight   = 8;
        comet.entityDamage        = 20;
        comet.totalTileDamage     = 0f;
        comet.splashRadius        = 1;
        comet.impactSound         = "Meteor_Large_Impact";
        comet.flyingSoundID       = 2;
        comet.explosionEffectHash = SpawnFXHashes.MeteorImpactDirt;
        PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>();

        primaryElement.SetElement(SimHashes.Regolith);
        primaryElement.Temperature = (comet.temperatureRange.x + comet.temperatureRange.y) / 2f;
        KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            Assets.GetAnim("meteor_rock_kanim")
        };
        kBatchedAnimController.isMovable   = true;
        kBatchedAnimController.initialAnim = "fall_loop";
        kBatchedAnimController.initialMode = KAnim.PlayMode.Loop;
        KCircleCollider2D kCircleCollider2D = gameObject.AddOrGet <KCircleCollider2D>();

        kCircleCollider2D.radius = 0.5f;
        return(gameObject);
    }
Пример #26
0
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreateEntity(ID, UI.SPACEDESTINATIONS.COMETS.GOLDCOMET.NAME, true);

        gameObject.AddOrGet <SaveLoadRoot>();
        gameObject.AddOrGet <LoopingSounds>();
        Comet comet = gameObject.AddOrGet <Comet>();

        comet.massRange           = new Vector2(3f, 20f);
        comet.temperatureRange    = new Vector2(323.15f, 423.15f);
        comet.explosionOreCount   = new Vector2I(2, 4);
        comet.entityDamage        = 15;
        comet.totalTileDamage     = 0.5f;
        comet.splashRadius        = 1;
        comet.impactSound         = "Meteor_Medium_Impact";
        comet.flyingSoundID       = 1;
        comet.explosionEffectHash = SpawnFXHashes.MeteorImpactMetal;
        PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>();

        primaryElement.SetElement(SimHashes.GoldAmalgam);
        primaryElement.Temperature = (comet.temperatureRange.x + comet.temperatureRange.y) / 2f;
        KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            Assets.GetAnim("meteor_gold_kanim")
        };
        kBatchedAnimController.isMovable      = true;
        kBatchedAnimController.initialAnim    = "fall_loop";
        kBatchedAnimController.initialMode    = KAnim.PlayMode.Loop;
        kBatchedAnimController.visibilityType = KAnimControllerBase.VisibilityType.OffscreenUpdate;
        KCircleCollider2D kCircleCollider2D = gameObject.AddOrGet <KCircleCollider2D>();

        kCircleCollider2D.radius        = 0.5f;
        gameObject.transform.localScale = new Vector3(0.6f, 0.6f, 1f);
        return(gameObject);
    }
Пример #27
0
    public void InstanceComets()
    {
        int startX    = _startPositions[0];
        int startPosY = 10;

        for (int i = 0; i < 50; i++)
        {
            Comet comet = (Comet)cometScene.Instance();
            comet.speed = _speed;
            int shuffle = (int)Godot.GD.RandRange(50, 1024);
            if (i % 2 == 0)
            {
                comet.Position  = new Vector2(_startPositions[0] + shuffle, startPosY * i + 14);
                comet.direction = 1;
            }
            else
            {
                comet.Position        = new Vector2(_startPositions[1] - shuffle, startPosY * i + 14);
                comet.direction       = -1;
                comet.RotationDegrees = 180;
            }
            AddChild(comet);
        }
    }
Пример #28
0
    float probabilityOfKiling = 0.4f; //if == 1, then all asteroids are killing

    // Use this for initialization
    void Start()
    {
        c      = new Comet();
        player = GameObject.Find("SpaceShip");
        AddAsteroids();
    }
Пример #29
0
        static void Main(string[] args)
        {
            // Définition de l'équation différentielle à tester
            Func <double, double, double> equation          = (x, y) => - 2 * y * x;
            bool isIterationDetailsAsked                    = true;
            IFirstOrderDifferentialEquation equationToSolve = new FirstOrderEulerMethod(equation);

            // Test de la méthode d'Euler
            Console.WriteLine("Test méthode Euler :");
            equationToSolve.SetStartingPoint(0, 1);
            equationToSolve.SetComputeStep(0.1);
            double?result = equationToSolve.ComputeForGivenX(1.8, isIterationDetailsAsked);

            if (result.HasValue)
            {
                Console.WriteLine("Résultat du calcul : " + result);
                if (isIterationDetailsAsked)
                {
                    string details = equationToSolve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Test de la méthode de Cauchy
            Console.WriteLine("Test méthode Cauchy :");
            equationToSolve = new FirstOrderCauchyMethod(equation);
            equationToSolve.SetStartingPoint(0, 1);
            equationToSolve.SetComputeStep(0.1);
            result = equationToSolve.ComputeForGivenX(1.8, isIterationDetailsAsked);
            if (result.HasValue)
            {
                Console.WriteLine("Résultat du calcul : " + result);
                if (isIterationDetailsAsked)
                {
                    string details = equationToSolve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Test de la méthode de Heun
            Console.WriteLine("Test méthode Heun :");
            equationToSolve = new FirstOrderHeunMethod(equation);
            equationToSolve.SetStartingPoint(0, 1);
            equationToSolve.SetComputeStep(0.1);
            result = equationToSolve.ComputeForGivenX(1.8, isIterationDetailsAsked);
            if (result.HasValue)
            {
                Console.WriteLine("Résultat du calcul : " + result);
                if (isIterationDetailsAsked)
                {
                    string details = equationToSolve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Test de la méthode Runge-Kutta au 4ème ordre
            Console.WriteLine("Test méthode Runge-Kutta au 4ème ordre :");
            equationToSolve = new FirstOrderRungeKuttaMethod(equation);
            equationToSolve.SetStartingPoint(0, 1);
            equationToSolve.SetComputeStep(0.1);
            result = equationToSolve.ComputeForGivenX(1.8, isIterationDetailsAsked);
            if (result.HasValue)
            {
                Console.WriteLine("Résultat du calcul : " + result);
                if (isIterationDetailsAsked)
                {
                    string details = equationToSolve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }



            // Définition de l'équation différentielle à tester
            Func <double, double, double, double>[] equations = new Func <double, double, double, double>[]
            {
                (x, y, z) => - 2 * z,
                (x, y, z) => y - Math.Sin(x) * Math.Sin(x)
            };
            isIterationDetailsAsked = true;
            ISecondOrderDifferentialEquation equations2Solve = new SecondOrderEulerMethod(equations);

            // Test de la méthode de Euler 2ème ordre
            Console.WriteLine("Test méthode Euler 2ème ordre :");
            equations2Solve.SetStartingPoints(new double[3] {
                0, 1, 0
            });
            equations2Solve.SetComputeStep(0.05);
            double[] results = equations2Solve.ComputeForGivenX(0.5, isIterationDetailsAsked);
            if (results != null && results.Length > 0)
            {
                Console.WriteLine($"Résultat du calcul : y = {results[1]}, z = {results[2]}");
                if (isIterationDetailsAsked)
                {
                    string details = equations2Solve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }


            // Test de la méthode de Cauchy 2ème ordre
            Console.WriteLine("Test méthode Cauchy 2ème ordre :");
            equations2Solve = new SecondOrderCauchyMethod(equations);
            equations2Solve.SetStartingPoints(new double[3] {
                0, 1, 0
            });
            equations2Solve.SetComputeStep(0.05);
            results = equations2Solve.ComputeForGivenX(0.5, isIterationDetailsAsked);
            if (results != null && results.Length > 0)
            {
                Console.WriteLine($"Résultat du calcul : y = {results[1]}, z = {results[2]}");
                if (isIterationDetailsAsked)
                {
                    string details = equations2Solve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Test de la méthode de Heun 2ème ordre
            Console.WriteLine("Test méthode Heun 2ème ordre :");
            equations2Solve = new SecondOrderHeunMethod(equations);
            equations2Solve.SetStartingPoints(new double[3] {
                0, 1, 0
            });
            equations2Solve.SetComputeStep(0.05);
            results = equations2Solve.ComputeForGivenX(0.5, isIterationDetailsAsked);
            if (results != null && results.Length > 0)
            {
                Console.WriteLine($"Résultat du calcul : y = {results[1]}, z = {results[2]}");
                if (isIterationDetailsAsked)
                {
                    string details = equations2Solve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Test de la méthode de Runge-Kutta au 4ème ordre
            Console.WriteLine("Test méthode Runge-Kutta au 4ème ordre :");
            equations2Solve = new SecondOrderRungeKuttaMethod(equations);
            equations2Solve.SetStartingPoints(new double[3] {
                0, 1, 0
            });
            equations2Solve.SetComputeStep(0.05);
            results = equations2Solve.ComputeForGivenX(0.5, isIterationDetailsAsked);
            if (results != null && results.Length > 0)
            {
                Console.WriteLine($"Résultat du calcul : y = {results[1]}, z = {results[2]}");
                if (isIterationDetailsAsked)
                {
                    string details = equations2Solve.BuildFormatedComputationDetailsForDisplay();
                    if (details != null)
                    {
                        Console.WriteLine(details);
                    }
                }
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Calcul du zéro d'une fonction
            Func <double, double> equationToComputeZero        = (x) => Math.Exp(x) - 6 * x;
            Func <double, double> derivedEquationToComputeZero = (x) => Math.Exp(x) - 6;
            NewtonRaphsonMethod   zeroFinder = new NewtonRaphsonMethod(equationToComputeZero, derivedEquationToComputeZero);
            double?zero = zeroFinder.ComputeForZero(3, true);

            if (zero.HasValue)
            {
                Console.WriteLine($"Zéro trouvé : {zero.Value} en {zeroFinder.IterationNumberReached} iterations");
                Console.WriteLine(zeroFinder.BuildFormatedComputationDetailsForDisplay());
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Calcul d'une intégrale
            Func <double, double> equationToInteger = (x) => Math.Exp(-x) + 2 * x;
            SimpsonMethod         integral          = new SimpsonMethod(equationToInteger);

            integral.SetIterationNumber(100);
            double?computedIntegral = integral.ComputeIntegral(2, 6);

            if (computedIntegral.HasValue)
            {
                Console.WriteLine($"Intégrale : {computedIntegral.Value}");
            }
            else
            {
                Console.WriteLine("Calcul impossible");
            }

            // Calcul d'une comète
            Comet comet      = new Comet(0.5, 0.95, 1.0, 0.03);
            var   tailResult = comet.ComputeSyndynams(-114.5916);


            Console.ReadKey();
        }
Пример #30
0
 private void RangeSelector_ValueChanged(object sender, Comet.Controls.RangeChangedEventArgs e)
 {
     Debug.WriteLine("Changed: " + e.ChangedRangeProperty);
     Debug.WriteLine("OldValue: " + e.OldValue + " NewValue: " + e.NewValue);
 }
Пример #31
0
        private void listView_PullProgressChanged(object sender, Comet.Controls.RefreshProgressEventArgs e)
        {
            refreshindicator.Opacity = e.PullProgress;

            refreshindicator.Background = e.PullProgress < 1.0 ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Blue);
        }
 private static void Prefix(Comet __instance)
 {
     __instance.FindOrAdd <TrackedComet>();
 }
Пример #33
0
        private void listView_PullProgressChanged(object sender, Comet.Controls.RefreshProgressEventArgs e)
        {
            if (e.PullProgress < 0.5) transform.RotationX = 0;
            else transform.RotationX = 180 * ((e.PullProgress - 0.5) * 2);

            refreshText.Visibility = e.PullProgress < 1 ? Visibility.Collapsed : Visibility.Visible;
        }