コード例 #1
0
        public void ClearTest()
        {
            var br = new ByteReader(new byte[10], 5, 5);

            br.Clear();
            Assert.AreEqual(0, br.Offset);
        }
コード例 #2
0
        private BattleMapPlayer InitPlayer()
        {
            ByteReader BR = new ByteReader(PlayerInfo);

            PlayerManager.OnlinePlayerName  = BR.ReadString();
            PlayerManager.OnlinePlayerLevel = BR.ReadInt32();

            BR.Clear();

            Unit      NewUnit      = Unit.FromFullName("Normal/Original/Voltaire", Owner.Content, PlayerManager.DicUnitType, PlayerManager.DicRequirement, PlayerManager.DicEffect, PlayerManager.DicAutomaticSkillTarget);
            Character NewCharacter = new Character("Original/Greg", Owner.Content, PlayerManager.DicRequirement, PlayerManager.DicEffect, PlayerManager.DicAutomaticSkillTarget, PlayerManager.DicManualSkillTarget);

            NewCharacter.Level           = 1;
            NewUnit.ArrayCharacterActive = new Character[] { NewCharacter };

            Squad NewSquad = new Squad("Squad", NewUnit);

            NewSquad.IsPlayerControlled = true;

            BattleMapPlayer NewPlayer = new BattleMapPlayer(PlayerManager.OnlinePlayerID, PlayerManager.OnlinePlayerName, BattleMapPlayer.PlayerTypes.Online, false, 0, true, Color.Blue);

            NewPlayer.Inventory.ActiveLoadout.ListSquad.Add(NewSquad);

            return(NewPlayer);
        }
コード例 #3
0
        protected override void Read(OnlineReader Sender)
        {
            byte[]     ArrayPlayerInfo = Sender.ReadByteArray();
            ByteReader BR = new ByteReader(ArrayPlayerInfo);

            PlayerRanking = BR.ReadByte();
            PlayerLicense = BR.ReadByte();
            PlayerGuild   = BR.ReadString();

            BR.Clear();
        }
コード例 #4
0
        protected override void Execute(IOnlineConnection Host)
        {
            PlayerManager.OnlinePlayerID = PlayerID;
            PlayerManager.ListLocalPlayer.Add(new Player(PlayerManager.OnlinePlayerID, PlayerManager.OnlinePlayerName, Player.PlayerTypes.Online, 0));
            ByteReader BR = new ByteReader(PlayerInfo);

            PlayerManager.OnlinePlayerName  = BR.ReadString();
            PlayerManager.OnlinePlayerLevel = BR.ReadInt32();

            BR.Clear();
            Owner.IdentifyToCommunicationServer(PlayerManager.OnlinePlayerID, PlayerManager.OnlinePlayerName, PlayerInfo);
            Owner.AskForPlayerList();
        }
コード例 #5
0
        protected override void Read(OnlineReader Sender)
        {
            int ListPlayerNameCount = Sender.ReadInt32();

            ArrayLobbyFriend = new Player[ListPlayerNameCount];
            for (int P = 0; P < ListPlayerNameCount; ++P)
            {
                string     PlayerID        = Sender.ReadString();
                byte[]     ArrayPlayerInfo = Sender.ReadByteArray();
                ByteReader BR = new ByteReader(ArrayPlayerInfo);

                ArrayLobbyFriend[P]       = new Player(PlayerID, BR.ReadString(), Player.PlayerTypes.Online, 0);
                ArrayLobbyFriend[P].Level = BR.ReadInt32();

                BR.Clear();
            }
        }
コード例 #6
0
        public override void Load(byte[] ArrayGameData)
        {
            ByteReader BR = new ByteReader(ArrayGameData);

            int ListCharacterCount = BR.ReadInt32();

            for (int P = 0; P < ListCharacterCount; ++P)
            {
                string PlayerID           = BR.ReadString();
                string PlayerName         = BR.ReadString();
                int    PlayerTeam         = BR.ReadInt32();
                bool   IsPlayerControlled = BR.ReadBoolean();
                Color  PlayerColor        = Color.FromNonPremultiplied(BR.ReadByte(), BR.ReadByte(), BR.ReadByte(), 255);

                byte LocalPlayerIndex = BR.ReadByte();

                Player NewPlayer;
                if (PlayerManager.OnlinePlayerID == PlayerID)
                {
                    NewPlayer       = new Player(PlayerManager.ListLocalPlayer[LocalPlayerIndex]);
                    NewPlayer.Team  = PlayerTeam;
                    NewPlayer.Color = PlayerColor;
                    AddLocalCharacter(NewPlayer);
                    //NewPlayer.InputManagerHelper = new PlayerRobotInputManager();
                    //NewPlayer.UpdateControls(GameplayTypes.MouseAndKeyboard);
                }
                else
                {
                    NewPlayer = new Player(PlayerName, "Online", true, true, PlayerTeam, PlayerColor);
                    NewPlayer.LocalPlayerIndex = LocalPlayerIndex;
                    ListAllPlayer.Add(NewPlayer);
                }

                NewPlayer.IsPlayerControlled = IsPlayerControlled;
                NewPlayer.Inventory.ActiveLoadout.ListSquad.Clear();
                int ArraySquadLength = BR.ReadInt32();
                for (int S = 0; S < ArraySquadLength; ++S)
                {
                    float SquadX = BR.ReadFloat();
                    float SquadY = BR.ReadFloat();
                    float SquadZ = BR.ReadFloat();
                    bool  SquadIsPlayerControlled = BR.ReadBoolean();

                    int    UnitsInSquad = BR.ReadInt32();
                    Unit[] ArrayNewUnit = new Unit[UnitsInSquad];
                    for (int U = 0; U < UnitsInSquad; ++U)
                    {
                        string UnitTypeName = BR.ReadString();
                        string RelativePath = BR.ReadString();

                        ArrayNewUnit[U] = PlayerManager.DicUnitType[UnitTypeName].FromFile(RelativePath, Content, PlayerManager.DicRequirement, PlayerManager.DicEffect, PlayerManager.DicAutomaticSkillTarget);

                        int ArrayCharacterLength = BR.ReadInt32();
                        ArrayNewUnit[U].ArrayCharacterActive = new Character[UnitsInSquad];
                        for (int C = 0; C < ArrayCharacterLength; ++C)
                        {
                            string CharacterPath = BR.ReadString();
                            ArrayNewUnit[U].ArrayCharacterActive[C]       = new Character(CharacterPath, Content, PlayerManager.DicRequirement, PlayerManager.DicEffect, PlayerManager.DicAutomaticSkillTarget, PlayerManager.DicManualSkillTarget);
                            ArrayNewUnit[U].ArrayCharacterActive[C].Level = 1;
                        }
                    }

                    Unit Leader = ArrayNewUnit[0];

                    Unit WingmanA = null;
                    if (UnitsInSquad > 1)
                    {
                        WingmanA = ArrayNewUnit[1];
                    }

                    Unit WingmanB = null;
                    if (UnitsInSquad > 2)
                    {
                        WingmanB = ArrayNewUnit[2];
                    }
                    Squad NewSquad = new Squad("", Leader, WingmanA, WingmanB);
                    NewSquad.SetPosition(new Vector3(SquadX, SquadY, SquadZ));
                    NewSquad.IsPlayerControlled = SquadIsPlayerControlled;
                    NewPlayer.Inventory.ActiveLoadout.ListSquad.Add(NewSquad);
                }
            }

            BattleMapPath = BR.ReadString();

            Load();
            for (int P = 0; P < ListPlayer.Count; P++)
            {
                Player ActivePlayer = ListPlayer[P];
                foreach (Squad ActiveSquad in ActivePlayer.Inventory.ActiveLoadout.ListSquad)
                {
                    ActiveSquad.ReloadSkills(DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                    SpawnSquad(P, ActiveSquad, 0, ActiveSquad.Position, (int)ActiveSquad.Position.Z);
                }
            }
            Init();
            TogglePreview(true);

            BR.Clear();
        }