public void NoStoryBlockThrowsException() { var bh = new BlockHandler(); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" ## this file has no story just a lonely scene".ToLines()))); }
public void StoryWithALegitAnchorParses() { var bh = new BlockHandler(); bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene) story with a simple link ## a scene this is a scene".ToLines())); }
public void StoryLinkingToNonExistentSceneThrowsException() { var bh = new BlockHandler(); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [a story](/non-existent) this story links to a first scene that doesn't exist ## a scene this scene is so cold and lonely".ToLines()))); }
public void StoryWithDuplicateActionsThrowsException() { var bh = new BlockHandler(); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [a story](/a-scene) this story is action-happy ## a scene this is the first scene ### an action this is an action ## another scene this is another scene ### an action oops, this is the same action!".ToLines()))); }
public bool Run() { this.blocksHandler = new BlockHandler(Environment.ProcessorCount, this.operationType, s => { Console.WriteLine(s); this.Abort(); }); if (!this.Init()) { return(false); } this.Process(); return(!isAborder); }
protected virtual void bindForDistributeSums(DataTable tab) { BlockHandler bh = new BlockHandler(); bh.setBlockPoint(globalRecalc); bh.getGroupBlockPoints().Add(cellBindingLines.getMainBlockPoint()); bh.getGroupBlockPoints().Add(cellBindingHeader.getMainBlockPoint()); cellBindingLines.addRelation( new string[] { TableSTLINE.PRICE, TableSTLINE.TOTAL, TableSTLINE.DISCPER }, new ImplTableColumnChangedWrap(new WorkerStart(distributeDocumentBalance)), bh, null); cellBindingHeader.addRelation( new string[] { TableINVOICE.DISCPER }, new ImplTableColumnChangedWrap(new WorkerStart(distributeDocumentBalance)), bh, null); }
public Primitive GetValue() { List <Object> blocks = entityProvider.GetEntities(); if (aggregationType == PropertyAggregate.COUNT) { return(new NumberPrimitive(blocks.Count)); } BlockHandler handler = BlockHandlerRegistry.GetBlockHandler(entityProvider.GetBlockType()); PropertySupplier p = property ?? handler.GetDefaultProperty(Return.NUMERIC); List <Primitive> propertyValues = blocks.Select(b => { return(direction.HasValue ? handler.GetPropertyValue(b, p, direction.Value) : handler.GetPropertyValue(b, p)); }).ToList(); return(Aggregate(propertyValues, aggregationType)); }
protected void SetLine(int currentLevel, int index, int line) { BlockTextureGenerator.BlockType type = (BlockTextureGenerator.BlockType)(line % 3); BlockTextureGenerator.Border border = BlockTextureGenerator.Border.BORDER; for (int y = 0; y < 4; y++) { BlockHandler block = blocks[index][y]; if (y >= line) { block.gameObject.SetActive(false); continue; } block.SetGlow(line == 4 ? 1.0f : 0.0f); block.SetImage(BlockTextureGenerator.Instance.getLevelSprite(currentLevel, border, type)); block.gameObject.SetActive(true); } }
public void StoriesWithFancyAnchorsThrowExceptions() { var bh = new BlockHandler(); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene?conditional) story with a conditional ## a scene this is a scene".ToLines()))); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene#toggle) story with a toggle ## a scene this is a scene".ToLines()))); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene#?conditional#toggle) story with a conditional and a toggle ## a scene this is a scene".ToLines()))); }
public void StoriesWithFancyAnchorsThrowExceptions() { var bh = new BlockHandler(); Assert.Throws <FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene?conditional) story with a conditional ## a scene this is a scene".ToLines()))); Assert.Throws <FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene#toggle) story with a toggle ## a scene this is a scene".ToLines()))); Assert.Throws <FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene#?conditional#toggle) story with a conditional and a toggle ## a scene this is a scene".ToLines()))); }
public void Awake() { for (int x = 0; x < MAX_HISTORY; x++) { blocks[x] = new BlockHandler[4]; for (int y = 0; y < 4; y++) { GameObject go = Instantiate(prefab.gameObject); BlockHandler bh = go.GetComponent <BlockHandler>(); RectTransform rt = go.GetComponent <RectTransform>(); rt.SetParent(this.gameObject.transform, true); Vector3 location = new Vector3(); location.x = x * (blockSize + 3); location.y = y * blockSize; rt.localPosition = location; rt.localScale = Vector3.one; blocks[x][y] = bh; } } }
public void Initialize(BlockHandler b, float x, float y, int p, bool s, bool small, int d) { bh = b; player = p; dir = d; if (small) { width = 2; height = 12; } else { width = 3; height = 8; } xStart = x; yStart = y; isShown = s; isSmall = small; TILE_SIZE = Consts.TILE_SIZE * (isSmall?sizeMultSmall:sizeMult); nextSelectLength = 0; nextSelectedTiles = new List <GameObject>(); addSprite = Resources.Load <Sprite>(SpritePaths.RecoveryTile); InitTiles(); }
private static void Main(string[] args) { var authHandler = new AuthHandler(); var blockHandler = new BlockHandler(); var roleAdminHandler = new RoleAdminHandler(); authHandler.SetNext(blockHandler).SetNext(roleAdminHandler); var userRequest = new UserRequest { IsAuth = true, IsBlocked = false, IsAdmin = false }; var result = authHandler.Check(userRequest); Console.WriteLine(result); Console.ReadKey(); }
public async Task <bool> FinishedDigging(IEntity entity, IGrainFactory grainFactory, IWorld world, BlockWorldPos position, BlockState blockState, long usedTick) { if (!blockState.IsSameId(BlockStates.Bedrock())) { var newState = BlockStates.Air(); await world.SetBlockState(grainFactory, position, newState); // 产生 Pickup var chunk = position.ToChunkWorldPos(); var finder = grainFactory.GetGrain <ICollectableFinder>(world.MakeAddressByPartitionKey(chunk)); var blockHandler = BlockHandler.Create((BlockId)blockState.Id); var droppedSlot = blockHandler.DropBlock(ItemId, blockState); if (!droppedSlot.IsEmpty) { await finder.SpawnPickup(position + new Vector3(0.5f, 0.5f, 0.5f), new[] { droppedSlot }.AsImmutable()); } return(true); } return(false); }
private void Awake() { for (int x = 0; x < NUM_LEVELS; x++) { data[x] = new BlockHandler[10]; for (int y = 0; y < 10; y++) { GameObject go = GameObject.Instantiate(prefab.gameObject); RectTransform rt = go.GetComponent <RectTransform>(); rt.SetParent(this.transform, true); Vector3 pos = new Vector3(); pos.x = x * xOffset; pos.y = y * yOffset; rt.localPosition = pos; //go.SetActive(true); data[x][y] = go.GetComponent <BlockHandler>(); } } inited = true; }
public void Update() { if (Locator.TurnManager.IsSelfTurn) { var self = _playerModelDict[GameTypes.PlayerType.SELF]; if (!self.CanPut()) { Locator.TurnManager.FinishTurn(GameTypes.PlayerType.SELF); } else { // isAI if (false) { var block = self.PickRandomBlock(); var cellPos = block.PickRandomEnableCellPosition(); BlockHandler.PutBlock(GameTypes.PlayerType.SELF, block.Id, Locator.CellManager.GetCell(cellPos.X, cellPos.Y)); } } } if (Locator.TurnManager.IsEnemyTurn) { var enemy = _playerModelDict[GameTypes.PlayerType.ENEMY]; if (!enemy.CanPut()) { Locator.TurnManager.FinishTurn(enemy.PlayerType); } else { // isAI if (false) { var block = enemy.PickRandomBlock(); var cellPos = block.PickRandomEnableCellPosition(); BlockHandler.PutBlock(GameTypes.PlayerType.ENEMY, block.Id, Locator.CellManager.GetCell(cellPos.X, cellPos.Y)); } } } }
void HorseToThisPosition() { AddPoint(); if (blockHandler == null) { blockHandler = GameObject.FindObjectOfType <BlockHandler>(); } blockHandler.StartMoving(); //When Start OnStartHorseMove(); Horse.horse.transform.parent = this.gameObject.transform; iTween.MoveTo(Horse.horse, iTween.Hash( "position", new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y - 45f, this.gameObject.transform.position.z), "time", 0.8f, "easetype", iTween.EaseType.easeInQuad, "islocal", true, "oncomplete", "OnFinishedHorseMove", "oncompletetarget", gameObject )); iTween.ShakePosition(BlockHandler.BlockHandlerGO, iTween.Hash( "amount", new Vector3(0.02f, 0.03f, 0.04f), "time", 0.08f )); //When Finishes iTween.ShakePosition(BlockHandler.BlockHandlerGO, iTween.Hash( "amount", new Vector3(0.04f, 0.06f, 0.08f), "time", 0.2f, "delay", 0.8f )); }
public ResolvedStory ParseStory(string storyText) { var lines = storyText.Split(new[] { "\n", "\r\n" }, StringSplitOptions.None); var blocks = BlockHandler.ExtractBlocks(lines); var story = BlockHandler.ParseBlocks(blocks); GameTraverser.Story = story; var resolved = StateResolver.Resolve(GameTraverser.Enumerate(), story); resolved.Orphans = GameTraverser.OrphanedScenes.Select(o => new Orphan { Type = "Scene", Name = o.Name, LineNumber = o.LineNumber }).Union(GameTraverser.OrphanedActions.Select(o => new Orphan { Type = "Action", Name = o.Toggle, LineNumber = o.LineNumber })); return(resolved); }
protected override void Initialization() { try { inputStream = BlockReader.GetInputStream(option.InputFileName); outputStream = BlockWriter.GetOutputStream(option.OutputFileName); } catch (FileNotFoundException) { Console.WriteLine("Файл не найден"); isAborted = true; return; } catch (FileLoadException ex) { OutputConsole.DisplayError(ex); isAborted = true; return; } blockReader = new CompressedBlockReader(inputStream); blockWriter = new DecompressedBlockWriter(outputStream); blocksHandler = new BlockHandler(Environment.ProcessorCount, ex => Callback(ex), CompressionMode.Decompress); }
public void SetLine(int numLines, int finalLine) { int level = finalLine / 10; level += START_LEVEL; for (int i = finalLine - numLines; i < finalLine; i++) { BlockHandler block = GetBlock(i); if (block == null) { break; } BlockTextureGenerator.Border border; BlockTextureGenerator.BlockType blockType; float alpha; GetSprite(numLines, out border, out blockType, out alpha); Sprite s = BlockTextureGenerator.Instance.getLevelSprite(level, border, blockType); block.SetImage(s); block.SetGlow(alpha); block.gameObject.SetActive(true); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("PlayerCollider")) { this.gameObject.transform.parent.gameObject.transform.parent = collision.gameObject.transform.parent; iTween.MoveTo(this.gameObject.transform.parent.gameObject, iTween.Hash( "position", new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + 45f, this.gameObject.transform.position.z), "time", 0.4f, "easetype", iTween.EaseType.easeInQuad, "islocal", true )); Horse.horse.gameObject.GetComponent <Image>().color = new Color32(0, 0, 0, 0); Horse.playerIsDead = true; BlockHandler.ShakeBlocks(); Handheld.Vibrate(); Score.GetBestScore(); } }
/// <summary> /// Poll for new messages in a stream. If new messages are found beyond the last consumed position then they /// will be delivered to the <seealso cref="IBlockHandler"/> up to a limited number of bytes. /// </summary> /// <param name="blockHandler"> to which block is delivered. </param> /// <param name="blockLengthLimit"> up to which a block may be in length. </param> /// <returns> the number of bytes that have been consumed. </returns> public int BlockPoll(BlockHandler blockHandler, int blockLengthLimit) { if (_isClosed) { return(0); } var position = _subscriberPosition.Get(); var termOffset = (int)position & _termLengthMask; var termBuffer = ActiveTermBuffer(position); var limit = Math.Min(termOffset + blockLengthLimit, termBuffer.Capacity); var resultingOffset = TermBlockScanner.Scan(termBuffer, termOffset, limit); var bytesConsumed = resultingOffset - termOffset; if (resultingOffset > termOffset) { try { var termId = termBuffer.GetInt(termOffset + DataHeaderFlyweight.TERM_ID_FIELD_OFFSET); blockHandler(termBuffer, termOffset, bytesConsumed, SessionId, termId); } catch (Exception t) { _errorHandler(t); } finally { _subscriberPosition.SetOrdered(position + bytesConsumed); } } return(bytesConsumed); }
override public void Setup(BoardCursorActualCore c, TweenHandler t, BlockHandler bh, Vector2 nexterPos, bool smallNext, bool show = true, bool touch = false) { base.Setup(c, t, bh, nexterPos, smallNext, show, touch); topoffset = 1; cursor.setWidthAndHeight(width, --height); }
public ABCIConnector(TransactionHandlerRouter transactionHandlerRouter, QueryProcessor queryProcessor, BlockHandler blockHandler) { _transactionHandlerRouter = transactionHandlerRouter; _queryProcessor = queryProcessor; _blockHandler = blockHandler; }
public BlocksController(IBlockRepository repository) { _repository = repository; _handler = new BlockHandler(_repository); }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag.Equals("Player")) { if (collision.contacts.Length > 0) { ContactPoint contact = collision.contacts[0]; if (Vector3.Dot(contact.normal, Vector3.down) > 0.5f) { //Grabs the player jumping script from the player the enemy made collision with PlayerJumping jump = collision.gameObject.GetComponent <PlayerJumping>(); //Makes the player jump up jump.Jump(5f); soundPlayer.PlaySound(Sounds.KICKING); if (!stompedHead) { stompedHead = true; gameManager.IncreaseScore(score); //Checks if the enemy has to been deleted from the scene if (enemy.deleted) { gameObject.SetActive(false); //Destroy(gameObject); } //Pauses the movement of the enemy else { pauseMovement = true; } } else { kickedEnemy = true; } } //Checks if the player hits the enemy while its not moving anymore else if (stompedHead && pauseMovement) { //Grabs the new direction of the enemy direction = (int)Input.GetAxisRaw("Horizontal"); kickedEnemy = true; soundPlayer.PlaySound(Sounds.KICKING); } else { gameManager.HandleDeath(); } } } else if (collision.gameObject.tag.Equals("Floor") || collision.gameObject.tag.Equals("Interactable")) { //Switch direction direction = direction == 1 ? -1 : 1; //Checks if the enemy hit a interactable and is in shell form (aka been stomped and moving) if (collision.gameObject.tag.Equals("Interactable") && stompedHead) { BlockHandler blockHandler = collision.gameObject.GetComponent <BlockHandler>(); blockHandler.HandleCollision(); } } }
// Update is called once per frame void Update() { if (isGameEnd) { return; } //콤보 시간과 아이템 시간 체크 후 안내메시지 사라짐 if (comboTimer < 0) { comboText.SetActive(false); comboCount = 0; } comboTimer -= Time.deltaTime; if (itemTimer < 0) { itemText.SetActive(false); itemTimer = 0; } itemTimer -= Time.deltaTime; if (nowBlockHandler.isEnd()) //블록 이동이 끝났다면 { if (!checkGameEnd()) //게임이 끝난 지 체크 { while (renewBlock(checkDestoryBlock())) //줄을 사라지게 한 뒤 터진 줄부터 안터진 줄까지 줄수를 -1 해줌 { } nowBlockHandler = new BlockHandler(gamePanel, blockPerfap); //새로운 블록생성 } } else { if (Input.GetKeyDown(KeyCode.UpArrow)) { nowBlockHandler.move(0); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { nowBlockHandler.move(MoveType.Move_Right); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { nowBlockHandler.move(MoveType.Move_Down); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { nowBlockHandler.move(MoveType.Move_Left); } else if (Input.GetKeyDown(KeyCode.Space)) { nowBlockHandler.move(MoveType.Set_Down); } timer += Time.deltaTime; //내려가는 속도 조절 if (timer < timeDelay) { return; } timer = 0; nowBlockHandler.move(MoveType.Move_Down); } }
void Start() { Cursor.visible = false; bh = new BlockHandler(); bh.createDictionary(); bh.registerBlocks(); }
public void StoryWithNoAnchorThrowsException() { var bh = new BlockHandler(); Assert.Throws<FicdownException>(() => bh.ParseBlocks(bh.ExtractBlocks(@" # my story doesn't link to a scene ## a scene nothing links here".ToLines()))); }
public void StoryWithScenesAndActionsParses() { var bh = new BlockHandler(); var story = bh.ParseBlocks(bh.ExtractBlocks(@" # [my story](/a-scene) story with a simple link ## a scene this is a scene ## [a scene](?something) this is the same scene with a conditional ## another scene this is another scene ### action1 this is an action ### action 2 this is another action ## yet another scene yup here's some more ### another action the last action (hero?)".ToLines())); Assert.Equal(3, story.Scenes.Count); Assert.Equal(2, story.Scenes["a-scene"].Count); Assert.Equal(3, story.Actions.Count); }
protected virtual void DoTheActualSetup() { StateControllerInit(false); usingTouchControls = PD.GetSaveData().savedOptions["touchcontrols"] == 1; firstLaunch = true; player1Human = !PD.isDemo; player2Human = (PD.gameType == PersistData.GT.Versus); bh = new BlockHandler(PD, PD.GetPuzzleLevel()); zaps = new List <ZappyGun>(); zapsToDelete = new List <ZappyGun>(); SetupCountdown(); SetupActors(); SetupRoundDisplay(); SetupEasterEgg(); specialMode = PD.useSpecial; height = PD.isTutorial?6:PD.rowCount; width = 8; float p1Xoffset = (player2Human || (PD.isDemo && PD.demoPlayers == 2)) ? -10.1f : (PD.IsLeftAlignedHUD()?-1.5f:-5.5f), p2Xoffset = 3.0f; CreateBoards(p1Xoffset, p2Xoffset); SetUpHUDAndScores(); if (PD.runningScore > 0) { board1.AddToScore(PD.runningScore); } if (PD.runningTime > 0) { hud.SetTimeWithSeconds(PD.runningTime); } if (PD.gameType == PersistData.GT.Challenge) { (board1 as BoardWarPuzzlePlayer).unlockedRow = (hud as PuzzleHUD).GetUnlockedRow(); } cursor1 = CreatePlayerCursor(player1Human, p1Xoffset, 1, board1, board2); cursor2 = CreatePlayerCursor(player2Human || PD.override2P, p2Xoffset, 2, board2, board1, PD.override2P); board1.Setup(cursor1, th, bh, (player2Human || (PD.isDemo && PD.demoPlayers == 2)) ? new Vector2(-0.2f, -0.6f) : new Vector2(PD.IsLeftAlignedHUD()?-0.725f:0.75f, -0.6f), player2Human || (PD.isDemo && PD.demoPlayers == 2), true, player1Human && usingTouchControls); board2.Setup(cursor2, th, bh, new Vector2(0.2f, -0.6f), true, player2Human || (PD.isDemo && PD.demoPlayers == 2)); board1.RefreshGraphics(); board2.RefreshGraphics(); CreateMirrors(p1Xoffset, p2Xoffset); mirror1.RefreshGraphics(); mirror2.RefreshGraphics(); SetupMouseControls(p1Xoffset); if (!PD.isDemo) { if (PD.gameType == PersistData.GT.Campaign) { campaign = new CampaignHandler(PD, board1 as BoardWarSpecial, board2 as BoardWarCampaign, mirror2 as BoardMirrorSpecial, cursor1 as BoardCursorWar, cursor2 as BoardCursorBot, hud as CampaignHUD, GetXMLHead()); } pauseButtonSheet = Resources.LoadAll <Sprite>(SpritePaths.ShortButtons); pauseButton = GetGameObject(player2Human ? (new Vector3(0.0f, -0.1f)):(new Vector3(2.5f, 0.7f)), "Pause Button", pauseButtonSheet[0], true, "HUD"); pauseButton.SetActive(PD.usingMouse); pauseButton.transform.localScale = new Vector3(0.75f, 0.75f); FontData f = PD.mostCommonFont.Clone(); f.scale = 0.035f; pauseText = GetMeshText(player2Human ? (new Vector3(0.0f, 0.0f)):(new Vector3(2.5f, 0.8f)), GetXmlValue(GetXMLHead(), "pause"), f).gameObject; pauseText.SetActive(PD.usingMouse); pauseTimer = 0; mouseObjects.Add(pauseButton); mouseObjects.Add(pauseText); } else { demoCountdown = 1800; } }
/// <summary> /// Toggles all functions to return angles in degrees. /// </summary> public static void UseDegrees() { BlockHandler.UseDegrees(); }
public BlockHandlerWrapper(BlockHandler @delegate) { _delegate = @delegate; }
public BlockCommand(BlockHandler blockHandler, EntityProvider entityProvider, BlockCommandHandler commandHandler) { this.blockHandler = blockHandler; this.entityProvider = entityProvider; this.commandHandler = commandHandler; }
public static IBlockHandler ToBlockHandler(BlockHandler @delegate) { return(new BlockHandlerWrapper(@delegate)); }
/// <summary> /// Toggles all functions to returns angles in radians. /// </summary> public static void UseRadians() { BlockHandler.UseRadians(); }