public RemoteHostBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab, SoundManager soundManager, GameSignalingClient gameSignalingClient, MeleeAttackEntity meleeAttackEntity, EventSystemWatcher eventSystemWatcher) { var botEntity = Object.Instantiate(botEntityPrefab); tileMapInfo.EnemyTankTransform = botEntity.transform; botEntity.gameObject.layer = LayerMask.NameToLayer("EnemyBot"); botEntity.transform.position = tileMapInfo.GetPlayer1StartPosition(); 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, true ); gameSignalingClient.ReceivedClientReceiveSignalData += data => { if (data.commandApplyTarget == MatchType.Host) { new BotCommandsTransformerService().FromCommandData(data.commandData, botApplication); } }; }
public PlayerBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab, CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent, ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager, 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 ); javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(botApplication); runButtonEvent.AddClickEvent(() => OnRunButtonClick(processScrollViewPresenter, scriptText)); }
private void Start() { _info = GetComponent <TileMapInfo>(); GridPosition p1 = _info.GetGridPosition(new Vector3(-208, -160)); GridPosition p11 = new GridPosition(1, 1); Debug.Assert(_info.GetTileType(p1) == TileType.Rock); Debug.Assert(_info.GetTileType(_info.GetGridPosition(_info.GetPlayer1StartPosition())) == TileType.Empty); Debug.Assert(_info.GetTileType(_info.GetGridPosition(_info.GetPlayer2StartPosition())) == TileType.Empty); Debug.Log(_info.GetTileType(new GridPosition(0, 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(); }); }