public Partida(string n, DateTime t, Map m, Inventario i,Personaje j, Point p) { map=m; inv=i; jugador=j; pos=p; }
public void SetJugador(ref Personaje p) { //j=(Personaje)Ele[player]; }
//<-------------Termina esto public void CargarPersonaje(XmlNodeList _Dinamicos,ref Map _mapa) { XmlNodeList _Elemento = ((XmlElement)_Dinamicos[0]).GetElementsByTagName("Personaje"); //------------------Cargar info del Elemento animado--------------------// foreach (XmlElement a in _Elemento) { //---------------------------Cargando datos del elemento-----------------// string nombre = a.GetAttribute("name"); string clase = a.GetAttribute("clase"); float width = float.Parse(a.GetAttribute("width")); float height = float.Parse(a.GetAttribute("height")); string _accion = a.GetAttribute("accion"); Personaje temp = new Personaje(0, 0, width, height,1, 0); //-----------------------Cargando datos de la imagen----------------// temp=(Personaje)CargarImagen(temp, a); //----------------------Cargando datos de animaciones----------------// List<Animacion> Acciones = CargarAnimacion(a,temp.im); //----------------------Cargar posiciones--------------------------// List<PointF> posiciones = CargarPosicion(a); foreach (PointF p in posiciones) { Personaje _E=null; switch (clase) { case "Jugador": _E = new Jugador(p.X, p.Y, width, height, _mapa.k, temp.profundidad); _mapa.player = _mapa.Ele.Count; _mapa.IM.mover = new MovimientoPersonaje(_E.Caminar); _mapa.mover = new Moverse(_E.Moverse); _E.clase = "Jugador"; break; case "Enemigo": _E = new Enemigo(p.X, p.Y, width, height, _mapa.k, temp.profundidad); _E.clase = "Enemigo"; break; case "NPC": _E = new NPC(p.X, p.Y, width, height, _mapa.k, temp.profundidad); _E.clase = "NPC"; break; } _E.AddImg(temp.im); _E.DefinePortion(temp.rec[1].X, temp.rec[1].Y, temp.rec[1].Width, temp.rec[1].Height); _E.acciones = Acciones; _E.SetAction(_accion, false); _E.name=nombre; CargarEstado(_E, a); _E.rec[2] = CargarCaja(a, _E); _E.type = "Personaje"; _mapa.AddElemento(_E, p.X, p.Y); } } }
public void WriteStatus(XmlWriter writer, Personaje b) { writer.WriteStartElement("Estatus"); writer.WriteAttributeString("vida", b.health.ToString()); writer.WriteAttributeString("velocidad", b.speed.ToString()); writer.WriteAttributeString("fuerza", b.force.ToString()); writer.WriteAttributeString("stamina", b.stamina.ToString()); writer.WriteEndElement(); }
public void CargarEstado(Personaje p, XmlElement a) { XmlNodeList Estatus = a.GetElementsByTagName("Estatus"); int vida = int.Parse(((XmlElement)Estatus[0]).GetAttribute("vida")); int velocidad = int.Parse(((XmlElement)Estatus[0]).GetAttribute("velocidad")); int fuerza = int.Parse(((XmlElement)Estatus[0]).GetAttribute("fuerza")); int stamina = int.Parse(((XmlElement)Estatus[0]).GetAttribute("stamina")); p.SetStatus(vida, velocidad, stamina, fuerza); }