public RemoteClientBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                         SoundManager soundManager, GameSignalingHost gameSignalingHost,
                                         MeleeAttackEntity meleeAttackEntity, EventSystemWatcher eventSystemWatcher)
        {
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.EnemyTankTransform = botEntity.transform;
            botEntity.gameObject.layer     = LayerMask.NameToLayer("EnemyBot");
            botEntity.transform.position   = tileMapInfo.GetPlayer2StartPosition();
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("EnemyBullet")),
                true
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun,
                meleeAttackApplication
                );

            gameSignalingHost.ReceivedHostReceiveSignalData += data =>
            {
                new BotCommandsTransformerService().FromCommandData(data.clientCommandData, botApplication);
                gameSignalingHost.SendData(new ClientReceiveSignalData(data.clientCommandData, MatchType.Client));
            };
        }
Exemplo n.º 2
0
        public HostMultiPlayGame(PlayGameInitData playGameInitData, MultiGameInfo multiGameInfo)
        {
            gameSignalingHost =
                new GameSignalingHost(multiGameInfo.myTcpClient, SelectedStageData.GetSelectedStageKind());

            var playerMeleeAttackEntity = Object.Instantiate(playGameInitData.meleeAttackPrefab);

            playerMeleeAttackEntity.gameObject.layer = LayerMask.NameToLayer("PlayerBullet");

            var enemyMeleeAttackEntity = Object.Instantiate(playGameInitData.meleeAttackPrefab);

            enemyMeleeAttackEntity.gameObject.layer = LayerMask.NameToLayer("EnemyBullet");


            playerBotController = new HostBotController(
                playGameInitData.botEntityPrefab,
                playGameInitData.tileMapInfo,
                playGameInitData.bulletPrefab,
                playGameInitData.cameraFollower,
                playGameInitData.playerHpPresenter,
                playGameInitData.runButtonEvent,
                playGameInitData.scriptText,
                playGameInitData.errorMsg,
                playGameInitData.soundManager,
                gameSignalingHost,
                playerMeleeAttackEntity,
                playGameInitData.processScrollViewPresenter,
                playGameInitData.eventSystemWatcher
                );
            enemyBotController = new RemoteClientBotController(
                playGameInitData.botEntityPrefab2P,
                playGameInitData.tileMapInfo,
                playGameInitData.bulletPrefab,
                playGameInitData.soundManager,
                gameSignalingHost,
                enemyMeleeAttackEntity,
                playGameInitData.eventSystemWatcher
                );
        }
Exemplo n.º 3
0
 void CreateGameSignaling(MyTcpClient myTcpClient, MatchType matchType)
 {
     if (MatchType.Client == matchType)
     {
         matchedClientFlag   = true;
         gameSignalingClient = new GameSignalingClient(myTcpClient);
         gameSignalingClient.ReceivedClientReceiveSignalData += (obj) =>
         {
             //   Debug.Log("ClientReceived:" + Enum.GetName(typeof(BattleResult), obj.battleResult));
             //   Debug.Log("ClientReceived:" + Enum.GetName(typeof(CommandKind), obj.commandData.kind));
         };
     }
     else
     {
         matchedHostFlag   = true;
         gameSignalingHost = new GameSignalingHost(myTcpClient, StageKind.Stage1);
         gameSignalingHost.ReceivedHostReceiveSignalData += (obj) =>
         {
             //  Debug.Log("HostReceived:" + Enum.GetName(typeof(CommandKind), obj.clientCommandData.kind));
         };
     }
 }
 public HostBotCommandsHook(IBotCommands botCommands, GameSignalingHost gameSignalingHost)
 {
     this.botCommands       = botCommands;
     this.gameSignalingHost = gameSignalingHost;
 }
Exemplo n.º 5
0
        public HostBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                 CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent,
                                 ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager, GameSignalingHost gameSignalingHost,
                                 MeleeAttackEntity meleeAttackEntity, ProcessScrollViewPresenter processScrollViewPresenter,
                                 EventSystemWatcher eventSystemWatcher)
        {
            this.errorMsg          = errorMsg;
            this.playerHpPresenter = playerHpPresenter;
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.PlayerTankTransform = botEntity.transform;
            botEntity.gameObject.layer      = LayerMask.NameToLayer("PlayerBot");
            cameraFollower.SetPlayerPosition(botEntity.transform);
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();

            botEntity.transform.position = tileMapInfo.GetPlayer1StartPosition();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("PlayerBullet")),
                false
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun,
                meleeAttackApplication
                );
            var hookBotApplication = new HostBotCommandsHook(botApplication, gameSignalingHost);

            javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(hookBotApplication);
            runButtonEvent.AddClickEvent(async() =>
            {
                var tokenSource = new CancellationTokenSource();
                var token       = tokenSource.Token;
                var panel       =
                    processScrollViewPresenter.AddProcessPanel(
                        () => { tokenSource.Cancel(); });
                var task = javaScriptEngine.ExecuteJS(scriptText.GetScriptText(), token, panel.ProcessId);
                await task;
                panel.Dispose();
            });
        }