Ejemplo n.º 1
0
        public override void HandleScriptMessage(ScriptMessageReader mr)
        {
            switch (mr.ReadInteger())
            {
            case 0:
                this._success = mr.ReadBool();
                this.ShowButton(true);
                break;

            case 2:
                this.AddDialogString(App.Localize("@GAMESPY_CONNECTING"));
                break;

            case 3:
                this.AddDialogString(App.Localize("@GAMESPY_CONNECT_FAILED"));
                break;

            case 4:
                this.AddDialogString(App.Localize("@GAMESPY_INVALID_PASS"));
                break;

            case 5:
                this.AddDialogString(App.Localize("@INVALID_USERNAME_TEXT"));
                break;

            case 9:
                this.AddDialogString(App.Localize("@GAMESPY_CONNECT_CHAT_FAILED"));
                break;

            case 10:
                this.AddDialogString(App.Localize("@GAMESPY_CONNECTED"));
                break;
            }
        }
Ejemplo n.º 2
0
        public override bool OnEngineMessage(InteropMessageID messageID, ScriptMessageReader message)
        {
            switch (messageID)
            {
            case InteropMessageID.IMID_SCRIPT_MANEUVER_INFO:
                this.m_CurrentPosition.X = message.ReadSingle();
                this.m_CurrentPosition.Y = message.ReadSingle();
                this.m_CurrentPosition.Z = message.ReadSingle();
                this.m_Facing.X          = message.ReadSingle();
                this.m_Facing.Y          = message.ReadSingle();
                this.m_Facing.Z          = message.ReadSingle();
                this.HasReceivedAnUpdate = true;
                return(true);

            case InteropMessageID.IMID_SCRIPT_FORMATION_REMOVE_SHIP:
                int shipID = message.ReadInteger();
                if (this._parentShipFormation != null)
                {
                    this._parentShipFormation.RemoveShip(shipID);
                }
                return(true);

            default:
                App.Log.Warn("Unhandled message (id=" + (object)messageID + ") in FormationDefinition.", "combat");
                return(false);
            }
        }
Ejemplo n.º 3
0
        public override void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
        {
            switch (messageID)
            {
            case InteropMessageID.IMID_SCRIPT_OBJECT_RELEASE:
                this.RemoveObject(mr);
                break;

            case InteropMessageID.IMID_SCRIPT_OBJECTS_RELEASE:
                this.RemoveObjects(mr);
                break;

            case InteropMessageID.IMID_SCRIPT_SYNC_FLEET_POSITIONS:
                mr.ReadInteger();
                int num = mr.ReadInteger();
                for (int index = 0; index < num; ++index)
                {
                    bool flag = mr.ReadBool();
                    this.App.GameDatabase.UpdateShipFleetPosition(mr.ReadInteger(), !flag ? new Vector3?() : new Vector3?(new Vector3(mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle())));
                }
                if (!this._finalSync)
                {
                    break;
                }
                this.App.SwitchGameState <StarMapState>();
                break;
            }
        }
Ejemplo n.º 4
0
 public void RemoveObjects(ScriptMessageReader data)
 {
     for (int id = data.ReadInteger(); id != 0; id = data.ReadInteger())
     {
         IGameObject gameObject1 = this._set.Objects.FirstOrDefault <IGameObject>((Func <IGameObject, bool>)(x =>
         {
             if (x.ObjectID == id)
             {
                 return(x is IDisposable);
             }
             return(false);
         }));
         if (gameObject1 != null)
         {
             (gameObject1 as IDisposable).Dispose();
             this._set.Remove(gameObject1);
         }
         else
         {
             IGameObject gameObject2 = this._app.GetGameObject(id);
             if (gameObject2 != null)
             {
                 this._app.ReleaseObject(gameObject2);
             }
         }
     }
 }
Ejemplo n.º 5
0
        public override void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
        {
            switch (messageID)
            {
            case InteropMessageID.IMID_SCRIPT_OBJECT_ADD:
                if (this._scene == null)
                {
                    break;
                }
                this._scene.AddObject(mr);
                break;

            case InteropMessageID.IMID_SCRIPT_OBJECT_RELEASE:
                if (this._scene == null)
                {
                    break;
                }
                this._scene.RemoveObject(mr);
                break;

            case InteropMessageID.IMID_SCRIPT_OBJECTS_RELEASE:
                if (this._scene == null)
                {
                    break;
                }
                this._scene.RemoveObjects(mr);
                break;

            default:
                App.Log.Warn("Unhandled message (id=" + (object)messageID + ").", "engine");
                break;
            }
        }
Ejemplo n.º 6
0
        public override void HandleScriptMessage(ScriptMessageReader mr)
        {
            switch ((Network.DialogAction)mr.ReadInteger())
            {
            case Network.DialogAction.DA_FINALIZE:
                this._success = mr.ReadBool();
                this.ShowButton(true);
                break;

            case Network.DialogAction.DA_NEWUSER_CREATING:
                this.AddDialogString(App.Localize("@NETWORKDIALOG_CREATE_NEW_USER"));
                break;

            case Network.DialogAction.DA_NEWUSER_INVALID_USERNAME:
                this.AddDialogString(App.Localize("@NETWORKDIALOG_INVALID_USERNAME"));
                break;

            case Network.DialogAction.DA_NEWUSER_NICK_IN_USE:
                this.AddDialogString("Nickname in use.");
                break;

            case Network.DialogAction.DA_NEWUSER_INVALID_PASSWORD:
                this.AddDialogString(App.Localize("@NETWORKDIALOG_INVALID_PASSWORD"));
                break;

            case Network.DialogAction.DA_NEWUSER_FAILED:
                this.AddDialogString(App.Localize("@NETWORKDIALOG_USER_CREATION_FAILED"));
                break;

            case Network.DialogAction.DA_NEWUSER_SUCCESS:
                this.AddDialogString(App.Localize("@NETWORKDIALOG_NEW_USER_CREATED"));
                break;
            }
        }
Ejemplo n.º 7
0
 protected void RemoveObjects(ScriptMessageReader data)
 {
     for (int id = data.ReadInteger(); id != 0; id = data.ReadInteger())
     {
         this.RemoveGameObject(this.App.GetGameObject(id));
     }
 }
Ejemplo n.º 8
0
 public static DamagePattern FromDatabaseString(string base64String)
 {
     using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(base64String)))
     {
         using (ScriptMessageReader r = new ScriptMessageReader(true, stream))
             return(DamagePattern.Read(r));
     }
 }
Ejemplo n.º 9
0
        public PlayerCombatData(ScriptMessageReader mr, int version)
        {
            this._playerID      = mr.ReadInteger();
            this._victoryStatus = (GameSession.VictoryStatus)mr.ReadInteger();
            this.Construct();
            int num1 = mr.ReadInteger();

            for (int index = 0; index < num1; ++index)
            {
                this._shipData.Add(new Kerberos.Sots.Strategy.ShipData()
                {
                    designID       = mr.ReadInteger(),
                    damageDealt    = mr.ReadSingle(),
                    damageReceived = mr.ReadSingle(),
                    killCount      = mr.ReadInteger(),
                    destroyed      = mr.ReadBool()
                });
            }
            int num2 = mr.ReadInteger();

            for (int index1 = 0; index1 < num2; ++index1)
            {
                Kerberos.Sots.Strategy.PlanetData planetData = new Kerberos.Sots.Strategy.PlanetData();
                planetData.orbitalObjectID = mr.ReadInteger();
                planetData.imperialDamage  = mr.ReadDouble();
                int num3 = mr.ReadInteger();
                planetData.civilianDamage = new List <PopulationData>();
                for (int index2 = 0; index2 < num3; ++index2)
                {
                    PopulationData populationData = new PopulationData()
                    {
                        faction = mr.ReadString(),
                        damage  = mr.ReadDouble()
                    };
                }
                planetData.infrastructureDamage = mr.ReadSingle();
                planetData.terraDamage          = mr.ReadSingle();
                this._planetData.Add(planetData);
            }
            int num4 = mr.ReadInteger();

            for (int index = 0; index < num4; ++index)
            {
                this._weaponData.Add(new Kerberos.Sots.Strategy.WeaponData()
                {
                    weaponID    = mr.ReadInteger(),
                    damageDealt = mr.ReadSingle()
                });
            }
            if (version >= 1)
            {
                this._fleetCount = mr.ReadInteger();
            }
            else
            {
                this._fleetCount = 0;
            }
        }
Ejemplo n.º 10
0
 public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
 {
     if (messageId != InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP || !(message.ReadString() == "Position"))
     {
         return(false);
     }
     this._position = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
     return(true);
 }
Ejemplo n.º 11
0
        public void AddObject(ScriptMessageReader data)
        {
            InteropGameObjectType interopGameObjectType = (InteropGameObjectType)data.ReadInteger();
            IGameObject           gameObject            = (IGameObject)null;

            if (gameObject == null)
            {
                return;
            }
            this._postLoadedObjects.Add(gameObject);
        }
Ejemplo n.º 12
0
        public CombatData(ScriptMessageReader mr, int version)
        {
            this.Construct();
            this._combatID = mr.ReadInteger();
            this._systemID = mr.ReadInteger();
            this._turn     = mr.ReadInteger();
            int num = mr.ReadInteger();

            for (int index = 0; index < num; ++index)
            {
                this._data.Add(new PlayerCombatData(mr, version));
            }
        }
Ejemplo n.º 13
0
 public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
 {
     if (base.OnEngineMessage(messageId, message))
     {
         return(true);
     }
     if (messageId != InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP || !(message.ReadString() == "WeaponToggleStateChanged"))
     {
         return(false);
     }
     this.m_ToggleStateOn = message.ReadBool();
     return(true);
 }
Ejemplo n.º 14
0
 public override void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
 {
     if (messageID == InteropMessageID.IMID_SCRIPT_MOVE_ORDER)
     {
         if (this.GetCommanderForPlayerID(mr.ReadInteger()) == null)
         {
             ;
         }
     }
     else
     {
         base.OnEngineMessage(messageID, mr);
     }
 }
Ejemplo n.º 15
0
        public static DamagePattern Read(ScriptMessageReader r)
        {
            int width   = r.ReadInteger();
            int height  = r.ReadInteger();
            int originX = r.ReadInteger();
            int originY = r.ReadInteger();
            int size    = DamagePattern.GetSize(DamagePattern.GetStride(width), height);

            byte[] initialData = new byte[size];
            for (int index = 0; index < size; index += 4)
            {
                DamagePattern.FourCCToBytes((uint)r.ReadInteger(), out initialData[index], out initialData[index + 1], out initialData[index + 2], out initialData[index + 3]);
            }
            return(new DamagePattern(width, height, originX, originY, initialData));
        }
Ejemplo n.º 16
0
        public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
        {
            InteropMessageID interopMessageId = messageId;

            if (messageId == InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP)
            {
                if (message.ReadString() == "BeamFinished")
                {
                    this.m_Finished  = true;
                    this.m_Succeeded = message.ReadInteger() == 1;
                    this.m_Resources = message.ReadInteger();
                }
                return(true);
            }
            App.Log.Warn("Unhandled message (id=" + (object)interopMessageId + ").", "combat");
            return(base.OnEngineMessage(messageId, message));
        }
Ejemplo n.º 17
0
 public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
 {
     if (messageId == InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP)
     {
         if (message.ReadString() == "PlanetPopUpdate")
         {
             this.Population           = message.ReadDouble();
             this._lastAttackingObject = this.App.GetGameObject(message.ReadInteger());
             return(true);
         }
     }
     else
     {
         App.Log.Warn("Unhandled message (id=" + (object)messageId + ").", "game");
     }
     return(false);
 }
Ejemplo n.º 18
0
 public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
 {
     if (messageId == InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP)
     {
         string str = message.ReadString();
         if (str == "Update")
         {
             this._percentConsumed = message.ReadSingle();
             return(true);
         }
         if (str == "IsActive")
         {
             this._isActive = message.ReadBool();
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 19
0
        public CombatData GetCombat(GameDatabase db, int combatID, int systemID, int turn)
        {
            foreach (CombatData combatData in this._combatData)
            {
                if (combatData.CombatID == combatID && combatData.SystemID == systemID && combatData.Turn == turn)
                {
                    return(combatData);
                }
            }
            int version = 0;
            ScriptMessageReader combatData1 = db.GetCombatData(systemID, combatID, turn, out version);

            if (combatData1 == null)
            {
                return((CombatData)null);
            }
            this.AddCombat(combatData1, version);
            return(this.GetLastCombat());
        }
Ejemplo n.º 20
0
        public void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
        {
            switch (messageID)
            {
            case InteropMessageID.IMID_SCRIPT_SET_PAUSE_STATE:
            case InteropMessageID.IMID_SCRIPT_SET_COMBAT_ACTIVE:
            case InteropMessageID.IMID_SCRIPT_PLAYER_DIPLO_CHANGED:
            case InteropMessageID.IMID_SCRIPT_ZONE_OWNER_CHANGED:
            case InteropMessageID.IMID_SCRIPT_OBJECT_ADD:
            case InteropMessageID.IMID_SCRIPT_OBJECTS_ADD:
            case InteropMessageID.IMID_SCRIPT_OBJECT_RELEASE:
            case InteropMessageID.IMID_SCRIPT_OBJECTS_RELEASE:
            case InteropMessageID.IMID_SCRIPT_COMBAT_ENDED:
            case InteropMessageID.IMID_SCRIPT_START_SENDINGDATA:
            case InteropMessageID.IMID_SCRIPT_COMBAT_DATA_SHIP:
            case InteropMessageID.IMID_SCRIPT_COMBAT_DATA_PLANET:
            case InteropMessageID.IMID_SCRIPT_COMBAT_DATA_STAR:
            case InteropMessageID.IMID_SCRIPT_COMBAT_DESTROYED_SHIPS:
            case InteropMessageID.IMID_SCRIPT_COMBAT_CAPTURED_SHIPS:
            case InteropMessageID.IMID_SCRIPT_COMBAT_WEAPON_DAMAGE_STATS:
            case InteropMessageID.IMID_SCRIPT_COMBAT_ZONE_STATES:
            case InteropMessageID.IMID_SCRIPT_END_SENDINGDATA:
            case InteropMessageID.IMID_SCRIPT_END_DELAYCOMPLETE:
            case InteropMessageID.IMID_SCRIPT_SYNC_FLEET_POSITIONS:
            case InteropMessageID.IMID_SCRIPT_SYNC_DEFENSE_POSITIONS:
            case InteropMessageID.IMID_SCRIPT_SYNC_DEFENSEBOAT_DATA:
                this._currentGameState.OnEngineMessage(messageID, mr);
                break;

            case InteropMessageID.IMID_SCRIPT_MOVE_ORDER:
                if (!(this._currentGameState is CombatState))
                {
                    break;
                }
                this._currentGameState.OnEngineMessage(messageID, mr);
                break;

            default:
                App.Log.Warn("Unhandled message (id=" + (object)messageID + ").", "state");
                break;
            }
        }
Ejemplo n.º 21
0
        public override void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
        {
            switch (messageID)
            {
            case InteropMessageID.IMID_SCRIPT_SYNC_DEFENSE_POSITIONS:
                int num1 = mr.ReadInteger();
                for (int index1 = 0; index1 < num1; ++index1)
                {
                    mr.ReadInteger();
                    int num2 = mr.ReadInteger();
                    for (int index2 = 0; index2 < num2; ++index2)
                    {
                        if (mr.ReadBool())
                        {
                            bool flag = mr.ReadBool();
                            this.App.GameDatabase.UpdateShipSystemPosition(mr.ReadInteger(), !flag ? new Matrix?() : new Matrix?(new Matrix(mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle(), mr.ReadSingle())));
                        }
                    }
                }
                if (this._finishing)
                {
                    this.App.SwitchGameState <StarMapState>();
                    break;
                }
                break;

            case InteropMessageID.IMID_SCRIPT_SYNC_DEFENSEBOAT_DATA:
                int shipID    = mr.ReadInteger();
                int OrbitalID = mr.ReadInteger();
                this.App.GameDatabase.RemoveSDBByShipID(shipID);
                if (OrbitalID != 0)
                {
                    this.App.GameDatabase.InsertSDB(OrbitalID, shipID);
                    break;
                }
                break;
            }
            base.OnEngineMessage(messageID, mr);
        }
Ejemplo n.º 22
0
        public override void HandleScriptMessage(ScriptMessageReader mr)
        {
            switch ((Network.DialogAction)mr.ReadInteger())
            {
            case Network.DialogAction.DA_FINALIZE:
                this._success = mr.ReadBool();
                this._app.UI.CloseDialog((Dialog)this, true);
                break;

            case Network.DialogAction.DA_RAW_STRING:
                this.AddString(mr.ReadString());
                break;

            case Network.DialogAction.DA_CONNECT_CONNECTING:
                this.AddString("Connecting to Host.");
                break;

            case Network.DialogAction.DA_CONNECT_FAILED:
                this.AddString("Failed to connect to Host.");
                break;

            case Network.DialogAction.DA_CONNECT_SUCCESS:
                this.AddString("Connection to Host succeeded.");
                break;

            case Network.DialogAction.DA_CONNECT_TIMED_OUT:
                this.AddString("Connection to Host timed out.");
                break;

            case Network.DialogAction.DA_CONNECT_INVALID_PASSWORD:
                this.AddString("Invalid password.");
                break;

            case Network.DialogAction.DA_CONNECT_NAT_FAILURE:
                this.AddString("NAT Negotiation failed.");
                break;
            }
        }
Ejemplo n.º 23
0
        public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
        {
            switch (messageId)
            {
            case InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP:
                string str = message.ReadString();
                if (str == "Position")
                {
                    this._position = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                    return(true);
                }
                if (str == "ShipSpeedScale")
                {
                    this._shipSpeedState = (ShipSpeedState)message.ReadInteger();
                    return(true);
                }
                if (str == "TargetFacingAngle")
                {
                    this._targetFacingAngle = (TargetFacingAngle)message.ReadInteger();
                    return(true);
                }
                break;

            case InteropMessageID.IMID_SCRIPT_MANEUVER_INFO:
                this._position    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._rotation    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._velocity    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._destination = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                return(true);

            default:
                App.Log.Warn("Unhandled message (id=" + (object)messageId + ").", "combat");
                break;
            }
            return(false);
        }
Ejemplo n.º 24
0
 public override void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr)
 {
 }
Ejemplo n.º 25
0
 public void AddCombat(ScriptMessageReader mr, int version)
 {
     this._combatData.Add(new CombatData(mr, version));
 }
Ejemplo n.º 26
0
 public abstract void OnEngineMessage(InteropMessageID messageID, ScriptMessageReader mr);
Ejemplo n.º 27
0
 protected void RemoveObject(ScriptMessageReader data)
 {
     this.RemoveGameObject(this.App.GetGameObject(data.ReadInteger()));
 }
Ejemplo n.º 28
0
 public override void HandleScriptMessage(ScriptMessageReader mr)
 {
 }
Ejemplo n.º 29
0
 public virtual void HandleScriptMessage(ScriptMessageReader mr)
 {
 }