Ejemplo n.º 1
0
 public void GameOver()
 {
     GameObject.Destroy(currentRoleGameObject);
     GameObject.Destroy(playerSyncRequest);
     GameObject.Destroy(remoteRoleGameObject);
     shootRequest  = null;
     attackRequest = null;
 }
Ejemplo n.º 2
0
 public void CreateSyncRequest()
 {
     playerSyncRequest = new GameObject("PlayerSyncRequest");
     playerSyncRequest.AddComponent <MoveRequest>().SetLocalPlayer(currentRoleGameObject.transform, currentRoleGameObject.GetComponent <PlayerMove>()).SetRemotePlayer(remoteRoleGameObject.transform);
     shootRequest           = playerSyncRequest.AddComponent <ShootRequest>();
     shootRequest.playerMng = this;
     attackRequest          = playerSyncRequest.AddComponent <AttackRequest>();
 }
Ejemplo n.º 3
0
 //游戏结束销毁对象
 public void GameOver()
 {
     GameObject.Destroy(currentRoleGameObject);
     GameObject.Destroy(playerSyncRequest);
     GameObject.Destroy(enemyRoleGameObject);
     roleDataDic.Clear();
     shootRequest  = null;
     attackRequest = null;
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 创建同步请求对象,将用于同步操作的脚本都放置到该游戏物体上
    /// </summary>
    public void CreateSyncRequest()
    {
        playerSyncRequest = new GameObject("PlayerSyncRequest");                                        //在场景中创建游戏物体
        MoveRequest moveRequest = playerSyncRequest.AddComponent <MoveRequest>();                       //添加移动同步请求对象

        moveRequest.SetLocalPlayer(currentRoleGo.transform, currentRoleGo.GetComponent <PlayerMove>()); //告知移动同步对象,本地角色的位置信息
        moveRequest.SetRemotePlayer(remoteRoleGo.transform);                                            //设置敌对角色,用于接收到同步信息以后直接控制敌对角色移动
        shootRequest = playerSyncRequest.AddComponent <ShootRequest>();                                 //添加同步箭矢射击的请求对象
        shootRequest.playerManager = this;
        attackRequest = playerSyncRequest.AddComponent <AttackRequest>();                               //添加造成伤害的请求对象
    }
Ejemplo n.º 5
0
 public void CreatSyncRequest()
 {
     playerSyncReuest = new GameObject("playerSyncRequest");
     //设置本地客户端及另一个客户端的Obj
     playerSyncReuest.AddComponent <MoveRequest>()
     .SetLocalPlayer(currentRoleObj.transform, currentRoleObj.GetComponent <PlayerMove>())
     .SetRemotePlayer(remoteRoleObj.transform);
     shootRequest = playerSyncReuest.AddComponent <ShootRequest>();
     shootRequest.playerManager = this;
     attackReuest = playerSyncReuest.AddComponent <AttackRequest>();
 }
Ejemplo n.º 6
0
 public void CreateSyncRequest()
 {
     PlayerSyncRequest = new GameObject("PlayerSyncRequest");
     PlayerSyncRequest.AddComponent <MoveRequest>().
     SetLocalPlayer(currentGameObject.transform, currentGameObject.GetComponent <PlayerMove>()).
     SetRemotePlayer(remotePlayerDict);
     shootRequest = PlayerSyncRequest.AddComponent <ShootRequest>();
     shootRequest.playerManager = this;
     damageRequest = PlayerSyncRequest.AddComponent <DamageRequest>();
     damageRequest.playerManager = this;
 }
Ejemplo n.º 7
0
 public void CreateSyncRequest()                              //創造同步 //把這個當成雙方同步的橋樑
 {
     playerSyncRequest = new GameObject("PlayerSyncRequest"); //創造一個GameObject
     playerSyncRequest.AddComponent <MoveRequest>().SetLocalPlayer(currentRoleGameObject.transform, currentRoleGameObject.GetComponent <PlayerMove>())
     .SetRemotePlayer(remoteRoleGameObject.transform);
     //給這個GameObje這個添加MoveRequest(同步移動的請求)並設置本地端角色(設置位置跟移動腳本)
     //也要設置遠端的角色(設置位置)
     //再來添加攻擊請求(負責叫後端扣受攻擊玩家的血)跟射擊請求(負責箭)
     shootRequest           = playerSyncRequest.AddComponent <ShootRequest>();
     shootRequest.playerMng = this;
     attackRequest          = playerSyncRequest.AddComponent <AttackRequest>();
 }
Ejemplo n.º 8
0
 public void GameOver()
 {
     GameObject.Destroy(currentGameObject);
     GameObject.Destroy(PlayerSyncRequest);
     GameObject.Destroy(remoteGameObject);
     remotePlayerDict.Clear();
     //foreach (var item in remoteGameobject)
     //{
     //    GameObject.Destroy(item);
     //}
     //remoteGameobject.Clear();
     shootRequest  = null;
     damageRequest = null;
 }
    public void GameOver()
    {
        //private GameObject currentRoleGameObject;
        //private GameObject playerSyncRequest;
        //private GameObject remoteRoleGameObject;

        //private ShootRequest shootRequest;
        //private AttackRequest attackRequest;
        GameObject.Destroy(currentRoleGameObject);
        GameObject.Destroy(playerSyncRequest);
        GameObject.Destroy(remoteRoleGameObject);
        shootRequest  = null;
        attackRequest = null;
    }
Ejemplo n.º 10
0
    public void GameOver() //遊戲結束,由PlayerMng執行函式,因為遊戲結束後要摧毀某些跟Player有關的物件
    {
        //private GameObject currentRoleGameObject;
        //private GameObject playerSyncRequest;
        //private GameObject remoteRoleGameObject;

        //private ShootRequest shootRequest;
        //private AttackRequest attackRequest;
        GameObject.Destroy(currentRoleGameObject); //本地端現有物件
        GameObject.Destroy(playerSyncRequest);     //同步的橋樑
        GameObject.Destroy(remoteRoleGameObject);  //遠端物件
        shootRequest  = null;
        attackRequest = null;
    }
Ejemplo n.º 11
0
Archivo: Game.cs Proyecto: fossabot/BGE
        public ShootResponse Shoot(ShootRequest shootRequest, PlayerState playerState)
        {
            var x             = shootRequest.X - 1;
            var y             = shootRequest.Y - 1;
            var shootResponse = new ShootResponse
            {
                IsHit = playerState.Field[x, y] == Constants.FieldShipSymbol
            };

            playerState.Field[x, y] = shootResponse.IsHit
                                ? Constants.FieldShipSinkSymbol
                                : Constants.FieldHitSymbol;

            shootResponse.PlayerState = playerState;
            return(shootResponse);
        }
Ejemplo n.º 12
0
        public override Task <ShootReply> Shoot(ShootRequest request,
                                                ServerCallContext context)
        {
            var resultMessage = new ShootReply();

            //Get Serivce's hand
            var serviceHand = GetHand();
            //Get Result
            var shootResult = GetShootResult(request.Shoot.Hand, serviceHand);

            return(Task.FromResult(new ShootReply
            {
                ShootResult = shootResult,
                Message = $"{request.Shoot.UserName} shot {request.Shoot.Hand} and {shootResult} to {serviceHand}"
            }));
        }
Ejemplo n.º 13
0
Archivo: Game.cs Proyecto: PDmatrix/BGE
        public ShootResponse Shoot(ShootRequest shootRequest)
        {
            var x             = shootRequest.X - 1;
            var y             = shootRequest.Y - 1;
            var shootResponse = new ShootResponse
            {
                IsHit = shootRequest.Field[x, y] == Constants.FieldShipSymbol
            };

            shootRequest.Field[x, y] = shootResponse.IsHit
                                ? Constants.FieldShipSinkSymbol
                                : Constants.FieldHitSymbol;

            var ships = shootRequest.Field.Cast <char>().Count(symbol => symbol == Constants.FieldShipSymbol);

            shootResponse.Field    = shootRequest.Field;
            shootResponse.IsWinner = ships == 0;
            return(shootResponse);
        }
Ejemplo n.º 14
0
    //创建用于同步的游戏物体
    public void CreateSyncRequest()
    {
        SyncRequestGameObject = new GameObject("SyncGameObject");

        SyncRequestGameObject.AddComponent <MoveRequest>().SetLocalPlayer(currentGO.transform, currentGO.GetComponent <PlayerMove>()).
        SetRemotePlayer(remoteGO.transform, remoteGO.GetComponent <Animator>());                    //添加用于同步位置信息的脚本,并设置其成员

        shootRequest = SyncRequestGameObject.AddComponent <ShootRequest>();                         //添加用于处理攻击行为的脚本,并设置其成员
        shootRequest.playerManager = this;

        attackRequest = SyncRequestGameObject.AddComponent <AttackRequest>();                        //添加用于处理伤害扣血请求的脚本

        udInfoRequest = SyncRequestGameObject.AddComponent <UpdatePlayerInfoRequest>();              //添加用于更新双方属性的脚本
        udInfoRequest.playerManager = this;

        gainInfoRequest = SyncRequestGameObject.AddComponent <GainInfoRequest>();                    //添加用于属性提升请求的脚本

        rampageRequest = SyncRequestGameObject.AddComponent <RampageRequest>();                      //添加暴走请求脚本
        rampageRequest.playerManager = this;
    }
    //创建同步请求
    public void CreatSyncRequest()
    {
        //1、创建同步位置的请求
        syncGo = new GameObject("PlayerSyncRequest");
        MoveRequest moveRequest = syncGo.AddComponent <MoveRequest>();

        //设置本地角色和远程角色
        moveRequest.SetLocalPlayer(currentRoleGo.transform, currentRoleGo.GetComponent <PlayerMove>());
        moveRequest.SetRemotePlayer(syncRoleGo.transform, syncRoleGo.GetComponent <Animator>());
        //开始位置同步
        moveRequest.StartSync();

        //2、箭的位置同步
        ShootRequest shootRequest = syncGo.AddComponent <ShootRequest>();

        shootRequest.SetRemoteArrow(roleDateDict[syncRoleType].ArrowPrefab);
        playerAttack.SetShootRequest(shootRequest);

        //3、伤害同步
        AttackRequest attackRequest = syncGo.AddComponent <AttackRequest>();

        playerAttack.SetAttckRequest(attackRequest);
    }
Ejemplo n.º 16
0
 //设置射击请求实例
 public void SetShootRequest(ShootRequest shootRequest)
 {
     this.shootRequest = shootRequest;
 }
Ejemplo n.º 17
0
 public Player(Transform transform, Transform gunTransform, ShootRequest shootRequest)
 {
     this.transform    = transform;
     this.gunTransform = gunTransform;
     this.shootRequest = shootRequest;
 }
Ejemplo n.º 18
0
        public async Task <ShootResponse> Shoot(ShootRequest shootRequest, PlayerState playerState)
        {
            await shootRequest.ValidateAndThrowAsync(playerState);

            return(_game.Shoot(shootRequest, playerState));
        }
Ejemplo n.º 19
0
 public Task <ShootResponse> Shoot(ShootRequest shootRequest)
 {
     return(Task.FromResult(_game.Shoot(shootRequest)));
 }