private async void BuildBorders_Click(object sender, RoutedEventArgs e)
        {
            EnableSpecialButtons(false);
            await BlockChecker.Of(client).FinishChecksAsync();

            EnableSpecialButtons(true);
        }
示例#2
0
    public SymBlock IsNeighbourNode(BlockChecker current_c)
    {
        if (current_c.checkerNextTo != null)
        {
            SymBlock b_in_row         = Helpers.GetBlock(current_c.checkerNextTo.checkers_container.position);
            Vector3  dir_to_current_c = current_c.position.RotateOnY(-b_in_row.BlockRotation.y);

            if (b_in_row != null)
            {
                if (b_in_row.IsNode || b_in_row.HasManualNodes)
                {
                    return(b_in_row);
                }
                else
                {
                    if (b_in_row.HasManualNodes)
                    {
                        // TODO: pokud blok má vnitřní nody
                    }

                    foreach (BlockChecker b_in_row_c in b_in_row.Checkers)
                    {
                        Vector3 dir_to_in_row_c = b_in_row_c.position.RotateOnY(-b_in_row.BlockRotation.y);

                        if (dir_to_in_row_c == dir_to_current_c)
                        {
                            return(IsNeighbourNode(b_in_row_c));
                        }
                    }
                }
            }
        }
        return(null);
    }
示例#3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="lastActiveBlock"></param>
    /// <param name="placePos"> //!!! GLOBÁLNÍ POZICE CHECKERU !!!</param>
    /// <returns></returns>
    public static BlockChecker GetLastActiveChecker(SymBlock lastActiveBlock, Vector3 placePos)
    {
        BlockChecker lastActiveChecker = null;

        // Tady se dohledá checker na který se kliklo (v db)
        foreach (BlockChecker c in lastActiveBlock.Checkers)
        {
            Vector3 checker_pos = c.CheckerTransform.position; // GLOBÁLNÍ POZICE CHECKERU

            // Pokud se pozice daného checkeru rovná pozici kterou nám vrátili hit data
            if (checker_pos == placePos)
            {
                // Tak se jedná o last active
                lastActiveChecker = c;

                // Ujistíme se, že jsou dány správně codinates, jinak přepíšeme na správné
                if (lastActiveChecker.checkers_container.position != lastActiveBlock.BlockPosition)
                {
                    lastActiveChecker.checkers_container.position = lastActiveBlock.BlockPosition;
                }
                break;
            }
        }

        return(lastActiveChecker);
    }
示例#4
0
    // BUILDMODE

    public void TurnBuildModeOn(BlockChecker controllerToBuildOn = null)
    {
        GameModesManager.Instance.SetGameMode(new BuildMode());
        GameModesManager.Instance.TurnModeOn();

        if (controllerToBuildOn != null)
        {
            var placeMode = new BuildSubModePlace(controllerToBuildOn);
            GameModesManager.Instance.subModesHandler.SetSubMode(placeMode);
            GameModesManager.Instance.subModesHandler.TurnModeOn();
        }
    }
示例#5
0
        // Najde další kontrolér pro build
        public BlockChecker GetNextCheckerToBuild()
        {
            BlockChecker nextBlock = null;

            // Nalezneme další checker pro build
            nextBlock = Settings.LoopCheckersInList_And_ReturnByLambda(TryToGetNextCheckerForBuild, _blockToFindOn.Checkers);

            // Pokud se je kontrolér stále null, zvolíme kontrolér napravo.
            if (nextBlock == null)
            {
                nextBlock = Settings.LoopCheckersInList_And_ReturnByLambda(TryToGetBlocksCheckerByPopulation, _blockToFindOn.Checkers);
            }
            return(nextBlock);
        }
示例#6
0
 private BlockChecker TryToGetNextCheckerForBuild(BlockChecker c)
 {
     if (c.CheckerTransform.position == _blockToFindOn.BaseCheckerNextTo.CheckerTransform.position)
     {
         foreach (BlockChecker c_potentional in _blockToFindOn.Checkers)
         {
             if (c_potentional != c)
             {
                 if (c.position == c_potentional.position * (-1)) // Pokud je to ten na proti
                 {
                     return(c_potentional);
                 }
             }
         }
     }
     return(null);
 }
示例#7
0
        private async void OnScanRequest(ScanRequestEvent e)
        {
            var spots = EmptyMapSpots;

            if (spots.Count == 0)
            {
                new ScanResultEvent(false, "No empty slots left.").RaiseIn(BotBits);
                return;
            }

            List <Map> maps;

            try
            {
                maps =
                    await
                    new MapScanner(MapWidth, MapHeight).LoadMapsAsync(e.TargetWorldId, ScanSignFormat,
                                                                      MapPositionMapper);
            }
            catch (MapLoadException ex)
            {
                new ScanResultEvent(false, ex.Message).RaiseIn(BotBits);
                return;
            }

            if (maps.Count == 0)
            {
                new ScanResultEvent(false, "No maps found.").RaiseIn(BotBits);
                return;
            }

            var blocks     = Blocks.Of(BotBits);
            var spotNumber = 0;

            var numAccepted = 0;
            var numRejected = 0;

            var result = ReviewResult.Rejected;

            foreach (var map in maps)
            {
                spots[spotNumber].AddMap(blocks, map);

                await PlaceSendMessage.Of(BotBits).FinishQueueAsync();

                await BlockChecker.Of(BotBits).FinishChecksAsync();

                reviewResult       = new TaskCompletionSource <ReviewResult>();
                waitingForResponse = true;
                new MapForReviewEvent(map.Name, map.Creators, numAccepted + numRejected + 1, maps.Count).RaiseIn(BotBits);

                result = await reviewResult.Task;

                waitingForResponse = false;

                switch (result)
                {
                case ReviewResult.Accepted:
                {
                    numAccepted++;
                    spotNumber++;

                    if (spotNumber < spots.Count)
                    {
                        continue;
                    }

                    new ScanResultEvent(false,
                                        "Scan not finished completely. Ran out of free spots.",
                                        numAccepted,
                                        numRejected).RaiseIn(BotBits);
                    return;
                }

                case ReviewResult.Rejected:
                {
                    numRejected++;
                    break;
                }

                case ReviewResult.Stopped:
                {
                    spots[spotNumber].Clear(blocks);

                    new ScanResultEvent(false,
                                        "Scan stopped.",
                                        numAccepted,
                                        numRejected).RaiseIn(BotBits);
                    return;
                }
                }
            }

            // Clear last map when rejected
            if (result == ReviewResult.Rejected)
            {
                spots[spotNumber].Clear(blocks);
            }

            new ScanResultEvent(true, "Scan succeeded.", numAccepted, numRejected).RaiseIn(BotBits);
        }
示例#8
0
 public void SetLastActiveChecker() => _lastActiveChecker = Helpers.GetLastActiveChecker(base.LastInteractedBlock, base.HitData.transform.position);
示例#9
0
 public BuildSubModePlace(BlockChecker checkerToBuildOn)
 {
     _checkerToBuildOn = checkerToBuildOn;
 }
示例#10
0
 // Symetrický blok
 public static IBlock CreateSymBlock(Vector3 position, Vector3 rotation, BlockSO BlockData, BlockChecker baseChecker)
 {
     return(new SymBlock(position, rotation, BlockData, baseChecker));
 }
示例#11
0
    public SymBlock CreateNewSymBlock(Vector3 position, Vector3 rotation, BlockSO BlockData, BlockChecker lastActiveChecker)
    {
        _newBlock = (SymBlock)BlockFactory.CreateSymBlock(position, rotation, BlockData, lastActiveChecker);

        var newBlock = (SymBlock)_newBlock;

        var bConstructor = BlockFactory.BlockConstructor((SymBlock)newBlock);

        bool wasBlockConstructed = newBlock.ConstructBlock(bConstructor);

        if (!wasBlockConstructed)
        {
            Debug.LogError("Symetricý blok se nepodařilo vytvořit!");
        }

        newBlock.SetBlockOrientation();

        newBlock.ConstructBlockPost(bConstructor);

        return((SymBlock)_newBlock);
    }
示例#12
0
        //public event EventHandler<ModifyWorldEventArgs> AddBlockEvent;

        public AddBlockToWorldAction(World world, BlockChecker checkerBuildingOn, Settings.Blocks_types blockTypeToAdd)
        {
            _world             = world;
            _blockTypeToAdd    = blockTypeToAdd;
            _checkerBuildingOn = checkerBuildingOn;
        }
示例#13
0
        private BlockChecker TryToGetBlocksCheckerByPopulation(BlockChecker c)
        {
            Vector3 population = Settings.GetVector3Population_(c.position).RotateOnY(_blockToFindOn.BlockRotation.y);

            return(c = population.z == 1 ? c : null);
        }
 void Awake()
 {
     Instance = this;
 }