コード例 #1
0
ファイル: PlayerHooks.cs プロジェクト: pfchrono/Toaria
 public static void OnUpdatePhysics(Player player)
 {
     if (PlayerHooks.UpdatePhysics != null)
     {
         PlayerHooks.UpdatePhysics(player);
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: pfchrono/Toaria
 public static void SavePlayer(Player newPlayer, string playerPath)
 {
     try
     {
         Directory.CreateDirectory(Main.PlayerPath);
     }
     catch
     {
     }
     if (playerPath == null || playerPath == "")
     {
         return;
     }
     string destFileName = playerPath + ".bak";
     if (File.Exists(playerPath))
     {
         File.Copy(playerPath, destFileName, true);
     }
     string text = playerPath + ".dat";
     using (FileStream fileStream = new FileStream(text, FileMode.Create))
     {
         using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
         {
             binaryWriter.Write(Main.curRelease);
             binaryWriter.Write(newPlayer.name);
             binaryWriter.Write(newPlayer.difficulty);
             binaryWriter.Write(newPlayer.hair);
             binaryWriter.Write(newPlayer.male);
             binaryWriter.Write(newPlayer.statLife);
             binaryWriter.Write(newPlayer.statLifeMax);
             binaryWriter.Write(newPlayer.statMana);
             binaryWriter.Write(newPlayer.statManaMax);
             binaryWriter.Write(newPlayer.hairColor.R);
             binaryWriter.Write(newPlayer.hairColor.G);
             binaryWriter.Write(newPlayer.hairColor.B);
             binaryWriter.Write(newPlayer.skinColor.R);
             binaryWriter.Write(newPlayer.skinColor.G);
             binaryWriter.Write(newPlayer.skinColor.B);
             binaryWriter.Write(newPlayer.eyeColor.R);
             binaryWriter.Write(newPlayer.eyeColor.G);
             binaryWriter.Write(newPlayer.eyeColor.B);
             binaryWriter.Write(newPlayer.shirtColor.R);
             binaryWriter.Write(newPlayer.shirtColor.G);
             binaryWriter.Write(newPlayer.shirtColor.B);
             binaryWriter.Write(newPlayer.underShirtColor.R);
             binaryWriter.Write(newPlayer.underShirtColor.G);
             binaryWriter.Write(newPlayer.underShirtColor.B);
             binaryWriter.Write(newPlayer.pantsColor.R);
             binaryWriter.Write(newPlayer.pantsColor.G);
             binaryWriter.Write(newPlayer.pantsColor.B);
             binaryWriter.Write(newPlayer.shoeColor.R);
             binaryWriter.Write(newPlayer.shoeColor.G);
             binaryWriter.Write(newPlayer.shoeColor.B);
             for (int i = 0; i < 11; i++)
             {
                 if (newPlayer.armor[i].name == null)
                 {
                     newPlayer.armor[i].name = "";
                 }
                 binaryWriter.Write(newPlayer.armor[i].name);
                 binaryWriter.Write(newPlayer.armor[i].prefix);
             }
             for (int j = 0; j < 48; j++)
             {
                 if (newPlayer.inventory[j].name == null)
                 {
                     newPlayer.inventory[j].name = "";
                 }
                 binaryWriter.Write(newPlayer.inventory[j].name);
                 binaryWriter.Write(newPlayer.inventory[j].stack);
                 binaryWriter.Write(newPlayer.inventory[j].prefix);
             }
             for (int k = 0; k < Chest.maxItems; k++)
             {
                 if (newPlayer.bank[k].name == null)
                 {
                     newPlayer.bank[k].name = "";
                 }
                 binaryWriter.Write(newPlayer.bank[k].name);
                 binaryWriter.Write(newPlayer.bank[k].stack);
                 binaryWriter.Write(newPlayer.bank[k].prefix);
             }
             for (int l = 0; l < Chest.maxItems; l++)
             {
                 if (newPlayer.bank2[l].name == null)
                 {
                     newPlayer.bank2[l].name = "";
                 }
                 binaryWriter.Write(newPlayer.bank2[l].name);
                 binaryWriter.Write(newPlayer.bank2[l].stack);
                 binaryWriter.Write(newPlayer.bank2[l].prefix);
             }
             for (int m = 0; m < 10; m++)
             {
                 binaryWriter.Write(newPlayer.buffType[m]);
                 binaryWriter.Write(newPlayer.buffTime[m]);
             }
             for (int n = 0; n < 200; n++)
             {
                 if (newPlayer.spN[n] == null)
                 {
                     binaryWriter.Write(-1);
                     break;
                 }
                 binaryWriter.Write(newPlayer.spX[n]);
                 binaryWriter.Write(newPlayer.spY[n]);
                 binaryWriter.Write(newPlayer.spI[n]);
                 binaryWriter.Write(newPlayer.spN[n]);
             }
             binaryWriter.Write(newPlayer.hbLocked);
             binaryWriter.Close();
         }
     }
     Player.EncryptFile(text, playerPath);
     File.Delete(text);
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: pfchrono/Toaria
 public static Player LoadPlayer(string playerPath)
 {
     bool flag = false;
     if (Main.rand == null)
     {
         Main.rand = new Random((int)DateTime.Now.Ticks);
     }
     Player player = new Player();
     try
     {
         string text = playerPath + ".dat";
         flag = Player.DecryptFile(playerPath, text);
         if (!flag)
         {
             using (FileStream fileStream = new FileStream(text, FileMode.Open))
             {
                 using (BinaryReader binaryReader = new BinaryReader(fileStream))
                 {
                     int num = binaryReader.ReadInt32();
                     player.name = binaryReader.ReadString();
                     if (num >= 10)
                     {
                         if (num >= 17)
                         {
                             player.difficulty = binaryReader.ReadByte();
                         }
                         else
                         {
                             bool flag2 = binaryReader.ReadBoolean();
                             if (flag2)
                             {
                                 player.difficulty = 2;
                             }
                         }
                     }
                     player.hair = binaryReader.ReadInt32();
                     if (num <= 17)
                     {
                         if (player.hair == 5 || player.hair == 6 || player.hair == 9 || player.hair == 11)
                         {
                             player.male = false;
                         }
                         else
                         {
                             player.male = true;
                         }
                     }
                     else
                     {
                         player.male = binaryReader.ReadBoolean();
                     }
                     player.statLife = binaryReader.ReadInt32();
                     player.statLifeMax = binaryReader.ReadInt32();
                     if (player.statLife > player.statLifeMax)
                     {
                         player.statLife = player.statLifeMax;
                     }
                     player.statMana = binaryReader.ReadInt32();
                     player.statManaMax = binaryReader.ReadInt32();
                     if (player.statMana > 400)
                     {
                         player.statMana = 400;
                     }
                     player.hairColor.R = binaryReader.ReadByte();
                     player.hairColor.G = binaryReader.ReadByte();
                     player.hairColor.B = binaryReader.ReadByte();
                     player.skinColor.R = binaryReader.ReadByte();
                     player.skinColor.G = binaryReader.ReadByte();
                     player.skinColor.B = binaryReader.ReadByte();
                     player.eyeColor.R = binaryReader.ReadByte();
                     player.eyeColor.G = binaryReader.ReadByte();
                     player.eyeColor.B = binaryReader.ReadByte();
                     player.shirtColor.R = binaryReader.ReadByte();
                     player.shirtColor.G = binaryReader.ReadByte();
                     player.shirtColor.B = binaryReader.ReadByte();
                     player.underShirtColor.R = binaryReader.ReadByte();
                     player.underShirtColor.G = binaryReader.ReadByte();
                     player.underShirtColor.B = binaryReader.ReadByte();
                     player.pantsColor.R = binaryReader.ReadByte();
                     player.pantsColor.G = binaryReader.ReadByte();
                     player.pantsColor.B = binaryReader.ReadByte();
                     player.shoeColor.R = binaryReader.ReadByte();
                     player.shoeColor.G = binaryReader.ReadByte();
                     player.shoeColor.B = binaryReader.ReadByte();
                     Main.player[Main.myPlayer].shirtColor = player.shirtColor;
                     Main.player[Main.myPlayer].pantsColor = player.pantsColor;
                     Main.player[Main.myPlayer].hairColor = player.hairColor;
                     for (int i = 0; i < 8; i++)
                     {
                         player.armor[i].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                         if (num >= 36)
                         {
                             player.armor[i].Prefix((int)binaryReader.ReadByte());
                         }
                     }
                     if (num >= 6)
                     {
                         for (int j = 8; j < 11; j++)
                         {
                             player.armor[j].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             if (num >= 36)
                             {
                                 player.armor[j].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     for (int k = 0; k < 44; k++)
                     {
                         player.inventory[k].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                         player.inventory[k].stack = binaryReader.ReadInt32();
                         if (num >= 36)
                         {
                             player.inventory[k].Prefix((int)binaryReader.ReadByte());
                         }
                     }
                     if (num >= 15)
                     {
                         for (int l = 44; l < 48; l++)
                         {
                             player.inventory[l].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             player.inventory[l].stack = binaryReader.ReadInt32();
                             if (num >= 36)
                             {
                                 player.inventory[l].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     for (int m = 0; m < Chest.maxItems; m++)
                     {
                         player.bank[m].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                         player.bank[m].stack = binaryReader.ReadInt32();
                         if (num >= 36)
                         {
                             player.bank[m].Prefix((int)binaryReader.ReadByte());
                         }
                     }
                     if (num >= 20)
                     {
                         for (int n = 0; n < Chest.maxItems; n++)
                         {
                             player.bank2[n].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             player.bank2[n].stack = binaryReader.ReadInt32();
                             if (num >= 36)
                             {
                                 player.bank2[n].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     if (num >= 11)
                     {
                         for (int num2 = 0; num2 < 10; num2++)
                         {
                             player.buffType[num2] = binaryReader.ReadInt32();
                             player.buffTime[num2] = binaryReader.ReadInt32();
                         }
                     }
                     for (int num3 = 0; num3 < 200; num3++)
                     {
                         int num4 = binaryReader.ReadInt32();
                         if (num4 == -1)
                         {
                             break;
                         }
                         player.spX[num3] = num4;
                         player.spY[num3] = binaryReader.ReadInt32();
                         player.spI[num3] = binaryReader.ReadInt32();
                         player.spN[num3] = binaryReader.ReadString();
                     }
                     if (num >= 16)
                     {
                         player.hbLocked = binaryReader.ReadBoolean();
                     }
                     binaryReader.Close();
                 }
             }
             player.PlayerFrame();
             File.Delete(text);
             Player result = player;
             return result;
         }
     }
     catch
     {
         flag = true;
     }
     if (flag)
     {
         try
         {
             string text2 = playerPath + ".bak";
             Player result;
             if (File.Exists(text2))
             {
                 File.Delete(playerPath);
                 File.Move(text2, playerPath);
                 result = Player.LoadPlayer(playerPath);
                 return result;
             }
             result = new Player();
             return result;
         }
         catch
         {
             Player result = new Player();
             return result;
         }
     }
     return new Player();
 }
コード例 #4
0
ファイル: Player.cs プロジェクト: pfchrono/Toaria
 public object clientClone()
 {
     Player player = new Player();
     player.zoneEvil = this.zoneEvil;
     player.zoneMeteor = this.zoneMeteor;
     player.zoneDungeon = this.zoneDungeon;
     player.zoneJungle = this.zoneJungle;
     player.zoneHoly = this.zoneHoly;
     player.direction = this.direction;
     player.selectedItem = this.selectedItem;
     player.controlUp = this.controlUp;
     player.controlDown = this.controlDown;
     player.controlLeft = this.controlLeft;
     player.controlRight = this.controlRight;
     player.controlJump = this.controlJump;
     player.controlUseItem = this.controlUseItem;
     player.statLife = this.statLife;
     player.statLifeMax = this.statLifeMax;
     player.statMana = this.statMana;
     player.statManaMax = this.statManaMax;
     player.position.X = this.position.X;
     player.chest = this.chest;
     player.talkNPC = this.talkNPC;
     for (int i = 0; i < 49; i++)
     {
         player.inventory[i] = (Item)this.inventory[i].Clone();
         if (i < 11)
         {
             player.armor[i] = (Item)this.armor[i].Clone();
         }
     }
     for (int j = 0; j < 10; j++)
     {
         player.buffType[j] = this.buffType[j];
         player.buffTime[j] = this.buffTime[j];
     }
     return player;
 }
コード例 #5
0
ファイル: TSPlayer.cs プロジェクト: pfchrono/Toaria
 protected TSPlayer(String playerName)
 {
     TilesDestroyed = new Dictionary<Vector2, TileData>();
     TilesCreated = new Dictionary<Vector2, TileData>();
     Index = -1;
     FakePlayer = new Player { name = playerName, whoAmi = -1 };
     Group = new Group(TShock.Config.DefaultGuestGroupName);
 }