示例#1
0
 internal PushedBlock PushWriteBlock(BlockKind kind, string msg, NewLineKind next)
 {
     PushBlock(kind);
     WriteLine(msg);
     WriteOpenBraceAndIndent();
     return(new PushedBlock(this, next));
 }
示例#2
0
    //--------------------------------------------------------------------------------------------------------
    private void CreateBlocks()
    {
        // handle the early game using special block-creating logic
        switch (turnCount)
        {
        case 1:
            CreateFirstBlock();
            return;

        case 2:
            CreateSecondBlock();
            return;
        }

        int openHexCount = (from hex in hexes where hex.Occupant == null select hex).Count();

        if (openHexCount == 0)
        {
            // how did we get here?
            return;
        }

        // how many blocks are we supposed to create?
        int   newBlockCount = 1;
        float d100Roll      = Random.Range(0f, 100f);

        if (d100Roll <= CurrentDoubleChance)
        {
            newBlockCount = 2;
        }
        else if (d100Roll <= CurrentDoubleChance + CurrentTripleChance)
        {
            newBlockCount = 3;
        }

        // if the board only has 2 or 3 hexes open, don't suddenly fill all of them and make the
        // player lose - instead, make sure there's still 1 more empty hex after the drop
        if (openHexCount > 1 && newBlockCount >= openHexCount)
        {
            newBlockCount = openHexCount - 1;
        }

        // create as many blocks as we need
        for (int i = 0; i < newBlockCount; i++)
        {
            d100Roll = Random.Range(0f, 100f);
            BlockKind newBlockKind = d100Roll <= CurrentWildChance ? BlockKind.WildCard : BlockKind.Normal;
            openHexes  = (from hex in hexes where hex.Occupant == null select hex).ToList();
            newDropHex = openHexes[Random.Range(0, openHexes.Count - 1)];

            CreateBlock(newDropHex, newBlockKind, 1, true);

            // if the board is full and there are no moves available, end the game
            if (IsBoardFullAndImmobile())
            {
                EnterGameOverState();
                return;
            }
        }
    }
示例#3
0
文件: Board.cs 项目: phansorg/DDChain
    // 対象のピースがマッチしているかの判定を行う
    private bool IsMatchBlock(Block block)
    {
        if (block == null)
        {
            return(false);
        }

        // ピースの情報を取得
        Vector2   pos  = GetBlockBoardPos(block);
        BlockKind kind = block.GetKind();

        if (block.checkFlag)
        {
            return(false);
        }

        CheckingBlockList.Clear();
        CheckingBlockList.Add(block);

        var MatchCount = GetSameKindBlockNum(kind, pos) + 1;

        bool deleteFlag = (MatchCount >= machingCount);

        foreach (Block checkingBlock in CheckingBlockList)
        {
            checkingBlock.SetDeleteFlag(deleteFlag);
        }

        return(deleteFlag);
    }
示例#4
0
    //--------------------------------------------------------------------------------------------------------
    private void CreateBlock(Hex location, BlockKind kind, int level, bool celebrate)
    {
        if (ForceWildCardNextTurn)
        {
            kind = BlockKind.WildCard;
            ShowWildcardTutorial(location);
            ForceWildCardNextTurn = false;
        }

        newBlock = Instantiate(
            original: BlockPrefab,
            position: location.transform.position,
            rotation: Quaternion.identity,
            parent: SushiAnchor.transform).GetComponent <Block>();

        newBlock.Initialize(location, level, kind);
        location.Occupant = newBlock;
        blocks.Add(newBlock);

        if (celebrate)
        {
            Instantiate(
                original: CreateCelebrationPrefab,
                position: newBlock.transform.position,
                rotation: Quaternion.identity,
                parent: SushiAnchor.transform);
        }
    }
示例#5
0
 public void turnToZombie()
 {
     gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("image/zombieBlock");
     gameObject.GetComponent<Animator>().runtimeAnimatorController = Resources.Load("animation/zombieAnimation/zombieAnimator") as RuntimeAnimatorController;
     kind = BlockKind.zombie;
     healthBar.transform.localScale = new Vector3(1,1,1);
 }
示例#6
0
 public ClassifiedSpan(SourceSpan span, SourceSpan blockSpan, SpanKind spanKind, BlockKind blockKind, AcceptedCharacters acceptedCharacters)
 {
     Span               = span;
     BlockSpan          = blockSpan;
     SpanKind           = spanKind;
     BlockKind          = blockKind;
     AcceptedCharacters = acceptedCharacters;
 }
 /*
  * The helper function below checks if the kind of the current block
  * matches the kind of the block requested. If it does, the current
  * block is returned; if not, a new block is started.
  */
 private BlockList CurrentBlock(BlockKind kind)
 {
     if (_blocks == null || _currentBlock.Kind != kind)
     {
         StartNewBlock(kind);
     }
     return(_currentBlock);
 }
示例#8
0
        public void PushBlock(BlockKind kind = BlockKind.Unknown, object obj = null)
        {
            var block = new Block {
                Kind = kind, Object = obj
            };

            block.Text.CurrentIndentation = CurrentIndentation;
            block.Text.IsStartOfLine      = ActiveBlock.Text.IsStartOfLine;
            block.Text.NeedsNewLine       = ActiveBlock.Text.NeedsNewLine;
            PushBlock(block);
        }
示例#9
0
 /*
  ### Creating a Block
  ###Blocks are constructed dynamically as the source file is parsed. When creating a new
  ###block only the kind of the block and the output format needs to be specified. Based
  ###on those the constructor initializes a new block and inserts a correct header to it.
  ###
  ###In markdown output whitespace is a bit more important than in HTML. That is why
  ###we sometimes need to add additional line breaks to the output.
  */
 public BlockList(BlockKind kind, OutputFormat format)
 {
     Kind     = kind;
     _builder = new StringBuilder();
     if (Kind == BlockKind.Code)
     {
         _builder.Append(format == OutputFormat.html ?
                         _htmlCodeHeader :
                         _mdCodeHeader + Environment.NewLine);
     }
 }
示例#10
0
 public CodeBlock(CodeLine line, string method, CodeStatementCollection statements, BlockKind kind, CodeBlock parent, string endLabel, string exitLabel)
 {
     this.line = line;
     this.method = method;
     this.statements = statements;
     Type = BlockType.Expect;
     this.kind = kind;
     this.parent = parent;
     level = int.MaxValue;
     this.endLabel = endLabel;
     this.exitLabel = exitLabel;
 }
示例#11
0
        public bool HasSolidNeighbour(int x, int y, int z)
        {
            Block[,,] blocks;

            if (x < 0 || x >= World.chunkSize ||
                y < 0 || y >= World.chunkSize ||
                z < 0 || z >= World.chunkSize)
            {
                //block in a neighbouring chunkGameObject
                //Vector3 neighbourChunkPos = this.Chunk.Position +
                //                            new Position((x - (int)this.Position.X) * World.chunkSize,
                //                                (y - (int)this.Position.Y) * World.chunkSize,
                //                                (z - (int)this.Position.Z) * World.chunkSize);
                Position pos = new Position(x, y, z);

                ////block in a neighbouring chunkGameObject
                Position neighbourChunkPos = this.Chunk.Position + ((pos - this.Position) * World.chunkSize);

                x = World.ConvertBlockIndexToLocal(x);
                y = World.ConvertBlockIndexToLocal(y);
                z = World.ConvertBlockIndexToLocal(z);

                if (StaticWorld.Instance.Chunks.TryGetValue(neighbourChunkPos, out Chunk nChunk))
                {
                    blocks = nChunk.ChunkData.chunkData;
                }
                else
                {
                    return(false);
                }
            } //block in this chunkGameObject
            else
            {
                blocks = this.Chunk.ChunkData.chunkData;
            }

            try
            {
                BlockKind neighbourKind = blocks[x, y, z].Kind;

                return(neighbourKind == BlockKind.Solid ||

                       (this.Kind == BlockKind.Transparent && neighbourKind == BlockKind.Transparent) ||
                       (this.Kind == BlockKind.Glowing && neighbourKind == BlockKind.Glowing)
                       );
            }
            catch (IndexOutOfRangeException)
            {
                Debug.LogWarning("sOME OUT OF RANGE IN block");
            }

            return(false);
        }
示例#12
0
 public CodeBlock(CodeLine line, string method, CodeStatementCollection statements, BlockKind kind, CodeBlock parent, string endLabel, string exitLabel)
 {
     this.line       = line;
     this.method     = method;
     this.statements = statements;
     Type            = BlockType.Expect;
     this.kind       = kind;
     this.parent     = parent;
     level           = int.MaxValue;
     this.endLabel   = endLabel;
     this.exitLabel  = exitLabel;
 }
示例#13
0
 /*
  * The helper function below checks if the kind of the current block
  * matches the kind of the block requested. If it does, the current
  * block is returned; if not, a new block is started.
  *
  * A new block is opened also in case the `_startNewBlock` flag is set.
  * When this occurs, the flag is reset back to false and a reference
  * to the opened block is stored in the `_newBlock` field.
  */
 private BlockList CurrentBlock(BlockKind kind)
 {
     if (_blocks == null || _currentBlock.Kind != kind || _startNewBlock)
     {
         StartNewBlock(kind);
     }
     if (_startNewBlock)
     {
         _startNewBlock = false;
         _newBlock      = _currentBlock;
     }
     return(_currentBlock);
 }
示例#14
0
        /*
         * Alternatively we can build a block incrementally by first creating it
         * and adding text later. Starting a new block closes the previous one
         * automatically, if such exists.
         */
        private void StartNewBlock(BlockKind kind)
        {
            var result = new BlockList(kind, _options.Format);

            if (_blocks == null)
            {
                _blocks = result;
            }
            else
            {
                _currentBlock.Next = result;
                _currentBlock.Close(_options.Format);
            }
            _currentBlock = result;
        }
示例#15
0
 //--------------------------------------------------------------------------------------------------------
 public void Initialize(Hex dropHex, int startLevel, BlockKind blockKind)
 {
     Level          = startLevel;
     swipeDestHex   = null;
     swipeDestPos   = null;
     swipeDestNeko  = null;
     Kind           = blockKind;
     BlocksToEat    = new List <Block>();
     gameController = GameObject.Find("Game Controller").GetComponent <GameController>();
     uiCanvas       = GameObject.Find("UI Canvas");
     name           = "Block on " + dropHex.name + ", Level " + Level + " (" + Kind + ")";
     UpdateDisplayImage();
     RandomizeSpeed();
     isInitialized = true;
 }
示例#16
0
文件: Board.cs 项目: phansorg/DDChain
    private void SetKind(Block block)
    {
        // 生成するピースの種類をランダムに決める
        BlockKind kind = (BlockKind)(UnityEngine.Random.Range(0, PuzzleDataV1.COLOR_MAX) % color);

        block.SetKind(kind);

        // お邪魔情報をセット
        if (garbage != 0 && UnityEngine.Random.Range(0, 100) < GarbagePercent)
        {
            block.SetGarbageKind((GarbageKind)garbage);
        }
        else
        {
            block.SetGarbageKind(GarbageKind.None);
        }
    }
示例#17
0
 public Block(ID ID = default, src.XPos Pos = default, BlockKind Kind = default, BranchPrediction Likely = default, bool FlagsLiveAtEnd = default, slice <Edge> Succs = default, slice <Edge> Preds = default, array <ptr <Value> > Controls = default, long AuxInt = default, slice <ptr <Value> > Values = default, ref ptr <Func> Func = default, array <Edge> succstorage = default, array <Edge> predstorage = default, array <ptr <Value> > valstorage = default)
 {
     this.ID             = ID;
     this.Pos            = Pos;
     this.Kind           = Kind;
     this.Likely         = Likely;
     this.FlagsLiveAtEnd = FlagsLiveAtEnd;
     this.Succs          = Succs;
     this.Preds          = Preds;
     this.Controls       = Controls;
     this.AuxInt         = AuxInt;
     this.Values         = Values;
     this.Func           = Func;
     this.succstorage    = succstorage;
     this.predstorage    = predstorage;
     this.valstorage     = valstorage;
 }
示例#18
0
文件: Board.cs 项目: phansorg/DDChain
    // 対象の方向に引数で指定したの種類のピースがいくつあるかを返す
    private int GetSameKindBlockNum(BlockKind kind, Vector2 blockPos)
    {
        if (ExistBlock(blockPos) == false)
        {
            return(0);
        }

        Block block = board[(int)blockPos.x, (int)blockPos.y];

        if (block.checkFlag)
        {
            return(0);
        }

        block.checkFlag = true;

        if (block.IsLink() == false)
        {
            return(0);
        }

        var count = 0;

        Action <Vector2> ProcNextPos = (nextPos) =>
        {
            if (ExistBlock(nextPos))
            {
                Block     nextBlock = board[(int)nextPos.x, (int)nextPos.y];
                BlockKind nextKind  = nextBlock.GetKind();
                if (nextBlock.IsLink() == true && nextKind == kind && nextBlock.checkFlag == false)
                {
                    CheckingBlockList.Add(nextBlock);
                    count++;
                    count += GetSameKindBlockNum(nextKind, nextPos);
                }
            }
        };

        ProcNextPos(blockPos + Vector2.up);
        ProcNextPos(blockPos + Vector2.right);
        ProcNextPos(blockPos + Vector2.down);
        ProcNextPos(blockPos + Vector2.left);

        return(count);
    }
示例#19
0
 private void DrawBlock(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         IterateBlocks((x, y) =>
         {
             Rectangle blockRectangle = CalculateBlockRectangle(x, y);
             if (blockRectangle.Contains(e.Location))
             {
                 BlockKind oldKind = _puzzleBlocks[x, y];
                 if (oldKind != EditBlockKind)
                 {
                     _puzzleBlocks[x, y] = EditBlockKind;
                     Invalidate();
                 }
             }
         });
     }
 }
示例#20
0
文件: Board.cs 项目: phansorg/DDChain
    private void SetLinkDirection(Block block)
    {
        if (block == null)
        {
            return;
        }

        // Tween中はLinkしない
        if (block.IsLink() == false)
        {
            block.SetLinkDirection((int)LinkDirection.None);
            return;
        }

        // ピースの情報を取得
        Vector2   blockPos      = GetBlockBoardPos(block);
        BlockKind kind          = block.GetKind();
        int       linkDirection = (int)LinkDirection.None;

        Action <Vector2, int> AddLinkDirection = (nextPos, add) =>
        {
            if (ExistBlock(nextPos))
            {
                Block nextBlock = board[(int)nextPos.x, (int)nextPos.y];
                if (nextBlock.IsLink() && nextBlock.GetKind() == kind)
                {
                    linkDirection += add;
                }
            }
        };

        AddLinkDirection(blockPos + Vector2.up, (int)LinkDirection.Up);
        AddLinkDirection(blockPos + Vector2.right, (int)LinkDirection.Right);
        AddLinkDirection(blockPos + Vector2.down, (int)LinkDirection.Down);
        AddLinkDirection(blockPos + Vector2.left, (int)LinkDirection.Left);

        block.SetLinkDirection(linkDirection);
    }
示例#21
0
 private SnapshotSpan GetBlockSpan(BlockKind blockKind, SnapshotPoint point)
 {
     var option = _motionUtil.GetBlock(blockKind, point);
     Assert.True(option.IsSome());
     var tuple = option.Value;
     return new SnapshotSpan(tuple.Item1, tuple.Item2.Add(1));
 }
示例#22
0
 /*
  ### Creating a Block
  ###Blocks are constructed dynamically as the source file is parsed. When creating a new
  ###block only the kind of the block and the output format needs to be specified. Based
  ###on those the constructor initializes a new block and inserts a correct header to it.
  ###
  ###In markdown output whitespace is a bit more important than in HTML. That is why
  ###we sometimes need to add additional line breaks to the output.
  */
 public BlockList(BlockKind kind, OutputFormat format)
 {
     Kind     = kind;
     _builder = new StringBuilder();
 }
示例#23
0
    public void initBlock(BlockKind blockKind)
    {
        switch (blockKind)
        {
        //META
        case BlockKind.STARTHERE:
            keyword        = new GolLangKeyword(GKeyword.STARTHERE);
            this.blockKind = blockKind;
            break;

        //Control
        case BlockKind.FOR:
            keyword        = new GolLangKeyword(GKeyword.FOR);
            this.blockKind = blockKind;
            break;

        case BlockKind.IF:
            keyword        = new GolLangKeyword(GKeyword.IF);
            this.blockKind = blockKind;
            break;

        case BlockKind.ELIF:
            keyword        = new GolLangKeyword(GKeyword.ELIF);
            this.blockKind = blockKind;
            break;

        case BlockKind.ELSE:
            keyword        = new GolLangKeyword(GKeyword.ELSE);
            this.blockKind = blockKind;
            break;

        //Int and Bool Compare
        case BlockKind.EQ:
            keyword        = new GolLangKeyword(GKeyword.EQ);
            this.blockKind = blockKind;
            break;

        case BlockKind.NEQ:
            keyword        = new GolLangKeyword(GKeyword.NEQ);
            this.blockKind = blockKind;
            break;

        //Int only Compare
        case BlockKind.GT:
            keyword        = new GolLangKeyword(GKeyword.GT);
            this.blockKind = blockKind;
            break;

        case BlockKind.LT:
            keyword        = new GolLangKeyword(GKeyword.LT);
            this.blockKind = blockKind;
            break;

        case BlockKind.GE:
            keyword        = new GolLangKeyword(GKeyword.GE);
            this.blockKind = blockKind;
            break;

        case BlockKind.LE:
            keyword        = new GolLangKeyword(GKeyword.LE);
            this.blockKind = blockKind;
            break;

        //Calculate
        case BlockKind.PLUS:
            keyword        = new GolLangKeyword(GKeyword.PLUS);
            this.blockKind = blockKind;
            break;

        case BlockKind.MINUS:
            keyword        = new GolLangKeyword(GKeyword.MINUS);
            this.blockKind = blockKind;
            break;

        case BlockKind.MUL:
            keyword        = new GolLangKeyword(GKeyword.MUL);
            this.blockKind = blockKind;
            break;

        case BlockKind.DIV:
            keyword        = new GolLangKeyword(GKeyword.DIV);
            this.blockKind = blockKind;
            break;

        case BlockKind.MOD:
            keyword        = new GolLangKeyword(GKeyword.MOD);
            this.blockKind = blockKind;
            break;

        //Negative Num
        case BlockKind.NEG:
            keyword        = new GolLangKeyword(GKeyword.NEG);
            this.blockKind = blockKind;
            break;

        //Logical
        case BlockKind.AND:
            keyword        = new GolLangKeyword(GKeyword.AND);
            this.blockKind = blockKind;
            break;

        case BlockKind.OR:
            keyword        = new GolLangKeyword(GKeyword.OR);
            this.blockKind = blockKind;
            break;

        case BlockKind.NOT:
            keyword        = new GolLangKeyword(GKeyword.NOT);
            this.blockKind = blockKind;
            break;

        //Bracket
        case BlockKind.BOP:
            keyword        = new GolLangKeyword(GKeyword.BOP);
            this.blockKind = blockKind;
            break;

        case BlockKind.BCL:
            keyword        = new GolLangKeyword(GKeyword.BCL);
            this.blockKind = blockKind;
            break;

        //Assignment
        case BlockKind.ASS:
            keyword        = new GolLangKeyword(GKeyword.ASS);
            this.blockKind = blockKind;
            break;

        //ETC
        case BlockKind.COMMA:
            keyword        = new GolLangKeyword(GKeyword.COMMA);
            this.blockKind = blockKind;
            break;

        //Const Int
        case BlockKind.CONSTI_0:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "0");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_1:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "1");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_2:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "2");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_3:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "3");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_4:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "4");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_5:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "5");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_6:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "6");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_7:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "7");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_8:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "8");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTI_9:
            keyword        = new GolLangKeyword(GKeyword.CONSTI, "9");
            this.blockKind = blockKind;
            break;

        //Const Bool
        case BlockKind.CONSTB_TRUE:
            keyword        = new GolLangKeyword(GKeyword.CONSTB, "1");
            this.blockKind = blockKind;
            break;

        case BlockKind.CONSTB_FALSE:
            keyword        = new GolLangKeyword(GKeyword.CONSTB, "0");
            this.blockKind = blockKind;
            break;

        //Int Variable
        case BlockKind.VARI_a:
            keyword        = new GolLangKeyword(GKeyword.VARI, "a");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARI_b:
            keyword        = new GolLangKeyword(GKeyword.VARI, "b");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARI_c:
            keyword        = new GolLangKeyword(GKeyword.VARI, "c");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARI_i:
            keyword        = new GolLangKeyword(GKeyword.VARI, "i");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARI_j:
            keyword        = new GolLangKeyword(GKeyword.VARI, "j");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARI_k:
            keyword        = new GolLangKeyword(GKeyword.VARI, "k");
            this.blockKind = blockKind;
            break;

        //Bool Variable
        case BlockKind.VARB_w:
            keyword        = new GolLangKeyword(GKeyword.VARB, "w");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARB_x:
            keyword        = new GolLangKeyword(GKeyword.VARB, "x");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARB_y:
            keyword        = new GolLangKeyword(GKeyword.VARB, "y");
            this.blockKind = blockKind;
            break;

        case BlockKind.VARB_z:
            keyword        = new GolLangKeyword(GKeyword.VARB, "z");
            this.blockKind = blockKind;
            break;

        //Function
        case BlockKind.FUNC_MELEEATTACK:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "MeleeAttack");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_RANGEATTACK:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "RangeAttack");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_OBSERVE:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "Observe");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_DEFENCE:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "Defence");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_ENERGYCHARGE:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "EnergyCharge");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_BREAKSHIELD:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "BreakShield");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_REPAIR:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "Repair");
            this.blockKind = blockKind;
            break;

        case BlockKind.FUNC_GOLEMENERGY:
            keyword        = new GolLangKeyword(GKeyword.FUNC, "GolemEnergy");
            this.blockKind = blockKind;
            break;
        }
    }
示例#24
0
 public void Remove()
 {
     Kind  = BlockKind.NULL;
     coord = new Coord(-1, -1);
     gameObject.SetActive(false);
 }
示例#25
0
 public void turnToNormal()
 {
     gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("image/humanBlock");
     gameObject.GetComponent<Animator>().runtimeAnimatorController = Resources.Load("animation/defaultAnimation/defaultAnimator") as RuntimeAnimatorController;
     kind = BlockKind.normal;
 }
示例#26
0
 public Block(BlockKind blockType, int from, int to)
 {
     Kind = blockType;
     From = from;
     To   = to;
 }
示例#27
0
    private List <Block> ExplodeTrigger(Coord[] coord)
    {
        //폭발 조건
        List <Block> explodelist = new List <Block>();

        int[] mxcount = new int[coord.Length], pxcount = new int[coord.Length];
        int[] mycount = new int[coord.Length], pycount = new int[coord.Length];

        for (int i = 0; i < coord.Length; i++)
        {
            if (batchedblocks[coord[i].x, coord[i].y] == null)
            {
                continue;
            }
            BlockKind kind = batchedblocks[coord[i].x, coord[i].y].Kind;

            int mx = coord[i].x - 1;
            while (mx >= 0 && mx < game.size.x)
            {
                if (batchedblocks[mx, coord[i].y] == null)
                {
                    break;
                }
                if (batchedblocks[mx, coord[i].y].Kind.Equals(kind) &&
                    !kind.Equals(BlockKind.WALL))
                {
                    mx--;
                    mxcount[i]++;
                }
                else
                {
                    break;
                }
            }

            int px = coord[i].x + 1;
            while (px >= 0 && px < game.size.x)
            {
                if (batchedblocks[px, coord[i].y] == null)
                {
                    break;
                }
                if (batchedblocks[px, coord[i].y].Kind.Equals(kind) &&
                    !kind.Equals(BlockKind.WALL))
                {
                    px++;
                    pxcount[i]++;
                }
                else
                {
                    break;
                }
            }

            int my = coord[i].y - 1;
            while (my >= 0 && my < game.size.y)
            {
                if (batchedblocks[coord[i].x, my] == null)
                {
                    break;
                }
                if (batchedblocks[coord[i].x, my].Kind.Equals(kind) &&
                    !kind.Equals(BlockKind.WALL))
                {
                    my--;
                    mycount[i]++;
                }
                else
                {
                    break;
                }
            }

            int py = coord[i].y + 1;
            while (py >= 0 && py < game.size.y)
            {
                if (batchedblocks[coord[i].x, py] == null)
                {
                    break;
                }
                if (batchedblocks[coord[i].x, py].Kind.Equals(kind) &&
                    !kind.Equals(BlockKind.WALL))
                {
                    py++;
                    pycount[i]++;
                }
                else
                {
                    break;
                }
            }
        }

        for (int i = 0; i < coord.Length; i++)
        {
            if (mxcount[i] + 1 + pxcount[i] >= 3)
            {
                ExplodeListAdd(coord[i], 0, 0, ref explodelist);
                for (int j = 1; j <= mxcount[i]; j++)
                {
                    ExplodeListAdd(coord[i], -j, 0, ref explodelist);
                }
                for (int j = 1; j <= pxcount[i]; j++)
                {
                    ExplodeListAdd(coord[i], j, 0, ref explodelist);
                }
            }
            if (mycount[i] + 1 + pycount[i] >= 3)
            {
                ExplodeListAdd(coord[i], 0, 0, ref explodelist);
                for (int j = 1; j <= mycount[i]; j++)
                {
                    ExplodeListAdd(coord[i], 0, -j, ref explodelist);
                }
                for (int j = 1; j <= pycount[i]; j++)
                {
                    ExplodeListAdd(coord[i], 0, j, ref explodelist);
                }
            }
        }

        if (explodelist.Count > 0)
        {
            return(explodelist);
        }
        else
        {
            return(null);
        }
    }
示例#28
0
 public Block FindBlock(BlockKind kind)
 {
     return(FindBlocks(kind).SingleOrDefault());
 }
示例#29
0
 public CodeBlock(CodeLine line, string method, CodeStatementCollection statements, BlockKind kind, CodeBlock parent)
     : this(line, method, statements, kind, parent, null, null)
 {
 }
示例#30
0
    public void OnValueChanged(int result)
    {
        Dropdown    objectDropdown = GameObject.Find("ObjectDropdown").GetComponent <Dropdown>();
        bool        writeBlock     = true;
        BlockKind   blockKind      = BlockKind.Red;
        GarbageKind garbageKind    = GarbageKind.None;

        switch (objectDropdown.value)
        {
        case 0:
            writeBlock = false;
            break;

        case 1:
            blockKind = BlockKind.Red;
            break;

        case 2:
            blockKind = BlockKind.Blue;
            break;

        case 3:
            blockKind = BlockKind.Green;
            break;

        case 4:
            blockKind = BlockKind.Yellow;
            break;

        case 5:
            blockKind = BlockKind.Purple;
            break;

        case 6:
            garbageKind = GarbageKind.Garbage;
            break;

        case 7:
            garbageKind = GarbageKind.Hard;
            break;

        case 8:
            blockKind   = BlockKind.Red;
            garbageKind = GarbageKind.Dark;
            break;

        case 9:
            blockKind   = BlockKind.Blue;
            garbageKind = GarbageKind.Dark;
            break;

        case 10:
            blockKind   = BlockKind.Green;
            garbageKind = GarbageKind.Dark;
            break;

        case 11:
            blockKind   = BlockKind.Yellow;
            garbageKind = GarbageKind.Dark;
            break;

        case 12:
            blockKind   = BlockKind.Purple;
            garbageKind = GarbageKind.Dark;
            break;
        }

        PuzzleController puzzleController = GameObject.Find("PuzzleController").GetComponent <PuzzleController>();

        puzzleController.writeBlock       = writeBlock;
        puzzleController.writeBlockKind   = blockKind;
        puzzleController.writeGarbageKind = garbageKind;
    }
示例#31
0
 public CodeBlock(CodeLine line, string method, CodeStatementCollection statements, BlockKind kind, CodeBlock parent)
     : this(line, method, statements, kind, parent, null, null)
 {
 }
示例#32
0
文件: Block.cs 项目: phansorg/DDChain
 //-------------------------------------------------------
 // Public Function
 //-------------------------------------------------------
 public void SetKind(BlockKind blockKind)
 {
     kind = blockKind;
     SetImage();
 }
		public XmlElement NewBlock(BlockKind kind)
		{
			string tag = null;
			switch (kind) {
			case BlockKind.Paragraph:
				tag = "p";
				break;
			case BlockKind.Quotation:
				tag = "blockquote";
				break;
			case BlockKind.Footnote:
				tag = "note";
				break;
			case BlockKind.Separator:
				tag = "hr";
				break;
			case BlockKind.Literal:
			case BlockKind.Verse:
				tag = "pre";
				break;
			case BlockKind.ListItem:
				tag = "li";
				break;
			case BlockKind.EnumeratedList:
				tag = "ol";
				break;
			case BlockKind.ItemizedList:
				tag = "ul";
				break;
			case BlockKind.DefinitionList:
				tag = "dl";
				break;
			case BlockKind.DefinitionTag:
				tag = "dt";
				break;
			case BlockKind.DefinitionItem:
				tag = "dd";
				break;
			case BlockKind.Section:
				tag = "sect";
				break;
			default:
				return null;
			}
			
			return CreateElement(tag);
		}
示例#34
0
 public void BlockSet(BlockKind _kind, Coord _coord)
 {
     Kind  = _kind;
     coord = _coord;
     transform.position = new Vector2(coord.x, coord.y);
 }
示例#35
0
文件: Block.cs 项目: zarumaru/ILSpy
 public Block(BlockKind kind = BlockKind.ControlFlow) : base(OpCode.Block)
 {
     this.Kind             = kind;
     this.Instructions     = new InstructionCollection <ILInstruction>(this, 0);
     this.FinalInstruction = new Nop();
 }
示例#36
0
 public void turnToKind(BlockKind kind)
 {
 }
示例#37
0
 public IEnumerable <Block> FindBlocks(BlockKind kind)
 {
     return(RootBlock.FindBlocks(kind));
 }
示例#38
0
        public pStatus Parse(string line, int linenumber)
        {
            bool finishInternal = false;
            bool doEsle = false;

            if (nested != null)
            {
                pStatus stat= nested.Parse(line, linenumber);
                if (stat==pStatus.Working || stat == pStatus.SyntaxError)
                {
                    return stat;
                }
                else if (stat == pStatus.Finished)
                {
                    finishInternal = true;

                }
            }
            else
            {
                //short f=0;
            }

            int part = indent.doIndentation(line);
            if (part < 0)
            {
                return pStatus.Finished;
            }

            string shortString = line.Trim(StringUtil.whitespace);

            if (finishInternal)
            {
                CodeBlock b = nested.getBlock();
                doEsle = elseMatcher.match(shortString);
                if (doEsle)
                {
                    shortString = elseMatcher.getArgs()["condition"];
                    if (shortString.StartsWith(" "))
                    {
                        shortString = shortString.Substring(1);
                    }
                }

                if (lastBlockKind == BlockKind.Condition)
                {
                    if (doEsle)
                    {
                        b.add(new Opcode(opcodeType.jump, new ArgumentValue(addressMode.constint, substitutionType.EndIf, ClassDatabase.integer)));
                    }
                }
                else
                {
                    b.add(new Opcode(opcodeType.jump, new ArgumentValue(addressMode.constint, substitutionType.BlockStart, ClassDatabase.integer)));
                }
                internalBlock.add(b);
                nested = null;

                if (!doEsle)
                {
                    block.add(internalBlock);
                    internalBlock = null;
                }
                else
                {

                }

            }

            if (parseParts.Count > 0)
            {
                parseParts.Clear();
            }

            if (localVariableMathcer.match(shortString))
            {
                Dictionary<string, string> args = localVariableMathcer.getArgs();
                if (locals.ContainsKey(args["name"]))
                {
                    ArgumentValue argva = EvalExpression(args["expression"]);
                    LocalVariable lvar = locals[args["name"]];
                    if (lvar.kind.isParent(argva.getKind()))
                    {
                        block.add(Phrase.assign.toSubstituedPhrase(new[] { argva, new ArgumentValue(addressMode.frameint, getFramePos(lvar.index)) },
                            null));
                    }

                    indent.expect(false, true, true);
                }
                else
                {
                    ArgumentValue k = EvalExpression(args["expression"]);
                    block.add(Phrase.assign.toSubstituedPhrase(new[] { k,
                    new ArgumentValue(addressMode.frameint, getFramePos(locals.Count)),
                    }, null));
                    locals.Add(args["name"], new LocalVariable(locals.Count, k.getKind()));

                    indent.expect(false, true, true);
                }
            }
            else if (ifMatcher.match(shortString))
            {

                lastBlockKind = BlockKind.Condition;
                setUpCondition(ifMatcher.getArgs()["condition"]);
            }
            else if (whileMatcher.match(shortString))
            {
                lastBlockKind = BlockKind.Loop;
                setUpCondition(whileMatcher.getArgs()["condition"]);
            }
            else if (doEsle && shortString == ":")
            {
                setUpCondition();
            }
            else if (doEsle)
            {
                throw new Errors.SyntaxError("else without a valid condition");
            }
            else
            {

                EvalExpression(shortString, false);
                indent.expect(false, true, true);
            }
            return pStatus.Working;
        }