public Character buildFromXml(string filepath, MoveProvider provider = null) { XmlDocument doc = new XmlDocument(); doc.Load(File.OpenRead(diroot == null ? filepath : (diroot + filepath))); return(buildFromXmlNode(doc.DocumentElement, provider)); }
public Character(MoveProvider mprovider, MoveSet mset, string name, Dictionary <string, int> stats) { _mprovider = mprovider; _mset = mset; _hp = new DepleteableStat(stats["hp"]); _strength = new Stat(stats["strength"]); _speed = new Stat(stats["speed"]); _vitality = new Stat(stats["vitality"]); _name = name; }
public ActionResult GetLocalDetail() { string barCode = WebUtil.GetFormValue <string>("SnNum", string.Empty); MoveProvider provider = new MoveProvider(); List <LocalProductEntity> list = provider.GetList(barCode); if (!list.IsNullOrEmpty()) { System.Threading.Tasks.Parallel.ForEach(list, item => { item.Num = ConvertHelper.ToType <double>(item.Num.ToString(), 0); }); } this.ReturnJson.AddProperty("List", ConvertJson.ListToJson <LocalProductEntity>(list, "Data")); return(Content(this.ReturnJson.ToString())); }
public Character buildFromXmlNode(XmlNode root, MoveProvider provider = null) { provider = provider == null ? new NullMoveProvider() : provider; string name = root["name"].InnerText; MoveSet moveroot = XmlbuildMoveSet(root["moves"], name); Dictionary <string, int> stats = new Dictionary <string, int>(); stats["speed"] = int.Parse(root["speed"].InnerText); stats["strength"] = int.Parse(root["strength"].InnerText); stats["vitality"] = int.Parse(root["vitality"].InnerText); stats["hp"] = int.Parse(root["hp"].InnerText); return(new Character(provider, moveroot, name, stats)); }
public void TestGetMoveInvalidInput() { // create a MockInputProvider that implements IInputProvider // Have Read() return something that CAN'T be parsed into the // PlayerAction enum var mockInputProvider = new Mock <IInputProvider>(MockBehavior.Strict); mockInputProvider.Setup(x => x.Read()).Returns("R"); // Create a MoveProvider, passing in the MockInputProvider var moveProvider = new MoveProvider(mockInputProvider.Object); moveProvider.GetMove(); // Call GetMove() and verify that an InvalidInputException is thrown // using ExpectedException }
public void TestMoveProviderStandWithNumber() { // mock input provider implements console input provider Read() method // returns "hit" as if user typed "0" into console var mockInputProvider = new Mock <IInputProvider>(MockBehavior.Strict); mockInputProvider.Setup(x => x.Read()).Returns("1"); //the mocked input is passed to the move provider, which implements the GetMove() //method of the MoveProvider class and returns the move because "1" is a valid move //from the PlayerAction enum if user chooses to stand var moveProvider = new MoveProvider(mockInputProvider.Object); var move = moveProvider.GetMove(); Assert.AreEqual(PlayerAction.stand, move); }
void Start() { spritesPerMove.Add(Move.UP, upSprite); spritesPerMove.Add(Move.RIGHT, rightSprite); spritesPerMove.Add(Move.LEFT, leftSprite); spritesPerMove.Add(Move.DOWN, downSprite); spritesPerMove.Add(Move.STAY, waitSprite); GameRunner runner = GameObject.FindObjectOfType <GameRunner> (); if (runner == null) { Debug.LogError("No GameRunner Found!"); } else { runner.StartCollectingMoves += new GameEvent(StartFadeIn); runner.EndCollectingMoves += new GameEvent(StartFadeOut); } myProvider = gameObject.GetComponent <MoveProvider> (); }