public HostileAttack(HostileStateMachine aHostileStateMachine) { mHostileStateMachine = aHostileStateMachine; mEnemy = aHostileStateMachine.Enemy; mPlayer = (Player)thePlayerManager.List[0]; }
public HostileStateMachine(Enemy aEnemy) { mEnemy = aEnemy; State = new HostileSeek(this); }
public void Remove(Enemy aEntity) { List.Remove(aEntity); }
public void Add(Enemy aEntity) { List.Add(aEntity); }
public void Load(string aFilePath) { int ButtonsToLoad = 0; using (XmlReader xmlReader = XmlReader.Create(aFilePath + ".xml")) { while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: ButtonsToLoad++; break; case XmlNodeType.Text: ButtonsToLoad--; break; } } ButtonsToLoad--; xmlReader.Close(); } using (XmlReader xmlReader = XmlReader.Create(aFilePath + ".xml")) { xmlReader.MoveToContent(); xmlReader.ReadStartElement("Data"); string rawData; string[] organizedData; string[] xData; string[] yData; string[] zData; for (int loop = 0; loop < ButtonsToLoad; loop++) { xmlReader.ReadStartElement("Button"); Enemy temporaryEnemy = new Enemy(); // temporaryEnemy.FilePathToBorder = xmlReader.ReadElementContentAsString("Border", ""); temporaryEnemy.FilePathToGraphic = xmlReader.ReadElementContentAsString("Graphic", ""); rawData = xmlReader.ReadElementContentAsString("Position", ""); organizedData = rawData.Split(' '); xData = organizedData[0].Split(':'); yData = organizedData[1].Split(':'); yData[1] = yData[1].TrimEnd(); // Glitch: This is not working. C# has failed me : ( yData[1] = yData[1].Replace('}', ' '); // This is another method of doing it. Rather not use it tho for the sake of consistency. temporaryEnemy.WorldPosition = new Vector2((float)Convert.ToDouble(xData[1]), (float)Convert.ToDouble(yData[1])); rawData = xmlReader.ReadElementContentAsString("IsCollidable", ""); if (rawData == "True") { temporaryEnemy.IsCollidable = true; } else { temporaryEnemy.IsCollidable = false; } rawData = xmlReader.ReadElementContentAsString("Color", ""); organizedData = rawData.Split(' '); xData = organizedData[0].Split(':'); yData = organizedData[1].Split(':'); zData = organizedData[2].Split(':'); zData[1] = zData[1].TrimEnd(); // See. It works here. What the heck? temporaryEnemy.Color = new Color((float)Convert.ToDouble(xData[1]), (float)Convert.ToDouble(yData[1]), (float)Convert.ToDouble(zData[1])); temporaryEnemy.Rotation = xmlReader.ReadElementContentAsFloat("Rotation", ""); temporaryEnemy.Scale = xmlReader.ReadElementContentAsFloat("Scale", ""); switch (xmlReader.ReadElementContentAsString("SpriteEffects", "")) { case "FlipVertically": temporaryEnemy.SpriteEffects = SpriteEffects.FlipVertically; break; case "FlipHorizontally": temporaryEnemy.SpriteEffects = SpriteEffects.FlipHorizontally; break; case "None": temporaryEnemy.SpriteEffects = SpriteEffects.None; break; default: break; } temporaryEnemy.Rotation = xmlReader.ReadElementContentAsFloat("LayerDepth", ""); xmlReader.ReadEndElement(); Add(temporaryEnemy); } } }