Ejemplo n.º 1
0
 protected override void OnPrepare(GameState prev, object[] parms)
 {
     this._rnd   = new Random();
     this._crits = new GameObjectSet(this.App);
     this._sky   = new Sky(this.App, SkyUsage.InSystem, 0);
     this._crits.Add((IGameObject)this._sky);
     this._camera = this._crits.Add <OrbitCameraController>();
     this._input  = this._crits.Add <CombatInput>();
     this._grid   = this._crits.Add <CombatGrid>();
 }
Ejemplo n.º 2
0
        public static Combat Create(
            App game,
            OrbitCameraController cameraController,
            CombatInput input,
            CombatSensor sensor,
            StarSystem system,
            CombatGrid grid,
            Vector3 origin,
            float radius,
            int duration,
            Player[] players,
            Dictionary <Player, Dictionary <Player, PlayerCombatDiplomacy> > diplomacyStates,
            bool simulateOnly = false)
        {
            List <int>    list       = ((IEnumerable <Player>)players).Where <Player>((Func <Player, bool>)(x => !x.IsStandardPlayer)).Select <Player, int>((Func <Player, int>)(x => x.ObjectID)).ToList <int>();
            Combat        combat     = new Combat();
            List <object> objectList = new List <object>();

            objectList.Add((object)cameraController.GetObjectID());
            objectList.Add((object)input.GetObjectID());
            objectList.Add((object)sensor.GetObjectID());
            objectList.Add((object)system.GetObjectID());
            objectList.Add((object)grid.GetObjectID());
            objectList.Add((object)origin);
            objectList.Add((object)radius);
            objectList.Add((object)duration);
            objectList.Add((object)game.LocalPlayer.GetObjectID());
            objectList.Add((object)simulateOnly);
            objectList.Add((object)players.Length);
            foreach (Player player in players)
            {
                objectList.Add((object)player.ObjectID);
            }
            objectList.Add((object)diplomacyStates.Count);
            foreach (KeyValuePair <Player, Dictionary <Player, PlayerCombatDiplomacy> > diplomacyState in diplomacyStates)
            {
                objectList.Add((object)diplomacyState.Key.GetObjectID());
                objectList.Add((object)diplomacyState.Value.Count);
                foreach (KeyValuePair <Player, PlayerCombatDiplomacy> keyValuePair in diplomacyState.Value)
                {
                    objectList.Add((object)keyValuePair.Key.GetObjectID());
                    objectList.Add((object)keyValuePair.Value);
                }
            }
            objectList.Add((object)list.Count);
            foreach (int num in list)
            {
                objectList.Add((object)num);
            }
            game.AddExistingObject((IGameObject)combat, objectList.ToArray());
            return(combat);
        }
Ejemplo n.º 3
0
 protected override void OnPrepare(GameState prev, object[] parms)
 {
     this._crits = new GameObjectSet(this.App);
     this._crits.Add((IGameObject) new Sky(this.App, SkyUsage.InSystem, 0));
     this._camera = this._crits.Add <OrbitCameraController>();
     this._camera.DesiredDistance   = 30f;
     this._combatGrid               = this._crits.Add <CombatGrid>();
     this._combatGrid.GridSize      = 5000f;
     this._combatGrid.CellSize      = 500f;
     this._combatInput              = this._crits.Add <CombatInput>();
     this._combatInput.CameraID     = this._camera.ObjectID;
     this._combatInput.CombatGridID = this._combatGrid.ObjectID;
     this._bigbad           = this._crits.Add <StaticModel>((object)"\\base\\factions\\zuul\\models\\Suul'ka\\suulka_test.scene");
     this._litmus1          = this._crits.Add <StaticModel>((object)"\\base\\props\\litmus_01.scene");
     this._litmus2          = this._crits.Add <StaticModel>((object)"\\base\\props\\litmus_02.scene");
     this._litmus3          = this._crits.Add <StaticModel>((object)"\\base\\props\\litmus_03.scene");
     this._bigbad.Position  = new Vector3(0.0f, -800f, 0.0f);
     this._litmus1.Position = new Vector3(-300f, 0.0f, 0.0f);
     this._litmus2.Position = new Vector3(0.0f, 0.0f, 0.0f);
     this._litmus3.Position = new Vector3(300f, 0.0f, 0.0f);
 }
Ejemplo n.º 4
0
        protected override void OnEnter()
        {
            base.OnEnter();
            this.App.UI.SetScreen("DefenseManager");
            this._finishing = false;
            this._dmcrits.Activate();
            this.Camera.DesiredDistance = 150000f;
            this.Camera.DesiredPitch    = MathHelper.DegreesToRadians(-45f);
            this.Camera.MaxDistance     = 500000f;
            this._manager.PostSetProp("SetStarSystem", (IGameObject)this._starsystem);
            this._manager.PostSetProp("SyncFleetList", this.App.UI.Path("fleetDetailsWidget", "gameFleetList"));
            this._manager.PostSetProp("LocalPlayerObjectID", this.App.LocalPlayer.ObjectID);
            this._manager.PostSetProp("SetFleetWidget", (IGameObject)this._fleetWidget);
            this._manager.PostSetProp("SetDefenseWidget", (IGameObject)this._defenseWidget);
            this._manager.Active = true;
            float width  = this.App.AssetDatabase.MineFieldParams.Width;
            float length = this.App.AssetDatabase.MineFieldParams.Length;

            this._manager.PostSetProp("SetMinefieldSize", (object)(Math.Sqrt((double)length * (double)length + (double)width * (double)width) + 500.0), (object)(double)this.App.AssetDatabase.PolicePatrolRadius);
            this.SyncFleetShipModels();
            this._starsystem.PostSetProp("AutoDrawEnabled", false);
            this._starsystem.PostSetProp("ZoneMapEnabled", true);
            this._starsystem.PostSetProp("ZoneFocusEnabled", true);
            this._input = new CombatInput();
            this._dmcrits.Add((IGameObject)this._input);
            this._fleetWidget.PreferredSelectMode = true;
            List <FleetInfo> list = this.App.GameDatabase.GetFleetsByPlayerAndSystem(this.App.LocalPlayer.ID, this._targetSystemID, FleetType.FL_NORMAL | FleetType.FL_RESERVE | FleetType.FL_DEFENSE).ToList <FleetInfo>();

            list.RemoveAll((Predicate <FleetInfo>)(x => Kerberos.Sots.StarFleet.StarFleet.IsGardenerFleet(this.App.Game, x)));
            this._fleetWidget.SetSyncedFleets(list);
            if (this._targetSystemID != 0)
            {
                this._fleetWidget.ListStations = true;
                this._fleetWidget.SetSyncedStations(this.App.GameDatabase.GetStationForSystemAndPlayer(this._targetSystemID, this.App.LocalPlayer.ID).ToList <StationInfo>());
            }
            this._defenseWidget.SetSyncedFleet(this.App.GameDatabase.InsertOrGetDefenseFleetInfo(this._targetSystemID, this.App.LocalPlayer.ID).ID);
            this.SyncPlanetTypeInfo();
            this.SyncSDBSlots();
            this.App.HotKeyManager.AddListener((IKeyBindListener)this);
        }
Ejemplo n.º 5
0
        protected override void OnPrepare(GameState prev, object[] parms)
        {
            this.App.NewGame();
            this._crits  = new GameObjectSet(this.App);
            this._sky    = new Sky(this.App, SkyUsage.InSystem, 0);
            this._camera = this._crits.Add <OrbitCameraController>();
            this._camera.TargetPosition = new Vector3(0.0f, 0.0f, 0.0f);
            this._combatInput           = this._crits.Add <CombatInput>();
            this._combatGrid            = this._crits.Add <CombatGrid>();
            CreateShipParams createShipParams = new CreateShipParams();

            createShipParams.player   = this.App.LocalPlayer;
            createShipParams.sections = this.App.AssetDatabase.ShipSections.Where <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x =>
            {
                if (!(x.Faction == "morrigi") || x.Class != ShipClass.Cruiser)
                {
                    return(false);
                }
                if (!x.FileName.Contains("cr_cmd.section") && !x.FileName.Contains("cr_eng_fusion.section"))
                {
                    return(x.FileName.Contains("cr_mis_armor.section"));
                }
                return(true);
            }));
            createShipParams.turretHousings   = this.App.AssetDatabase.TurretHousings;
            createShipParams.weapons          = this.App.AssetDatabase.Weapons;
            createShipParams.preferredWeapons = this.App.AssetDatabase.Weapons;
            createShipParams.modules          = this.App.AssetDatabase.Modules;
            createShipParams.preferredModules = this.App.AssetDatabase.Modules;
            createShipParams.psionics         = this.App.AssetDatabase.Psionics;
            createShipParams.faction          = this.App.AssetDatabase.GetFaction("morrigi");
            createShipParams.shipName         = "BOOGER";
            createShipParams.inputID          = this._combatInput.ObjectID;
            this._ship = Ship.CreateShip(this.App, createShipParams);
            this._crits.Add((IGameObject)this._ship);
            this._ship2          = Ship.CreateShip(this.App, createShipParams);
            this._ship2.Position = new Vector3(1000f, 0.0f, 0.0f);
            this._crits.Add((IGameObject)this._ship2);
        }
Ejemplo n.º 6
0
        public void Enter(App app)
        {
            this._app = app;
            if (this._app.GameDatabase == null)
            {
                this._app.NewGame();
            }
            app.Game.SetLocalPlayer(app.GetPlayer(1));
            this._set = new GameObjectSet(app);
            this._postLoadedObjects = new List <IGameObject>();
            this._set.Add((IGameObject) new Sky(app, SkyUsage.InSystem, new Random().Next()));
            if (ScriptHost.AllowConsole)
            {
                this._input = this._set.Add <CombatInput>();
            }
            this._camera = this._set.Add <OrbitCameraController>();
            this._camera.SetAttractMode(true);
            this._camera.TargetPosition  = new Vector3(500000f, 0.0f, 0.0f);
            this._camera.MinDistance     = 1f;
            this._camera.MaxDistance     = 11000f;
            this._camera.DesiredDistance = 11000f;
            this._camera.DesiredPitch    = MathHelper.DegreesToRadians(-2f);
            this._camera.DesiredYaw      = MathHelper.DegreesToRadians(45f);
            int systemId = 0;
            IEnumerable <HomeworldInfo> homeworlds = this._app.GameDatabase.GetHomeworlds();
            HomeworldInfo homeworldInfo            = homeworlds.FirstOrDefault <HomeworldInfo>((Func <HomeworldInfo, bool>)(x => x.PlayerID == app.LocalPlayer.ID));

            if (homeworldInfo != null)
            {
                systemId = homeworldInfo.SystemID;
            }
            else if (homeworlds.Count <HomeworldInfo>() > 0)
            {
                systemId = homeworlds.ElementAt <HomeworldInfo>(new Random().NextInclusive(0, homeworlds.Count <HomeworldInfo>() - 1)).SystemID;
            }
            this._starsystem = new StarSystem(this._app, 1f, systemId, new Vector3(0.0f, 0.0f, 0.0f), false, (CombatSensor)null, true, 0, false, true);
            this._set.Add((IGameObject)this._starsystem);
            this._starsystem.PostSetProp("InputEnabled", false);
            this._starsystem.PostSetProp("RenderSuroundingItems", false);
            Vector3 vector1 = new Vector3();
            float   num1    = 10000f;
            IEnumerable <PlanetInfo> infosOrbitingStar = this._app.GameDatabase.GetPlanetInfosOrbitingStar(systemId);
            bool flag1 = false;

            foreach (PlanetInfo planetInfo in infosOrbitingStar)
            {
                if (planetInfo != null)
                {
                    ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID);
                    if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this._app.LocalPlayer.ID)
                    {
                        vector1 = this._app.GameDatabase.GetOrbitalTransform(planetInfo.ID).Position;
                        num1    = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
                        flag1   = true;
                        break;
                    }
                }
            }
            if (!flag1)
            {
                PlanetInfo[] array = infosOrbitingStar.ToArray <PlanetInfo>();
                if (array.Length > 0)
                {
                    PlanetInfo planetInfo = array[new Random().Next(array.Length)];
                    vector1 = this._app.GameDatabase.GetOrbitalTransform(planetInfo.ID).Position;
                    num1    = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
                }
            }
            this._camera.DesiredYaw     = -(float)Math.Atan2((double)vector1.Z, (double)vector1.X);
            this._camera.TargetPosition = vector1;
            Matrix rotationYpr = Matrix.CreateRotationYPR(this._camera.DesiredYaw, 0.0f, 0.0f);

            Vector3[] shuffledPlayerColors = Player.GetShuffledPlayerColors(this._rand);
            foreach (string index in this._players.Keys.ToList <string>())
            {
                this._players[index] = new Player(app, app.Game, new PlayerInfo()
                {
                    FactionID       = app.GameDatabase.GetFactionIdFromName(index),
                    AvatarAssetPath = string.Empty,
                    BadgeAssetPath  = app.AssetDatabase.GetRandomBadgeTexture(index, this._rand),
                    PrimaryColor    = shuffledPlayerColors[0],
                    SecondaryColor  = new Vector3(this._rand.NextSingle(), this._rand.NextSingle(), this._rand.NextSingle())
                }, Player.ClientTypes.AI);
                this._set.Add((IGameObject)this._players[index]);
            }
            Vector3        zero         = Vector3.Zero;
            double         num2         = (double)Vector3.Cross(vector1, new Vector3(0.0f, 1f, 0.0f)).Normalize();
            float          num3         = 500f;
            int            num4         = 4;
            float          num5         = num3 * (float)num4;
            Vector3        vector3_1    = new Vector3(-num5, 0.0f, -num5);
            Vector3        vector3_2    = vector1 + -rotationYpr.Forward * (num1 + 2000f + num5);
            List <Vector3> vector3List1 = new List <Vector3>();

            for (int index = 0; index < 81; ++index)
            {
                int     num6      = index % 5;
                int     num7      = index / 5;
                Vector3 vector3_3 = new Vector3(vector3_1.X + (float)num7 * num3, 0.0f, vector3_1.Z + (float)num6 * num3);
                vector3_3 += vector3_2;
                vector3List1.Add(vector3_3);
            }
            List <Vector3> vector3List2 = new List <Vector3>();

            foreach (Vector3 pos in vector3List1)
            {
                if (this.PositionCollidesWithObject(pos, 400f))
                {
                    vector3List2.Add(pos);
                }
            }
            foreach (Vector3 vector3_3 in vector3List2)
            {
                vector3List1.Remove(vector3_3);
            }
            int        num8    = this._rand.NextInclusive(6, 12);
            List <int> intList = new List <int>();

            for (int index1 = 0; index1 < num8; ++index1)
            {
                int  index2 = 0;
                bool flag2  = true;
                for (int index3 = 0; flag2 && index3 < vector3List1.Count; ++index3)
                {
                    index2 = this._rand.NextInclusive(0, Math.Max(vector3List1.Count - 1, 0));
                    flag2  = intList.Contains(index2);
                    if (intList.Count == vector3List1.Count)
                    {
                        break;
                    }
                }
                Vector3 off = vector3List1.Count > 0 ? vector3List1[index2] : vector1;
                if (index1 < 3)
                {
                    zero += this.CreateRandomShip(off, "loa", index1 == 0);
                }
                else
                {
                    zero += this.CreateRandomShip(off, "", false);
                }
                if (!intList.Contains(index2))
                {
                    intList.Add(index2);
                }
            }
            if (num8 <= 0)
            {
                return;
            }
            Vector3 vector3_4 = zero / (float)num8;
        }