public void SessionZero() { Pseudo = string.Empty; level = 0; directionLook = 0; spirit = Enums.Spirit.Name.neutral; spiritLvl = 0; classeId = 0; classeName = Enums.ActorClass.ClassName.__notAffected; sexe = Enums.ActorSexe.Sexe.__notAffected; Pvp = false; map_position = Point.Zero(); map = string.Empty; animatedAction = Enums.AnimatedActions.Name.idle; wayPoint.Clear(); wayPointTimeStamp = 0; wayPointCnt = 0; }
public Actor(string _pseudo, int _level, Enums.Spirit.Name _spirit, Enums.ActorClass.ClassName _className, bool _pvp, int _spiritLvl, Enums.HiddenVillage.Names _hiddenVillage, string _maskColor, int _orientation, Enums.AnimatedActions.Name _action, string _waypoint) { this.pseudo = _pseudo; this.spirit = _spirit; this.spiritLevel = _spiritLvl; this.level = _level; className = _className; pvpEnabled = _pvp; hiddenVillage = _hiddenVillage; maskColorString = _maskColor; this.directionLook = _orientation; this.animatedAction = _action; // seulement quand le joueur est en mouvement alors qu'on viens de se connecter if (_waypoint != "null" && _waypoint != "") { string[] tmpWayPoint = _waypoint.Split(':'); foreach (string s in tmpWayPoint) { wayPoint.Add(new Point(Convert.ToInt32(s.Split(',')[0]), Convert.ToInt32(s.Split(',')[1]))); } } }
public void Fetch(string[] commandStrings) { #region MapData // commandStrings[1] = pseudo#classe#pvp:spirit:spiritLvl#village#MaskColors#map_position#orientation#level#action#waypoint#TotalPdv#CurrentPdv#rang | separateur entre plusieurs joueurs // pvp=0 donc mode pvp off, si pvp = 1 mode pvp on string[] playersInfos = commandStrings[1].Split('|'); foreach (string t in playersInfos) { string[] states = t.Split('#'); string actorName = states[0]; Enums.ActorClass.ClassName className = (Enums.ActorClass.ClassName)Enum.Parse(typeof(Enums.ActorClass.ClassName), states[1]); bool pvpEnabled = states[2].Split(':')[0] == "1"; Enums.Spirit.Name spirit = (Enums.Spirit.Name)Enum.Parse(typeof(Enums.Spirit.Name), states[2].Split(':')[1]); int spiritLevel = int.Parse(states[2].Split(':')[2]); Enums.HiddenVillage.Names hiddenVillage = (Enums.HiddenVillage.Names)Enum.Parse(typeof(Enums.HiddenVillage.Names), states[3]); string maskColors = states[4]; Point mapPoint = new Point(int.Parse(states[5].Split('/')[0]), int.Parse(states[5].Split('/')[1])); int orientation = int.Parse(states[6]); int level = int.Parse(states[7]); Enums.AnimatedActions.Name action = (Enums.AnimatedActions.Name)Enum.Parse(typeof(Enums.AnimatedActions.Name), states[8]); string waypoint = states[9]; int maxHealth = int.Parse(states[10]); int currentHealth = int.Parse(states[11]); // cette valeur n'est pas utilisé dans le jeu puisque le rang n'est pas encore affiché, il faut prévoir un truc pour montrer les rang de chaque joueur, ou pas si le rang dois etre caché, ptet que le rang est caché mais permet d'afficher le joueur avec un ora spécial Enums.Rang.official officialRang = (Enums.Rang.official)Enum.Parse(typeof(Enums.Rang.official), states[12]); // supprimer tout les anciennes instances qui correspond a ce joueur pour eviter un doublons ou une erreur de la part du serveur ou client s'il n'envoie pas la cmd de deconnexion du joeur au abonnés if (CommonCode.AllActorsInMap.Count(i => ((Actor)i.tag).pseudo == actorName) > 0) { Bmp allPlayers = CommonCode.AllActorsInMap.Find(f => ((Actor)f.tag).pseudo == actorName); allPlayers.visible = false; CommonCode.AllActorsInMap.Remove(allPlayers); CommonCode.AllActorsInMap.RemoveAll(i => ((Actor)i.tag).pseudo == actorName); } // affichage du personnage + position + orientation Bmp ibPlayers = new Bmp(@"gfx\general\classes\" + className + ".dat", Point.Empty, "Player_" + actorName, Manager.TypeGfx.Obj, true, 1, SpriteSheet.GetSpriteSheet(className.ToString(), CommonCode.ConvertToClockWizeOrientation(orientation))); ibPlayers.point = new Point((mapPoint.X * 30) + 15 - (ibPlayers.rectangle.Width / 2), (mapPoint.Y * 30) - (ibPlayers.rectangle.Height) + 15); ibPlayers.MouseOver += CommonCode.ibPlayers_MouseOver; ibPlayers.MouseOut += CommonCode.ibPlayers_MouseOut; ibPlayers.MouseMove += CommonCode.CursorHand_MouseMove; ibPlayers.MouseClic += CommonCode.ibPlayers_MouseClic; CommonCode.VerticalSyncZindex(ibPlayers); ibPlayers.TypeGfx = Manager.TypeGfx.Obj; Manager.manager.GfxObjList.Add(ibPlayers); ibPlayers.tag = CommonCode.MyPlayerInfo.instance.pseudo != actorName ? new Actor(actorName, level, !pvpEnabled ? Enums.Spirit.Name.neutral : spirit, className, pvpEnabled, !pvpEnabled ? 0 : spiritLevel, hiddenVillage, maskColors, orientation, action, waypoint) : CommonCode.MyPlayerInfo.instance.ibPlayer.tag; Actor actor = (Actor)ibPlayers.tag; actor.realPosition = mapPoint; actor.officialRang = officialRang; // affichage des ailles if (actor.pvpEnabled) { if (actor.spirit != Enums.Spirit.Name.neutral) { Bmp _spirit = new Bmp(@"gfx\general\obj\2\" + actor.spirit + @"\" + actor.spiritLevel + ".dat", Point.Empty, "spirit_" + ibPlayers.name, Manager.TypeGfx.Obj, false, 1); _spirit.point = new Point((ibPlayers.rectangle.Width / 2) - (_spirit.rectangle.Width / 2), -_spirit.rectangle.Height); ibPlayers.Child.Add(_spirit); Txt lPseudo = new Txt(actor.pseudo, Point.Empty, "lPseudo_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Regular), Brushes.Red); lPseudo.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lPseudo.Text, lPseudo.font).Width / 2) + 5, -_spirit.rectangle.Height - 15); ibPlayers.Child.Add(lPseudo); Txt lLvlSpirit = new Txt(actor.spiritLevel.ToString(), Point.Empty, "lLvlSpirit_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Bold), Brushes.Red); lLvlSpirit.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lLvlSpirit.Text, lLvlSpirit.font).Width / 2) + 2, -_spirit.rectangle.Y - (_spirit.rectangle.Height / 2) - (TextRenderer.MeasureText(lLvlSpirit.Text, lLvlSpirit.font).Height / 2)); ibPlayers.Child.Add(lLvlSpirit); Bmp village = new Bmp(@"gfx\general\obj\1\pays_thumbs.dat", Point.Empty, "village_" + actor.hiddenVillage, Manager.TypeGfx.Obj, false, 1, SpriteSheet.GetSpriteSheet("pays_" + actor.hiddenVillage + "_thumbs", 0)); village.point = new Point((ibPlayers.rectangle.Width / 2) - (village.rectangle.Width / 2), lPseudo.point.Y - village.rectangle.Height + 2); ibPlayers.Child.Add(village); } } else { Txt lPseudo = new Txt(actor.pseudo, Point.Empty, "lPseudo_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Regular), Brushes.Red); lPseudo.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lPseudo.Text, lPseudo.font).Width / 2) + 5, -15); ibPlayers.Child.Add(lPseudo); Bmp village = new Bmp(@"gfx\general\obj\1\pays_thumbs.dat", Point.Empty, "village_" + actor.hiddenVillage, Manager.TypeGfx.Obj, false, 1, SpriteSheet.GetSpriteSheet("pays_" + actor.hiddenVillage + "_thumbs", 0)); village.point = new Point((ibPlayers.rectangle.Width / 2) - (village.rectangle.Width / 2), lPseudo.point.Y - village.rectangle.Height + 2); ibPlayers.Child.Add(village); } // coloriage du personnage et attachement du maskColor au personnage CommonCode.ApplyMaskColorToClasse(ibPlayers); // pointeur vers l'image ibplayer de notre joueur s'il s'agit de son personnage if (CommonCode.MyPlayerInfo.instance.pseudo == actor.pseudo) { CommonCode.MyPlayerInfo.instance.ibPlayer = ibPlayers; } // ajout du personnage dans la liste des joueurs CommonCode.AllActorsInMap.Add(ibPlayers); // lancement de l'animation de mouvement si le joueur a un waypoint if (actor.wayPoint.Count > 0) { //mouvement du personnage // thread a part Thread tAnimAction = new Thread(() => CommonCode.AnimAction(ibPlayers, actor.wayPoint, actor.wayPoint.Count > 5 ? 20 : 50)); tAnimAction.Start(); } // affectation des pdv actor.maxHealth = maxHealth; actor.currentHealth = currentHealth; } #endregion }
public void Fetch(string[] commandStrings) { #region // connexion d'un joueur // pseudo#classe#pvp:spirit:spiritLvl#village#MaskColors#map_position#orientation#level#action#waypoint - separateur entre plusieurs joueurs // pvp=0 donc mode pvp off, si pvp = 1 mode pvp on string[] data = commandStrings[1].Split('#'); string playerName = data[0]; Enums.ActorClass.ClassName className = (Enums.ActorClass.ClassName)Enum.Parse(typeof(Enums.ActorClass.ClassName), data[1]); bool pvpEnabled = bool.Parse(data[2].Split(':')[0]); Enums.Spirit.Name spirit = (Enums.Spirit.Name)Enum.Parse(typeof(Enums.Spirit.Name), data[2].Split(':')[1]); int spiritLevel = int.Parse(data[2].Split(':')[2]); Enums.HiddenVillage.Names hiddenVillage = (Enums.HiddenVillage.Names)Enum.Parse(typeof(Enums.HiddenVillage.Names), data[3]); string maskColorsString = data[4]; string[] maskColors = maskColorsString.Split('/'); Point mapPosition = new Point(Convert.ToInt16(data[5].Split('/')[0]), Convert.ToInt16(data[5].Split('/')[1])); int directionLook = int.Parse(data[6]); int level = int.Parse(data[7]); Enums.AnimatedActions.Name animatedAction = (data[8] != "") ? (Enums.AnimatedActions.Name)Enum.Parse(typeof(Enums.AnimatedActions.Name), data[8]) : Enums.AnimatedActions.Name.idle; string waypoint = data[9]; // verifier si le personnage est deja present pour ne pas créer un doublons, si par erreur le serveur n'envoie pas une cmd de deconnexion du client ou SessionZero if (CommonCode.AllActorsInMap.Exists(f => ((Actor)f.tag).pseudo == playerName && ((Actor)f.tag).pseudo != CommonCode.MyPlayerInfo.instance.pseudo)) { Bmp tmpBmp = CommonCode.AllActorsInMap.Find(f => ((Actor)f.tag).pseudo == playerName); tmpBmp.visible = false; Manager.manager.GfxObjList.RemoveAll(f => f != null && f.GetType() == typeof(Bmp) && f.Tag() != null && f.Tag().GetType() == typeof(Actor) && ((Actor)f.Tag()).pseudo == playerName); CommonCode.AllActorsInMap.Remove(CommonCode.AllActorsInMap.Find(f => ((Actor)f.tag).pseudo == playerName)); } // affichage du personnage + position + orientation Bmp ibPlayers = new Bmp(@"gfx\general\classes\" + className + ".dat", Point.Empty, "Player_" + playerName, 0, true, 1, SpriteSheet.GetSpriteSheet(className.ToString(), CommonCode.ConvertToClockWizeOrientation(directionLook))); ibPlayers.MouseOver += CommonCode.ibPlayers_MouseOver; ibPlayers.MouseOut += CommonCode.ibPlayers_MouseOut; ibPlayers.MouseMove += CommonCode.CursorHand_MouseMove; ibPlayers.MouseClic += CommonCode.ibPlayers_MouseClic; Manager.manager.GfxObjList.Add(ibPlayers); // attachement des données ibPlayers.tag = new Actor(playerName, level, !pvpEnabled ? Enums.Spirit.Name.neutral : spirit, className, pvpEnabled, !pvpEnabled ? 0 : spiritLevel, hiddenVillage, maskColorsString, directionLook, animatedAction, waypoint); Actor pi = (Actor)ibPlayers.tag; pi.realPosition = mapPosition; CommonCode.AdjustPositionAndDirection(ibPlayers, new Point(mapPosition.X * 30, mapPosition.Y * 30)); CommonCode.VerticalSyncZindex(ibPlayers); // affichage des ailles if (pi.pvpEnabled) { if (pi.spirit != Enums.Spirit.Name.neutral) { Bmp spiritBmp = new Bmp(@"gfx\general\obj\2\" + pi.spirit + @"\" + pi.spiritLevel + ".dat", Point.Empty, "spirit_" + ibPlayers.name, Manager.TypeGfx.Obj, false, 1); spiritBmp.point = new Point((ibPlayers.rectangle.Width / 2) - (spiritBmp.rectangle.Width / 2), -spiritBmp.rectangle.Height); ibPlayers.Child.Add(spiritBmp); Txt lPseudo = new Txt(pi.pseudo, Point.Empty, "lPseudo_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Regular), Brushes.Red); lPseudo.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lPseudo.Text, lPseudo.font).Width / 2) + 5, -spiritBmp.rectangle.Height - 15); ibPlayers.Child.Add(lPseudo); Txt lLvlSpirit = new Txt(pi.spiritLevel.ToString(), Point.Empty, "lLvlSpirit_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Bold), Brushes.Red); lLvlSpirit.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lLvlSpirit.Text, lLvlSpirit.font).Width / 2) + 2, -spiritBmp.rectangle.Y - (spiritBmp.rectangle.Height / 2) - (TextRenderer.MeasureText(lLvlSpirit.Text, lLvlSpirit.font).Height / 2)); ibPlayers.Child.Add(lLvlSpirit); Bmp village = new Bmp(@"gfx\general\obj\1\pays_thumbs.dat", Point.Empty, "village_" + pi.hiddenVillage, Manager.TypeGfx.Obj, false, 1, SpriteSheet.GetSpriteSheet("pays_" + pi.hiddenVillage + "_thumbs", 0)); village.point = new Point((ibPlayers.rectangle.Width / 2) - (village.rectangle.Width / 2), lPseudo.point.Y - village.rectangle.Height + 2); ibPlayers.Child.Add(village); } } else { Txt lPseudo = new Txt(pi.pseudo, Point.Empty, "lPseudo_" + ibPlayers.name, Manager.TypeGfx.Obj, false, new Font("Verdana", 10, FontStyle.Regular), Brushes.Red); lPseudo.point = new Point((ibPlayers.rectangle.Width / 2) - (TextRenderer.MeasureText(lPseudo.Text, lPseudo.font).Width / 2) + 5, -15); ibPlayers.Child.Add(lPseudo); Bmp village = new Bmp(@"gfx\general\obj\1\pays_thumbs.dat", Point.Empty, "village_" + pi.hiddenVillage, Manager.TypeGfx.Obj, false, 1, SpriteSheet.GetSpriteSheet("pays_" + pi.hiddenVillage + "_thumbs", 0)); village.point = new Point((ibPlayers.rectangle.Width / 2) - (village.rectangle.Width / 2), lPseudo.point.Y - village.rectangle.Height + 2); ibPlayers.Child.Add(village); } // coloriage selon le MaskColors if (maskColors[0] != "null") { Color tmpColor = Color.FromArgb(Convert.ToInt16(maskColors[0].Split('-')[0]), Convert.ToInt16(maskColors[0].Split('-')[1]), Convert.ToInt16(maskColors[0].Split('-')[2])); CommonCode.SetPixelToClass(className, tmpColor, 1, ibPlayers); } if (maskColors[1] != "null") { Color tmpColor = Color.FromArgb(Convert.ToInt16(maskColors[1].Split('-')[0]), Convert.ToInt16(maskColors[1].Split('-')[1]), Convert.ToInt16(maskColors[1].Split('-')[2])); CommonCode.SetPixelToClass(className, tmpColor, 2, ibPlayers); } if (maskColors[2] != "null") { Color tmpColor = Color.FromArgb(Convert.ToInt16(maskColors[2].Split('-')[0]), Convert.ToInt16(maskColors[2].Split('-')[1]), Convert.ToInt16(maskColors[2].Split('-')[2])); CommonCode.SetPixelToClass(className, tmpColor, 3, ibPlayers); } // ajout du joueur dans la liste des joueurs CommonCode.ApplyMaskColorToClasse(ibPlayers); CommonCode.AllActorsInMap.Add(ibPlayers); #endregion }