private void initControllers() { _playerMediator = gameObject.AddComponent<PlayerMediator>(); _playerMediator.init(); _playerProxy = new PlayerProxy(); _playerProxy.init(); }
private void SetProxy(GC_LOGIN_RET packet) { PlayerProxy proxy = GameFacade.GetProxy <PlayerProxy>(); proxy.userid = packet.Userid; proxy.oid = packet.Oid; proxy.accesstoken = packet.Accesstoken; proxy.playername = packet.Playername; proxy.level = packet.Level; //城市数据 proxy.city.cityId = packet.City.CityId; proxy.city.tileId = packet.City.TileId; proxy.city.level = packet.City.Level; proxy.city.food = packet.City.Food; proxy.city.stone = packet.City.Stone; proxy.city.iron = packet.City.Iron; proxy.city.WorldPos = new Coord(packet.City.Posx, packet.City.Posz); proxy.city.buildList.Clear(); for (int i = 0; i < packet.City.buildlistCount; i++) { GC_BuildingData data = packet.City.GetBuildlist(i); BuildingVo vo = new BuildingVo(); PlayerProxy.SetBuildVo(data, vo); proxy.city.buildList.Add(vo); } proxy.city.trainList.Clear(); for (int i = 0; i < packet.City.trainListCount; i++) { GC_TrainData data = packet.City.GetTrainList(i); TrainVo vo = new TrainVo(); PlayerProxy.SetTrainVo(data, vo); proxy.city.trainList.Add(vo); } //英雄数据 proxy.heroList.Clear(); for (int i = 0; i < packet.HeroList.heroListCount; i++) { GC_HeroData data = packet.HeroList.GetHeroList(i); HeroVo vo = new HeroVo(); PlayerProxy.SetHeroVo(data, vo); proxy.heroList.Add(vo); } //队伍数据 proxy.marchList.Clear(); for (int i = 0; i < packet.Marchlist.marchlistCount; i++) { GC_MarchData data = packet.Marchlist.GetMarchlist(i); MarchVo vo = new MarchVo(); PlayerProxy.SetMarchVo(data, vo); proxy.marchList.Add(vo); } }
public void PlayerProxyConstructorAndPropertriesGetterAndSetterWorksProper() { string expectedNickName = "Pesho"; int expectedScore = 15; PlayerProxy proxy = new PlayerProxy(expectedNickName, expectedScore); Assert.AreEqual(expectedNickName, proxy.Nickname, "Expected and actual PlayerProxy Nickname are not equal"); Assert.AreEqual(expectedScore, proxy.Score, "Expected and actual PlayerProxy Score are not equal"); }
public void ReceiveUpdateMarchMsg(object para) { GC_Update_March packet = (GC_Update_March)para; var marchs = MyMarchList.Concat(OtherMarchList).Where(item => item.MarchData.marchId == packet.Data.Marchid).ToList(); if (marchs.Any()) { PlayerProxy.SetMarchVo(packet.Data, marchs.First().MarchData); } }
public override void Execute(PureMVC.Interfaces.INotification notification) { switch (notification.Name) { case NotificationConstant.playerCommand.PlayerMove: { PlayerProxy proxy = (PlayerProxy)Facade.RetrieveProxy("PlayerProxy"); //通过名字获取Proxy proxy.Move(); } break; } }
public void Init() { Player = new PlayerProxy(); Player.Init(); Login = new LoginProxy(); Login.Init(); Room = new RoomProxy(); Room.Init(); Battle = new BattleProxy(); Battle.Init(); }
public TicTacToeGame(IEnumerable <PlayerProxy> players) : base(players) { // Default values for a new game _Grid = new string[3][]; for (int i = 0; i < 3; i++) { _Grid[i] = new string[3]; for (int j = 0; j < 3; j++) { _Grid[i][j] = string.Empty; } } _CurrentPlayer = Players[0]; }
public uint Execute(PacketDistributed ipacket) { GC_TroopTrain_Over packet = (GC_TroopTrain_Over )ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic if (packet.Ret == 0) { int queueIndex = -1; PlayerProxy proxy = GameFacade.GetProxy <PlayerProxy> (); for (int i = 0; i < proxy.city.trainList.Count; i++) { if (proxy.city.trainList[i].queueid == packet.Queueid) { queueIndex = proxy.city.trainList [i].queueIndex; proxy.city.trainList.RemoveAt(i); } } //设置队伍中的单位信息 for (int i = 0; i < proxy.marchList.Count; i++) { if (proxy.marchList[i].buildId == packet.Buildid) { List <TroopVo> list = proxy.marchList [i].troopList; for (int j = 0; j < list.Count; j++) { if (list[j].queueIndex == queueIndex) { list [j].health = packet.Hp; } } } } EventManager.GetInstance().SendEvent(EventId.TroopTrainOver, null); } else { UnityEngine.Debug.Log("数据包报错了!!!"); } return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
public override IGameStatus ProcessGameStep() { // Get the next placement for the current player var request = new GetPlacementRequest(_CurrentPlayer.Name, _Grid); var response = _CurrentPlayer.ProcessRequest <GetPlacementResponse>(request) as GetPlacementResponse; // Is it a valid placement? if (IsValidPlacement(response.Placement)) { // Place it _Grid[response.Placement.X][response.Placement.Y] = _CurrentPlayer.Name; // Switch the current player to the next one _CurrentPlayer = _CurrentPlayer == Players[0] ? Players[1] : Players[0]; } return(GetGameStatus()); }
static void Main(string[] args) { int i = 0; string playerId1 = args[i++]; string playerPath1 = args[i++]; string playerId2 = args[i++]; string playerPath2 = args[i++]; string resultsPath = args[i++]; string finalResultsPath = Path.Combine(resultsPath, "results.json"); var player1 = new PlayerProxy <Move>(playerId1, resultsPath, playerPath1); var player2 = new PlayerProxy <Move>(playerId2, resultsPath, playerPath2); var game = new CodeCompete.DotNet.GameName.GameName(new GamePlayer <Move>[] { player1, player2 }); var result = game.PlayGame(); File.WriteAllText(Path.Combine(resultsPath, "results.json"), JsonConvert.SerializeObject(result)); }
public override void Open() { if (!(pc is WCFPlayerPC)) { return; } try { NetTcpBinding binding = new NetTcpBinding(SecurityMode.None) { ReceiveTimeout = new TimeSpan(0, 5, 0) }; WCFPlayerPC wcfComputer = pc as WCFPlayerPC; player = new PlayerProxy(binding, wcfComputer.Endpoint); player.Open(); } catch { } }//Feito
public uint Execute(PacketDistributed ipacket) { GC_Update_March packet = (GC_Update_March)ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic PlayerProxy proxy = GameFacade.GetProxy <PlayerProxy>(); for (int i = 0; i < proxy.marchList.Count; i++) { if (proxy.marchList[i].marchId == packet.Data.Marchid) { PlayerProxy.SetMarchVo(packet.Data, proxy.marchList[i]); } } EventManager.GetInstance().SendEvent(EventId.ReceiveUpdateMarchMsg, packet); return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
/// <summary> /// Method to add you score to the highscore table /// </summary> private void EnterScoreRecordHandler() { Console.Write("Enter your nickname: "); var nickname = Console.ReadLine(); try { var playerProxy = new PlayerProxy(nickname, this.Player.Score); var scoresHandler = new ScoresHandler(); scoresHandler.LoadFromFile(GlobalErrorMessages.SaveRecordstFileName); scoresHandler.AddReccord(playerProxy); scoresHandler.SaveToFile(GlobalErrorMessages.SaveRecordstFileName); Console.WriteLine("Press any key to continiue.."); Console.ReadKey(); MainMenu.PrintMenu(this.engine); } catch (ArgumentOutOfRangeException) { Console.WriteLine("The name should be between 2 and 10 characters"); this.EnterScoreRecordHandler(); } }
public uint Execute(PacketDistributed ipacket) { GC_ASSIGN_HERO packet = (GC_ASSIGN_HERO )ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic long marchID = 0; if (packet.Ret == 0) { PlayerProxy playerProxy = GameFacade.GetProxy <PlayerProxy> (); for (int i = 0; i < playerProxy.heroList.Count; i++) { var data = playerProxy.heroList [i]; if (data.guid == packet.HeroId) { marchID = packet.Marchid; data.marchId = packet.Marchid; } else if (data.marchId == packet.Marchid) { data.marchId = 0; } } EventManager.GetInstance().SendEvent(EventId.AssignHero, marchID); } else { UnityEngine.Debug.Log("数据包报错了!!!"); } return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
private void Awake() { _rigidbody = GetComponent <Rigidbody2D>(); _player = GetComponent <PlayerProxy>(); }
public override void Execute(PureMVC.Interfaces.INotification notification) { proxy = (PlayerProxy)Facade.RetrieveProxy("PlayerProxy");//通过名字获取Proxy PastSingle recive = notification.Body as PastSingle; switch (notification.Name) { case NotificationConstant.playerCommand.PlayerMove: { proxy.Move(); } break; case NotificationConstant.playerCommand.JumpCommond: { proxy.Jump(); } break; case NotificationConstant.playerCommand.CollisionBaseCommond: { proxy.CollisionBase(); } break; case NotificationConstant.playerCommand.DiedCommond: { proxy.Died(); } break; case NotificationConstant.playerCommand.CollisionStay: { proxy.CollisionStay(); } break; case NotificationConstant.playerCommand.MouseLeftDown: { proxy.MouseDown(); } break; case NotificationConstant.playerCommand.MouseLeftUP: { proxy.MouseUp(); } break; case NotificationConstant.playerCommand.AtkMonsterArea: { proxy.inAtkArea(recive); } break; case NotificationConstant.playerCommand.JuageMonsterDistance: { proxy.JuageMonsterDis(recive); } break; case NotificationConstant.playerCommand.AtkMonster: { proxy.atkMonster(recive); } break; case NotificationConstant.playerCommand.ChangeHp: { proxy.ChangeHp(recive); } break; case NotificationConstant.playerCommand.ChangeCoin: { proxy.ChangeCoin(recive); } break; case NotificationConstant.playerCommand.ChainStateToFallState: { proxy.ChainStateToFallState(); } break; case NotificationConstant.playerCommand.ResetJumpData: { proxy.ResetJumpData(); } break; } }
public uint Execute(PacketDistributed ipacket) { GC_Troop_Train packet = (GC_Troop_Train )ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic if (packet.Ret == 0) { PlayerProxy playerProxy = GameFacade.GetProxy <PlayerProxy> (); bool find = false; for (int i = 0; i < playerProxy.city.trainList.Count; i++) { if (playerProxy.city.trainList[i].queueid == packet.Data.Queueid) { find = true; PlayerProxy.SetTrainVo(packet.Data, playerProxy.city.trainList [i]); } } if (!find) { TrainVo train = new TrainVo(); PlayerProxy.SetTrainVo(packet.Data, train); playerProxy.city.trainList.Add(train); } find = false; MarchVo march = null; for (int i = 0; i < playerProxy.marchList.Count; i++) { if (playerProxy.marchList [i].buildId == packet.Data.Buildid) { march = playerProxy.marchList [i]; for (int j = 0; j < playerProxy.marchList [i].troopList.Count; j++) { TroopVo vo = playerProxy.marchList [i].troopList [j]; if (vo.queueIndex == packet.Data.Queueindex) { find = true; } } } } if (!find) { TroopVo troop = new TroopVo(); troop.type = packet.Data.Trooptype; troop.health = 0; troop.level = 1; troop.queueIndex = packet.Data.Queueindex; march.troopList.Add(troop); } EventManager.GetInstance().SendEvent(EventId.TroopTrain, null); } else { UnityEngine.Debug.Log("数据包报错了!!!"); } return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
public override void create_instance() { //instance = GameObject.CreatePrimitive (PrimitiveType.Cube); instance = fashion.getInstance ().get_sprite ("character/xiaowanzi"); cell = new PlayerProxy (this); instance.AddComponent<Move>(); instance.AddComponent<SynPlayerProperty> (); instance.name = "hello"; }
public override void create_instance() { instance = GameObject.CreatePrimitive (PrimitiveType.Cube); instance.transform.localScale = new Vector3 (10, 10, 1); cell = new PlayerProxy (this); instance.AddComponent<Move>(); instance.AddComponent<SynPlayerProperty> (); instance.name = "hello"; }