Пример #1
0
        public void DoAction()
        {
            var user = this.GetLogin();

            var testAccount = new Core.Models.Account(user.AccountId);

            var testDefinition = new Core.Models.Definitions.Definition(276);

            var testPositionI = new Core.Models.PositionI(this.TestPosition());

            var dictParam = new System.Collections.Generic.Dictionary <string, object>();

            dictParam[Core.Controllers.Actions.CreateUnit.CREATE_POSITION] = testPositionI;
            dictParam[Core.Controllers.Actions.CreateUnit.CREATION_TYPE]   = (long)testDefinition.SubType;

            var testAction = new Core.Models.Action(testAccount, Core.Models.Action.ActionType.CreateBuilding, dictParam);

            var testActions = new Core.Models.Action[] { testAction, };

            var testActionRequest = new Core.Connections.DoActionsRequest(
                user.SessionID,
                this.TestPosition(),
                testActions);

            var testJson = JsonConvert.SerializeObject(testActionRequest);

            var testPackage = new Packet();

            testPackage.Content    = testJson;
            testPackage.MethodType = MethodType.DoActions;

            var testStream = this.GetStream();

            testPackage.Send(testStream);

            var data = JsonConvert.DeserializeObject <Core.Connections.Response>(Packet.Receive(testStream).Content);

            Assert.AreEqual(Core.Connections.Response.ReponseStatus.OK, data.Status);
        }
Пример #2
0
        public void DoAction()
        {
            var user = this.GetLogin();

            var testAccount = new Core.Models.Account(user.AccountId);

            var testDefinition = new Core.Models.Definitions.Definition(276);

            var testPositionI = new Core.Models.PositionI(this.TestPosition());

            var dictParam = new System.Collections.Generic.Dictionary<string, object>();
            dictParam[Core.Controllers.Actions.CreateUnit.CREATE_POSITION] = testPositionI;
            dictParam[Core.Controllers.Actions.CreateUnit.CREATION_TYPE] = (long)testDefinition.SubType;

            var testAction = new Core.Models.Action(testAccount, Core.Models.Action.ActionType.CreateBuilding, dictParam);

            var testActions = new Core.Models.Action[] { testAction, };

            var testActionRequest = new Core.Connections.DoActionsRequest(
                                    user.SessionID,
                                    this.TestPosition(),
                                    testActions);

            var testJson = JsonConvert.SerializeObject(testActionRequest);

            var testPackage = new Packet();

            testPackage.Content = testJson;
            testPackage.MethodType = MethodType.DoActions;

            var testStream = this.GetStream();

            testPackage.Send(testStream);

            var data = JsonConvert.DeserializeObject<Core.Connections.Response>(Packet.Receive(testStream).Content);

            Assert.AreEqual(Core.Connections.Response.ReponseStatus.OK, data.Status);
        }
Пример #3
0
 /// <summary>
 /// Do the actions.
 /// </summary>
 /// <param name="frameTimesInSecond">Frame times in second.</param>
 public void Schedule(float frameTimesInSecond)
 {
     if (Action != null)
     {
         var actionV = (Client.Common.Views.Actions.Action)Action.View;
         if (actionV.Schedule(frameTimesInSecond))
         {
             // action was successfully executed, let the next be executed
             Action = null;
         }
     }
     else if (Queue.TryDequeue(out Action))
     {
         var regionC = Core.Controllers.Controller.Instance.RegionManagerController;
         var actionC = (Core.Controllers.Actions.Action)Action.Control;
         var actionV = CreateActionView(Action, actionC.GetRegionPosition());
         var affectedRegions = actionC.GetAffectedRegions();
         actionC.Possible();
         actionV.BeforeDo();
         actionC.Do();
     }
     WorldLayerHex.UglyDraw();
 }