コード例 #1
0
ファイル: Board.cs プロジェクト: kslesinsky/PushABlock
    public bool AddThingToBoard(Thing thing, PosFace posFace)
    {
        if (thing == null)
        {
            return(false);
        }
        //check if thing.IdOnBoard >= 0 ?

        var square = SquareAt(posFace);

        if (square == null)
        {
            return(false);
        }

        if (square.ThingOnMe == null)
        {
            int id = NewEmptyThing();
            thing.IdOnBoard       = id;
            theThings[id].Thing   = thing;
            theThings[id].PosFace = posFace;
            square.ThingOnMe      = thing;
            return(true);
        }
        //else throw new NonCriticalException
        return(false); // didn't add
    }
コード例 #2
0
ファイル: GameVisuals.cs プロジェクト: kslesinsky/PushABlock
    public void UpdateThing(int thingId, PosFace newPosFace)
    {
        var transform = GetThingTransform(thingId);

        if (transform != null)
        {
            transform.position = GameConvert.Vector3From(newPosFace);
            transform.rotation = GameConvert.QuaternionFrom(newPosFace.Facing);
        }
    }
コード例 #3
0
ファイル: Board.cs プロジェクト: kslesinsky/PushABlock
    } // Take the return value, remember the Id, and assign Thing & PosFace to theThings[thingId]

    // returns true if successfully added
    public bool AddThingToBoard(SquareType squareType, PosFace posFace)
    {
        if (squareType == SquareType.Goal)
        {
            return(AddSquareDesignator(SquareDesignator.Goal, posFace));
        }

        Thing newThing = Thing.Create(squareType);

        return(AddThingToBoard(newThing, posFace));
    }
コード例 #4
0
ファイル: Board.cs プロジェクト: kslesinsky/PushABlock
    public static void LoadFromStringArrays(Board b, String[] squares, String[] facings)
    {
        if (squares == null || facings == null)
        {
            return;
        }

        int y = BoardCore.MAX_Y;

        for (int i = 0; i < squares.Length; i++) // loop through the rows in the text arrays, top to bottom
        {
            string squaresRow = squares[i];
            string facingsRow = facings[i];
            for (int j = 0; j < squaresRow.Length; j++)
            {
                //Convert chars to SquareType & Facing
                int squareTypeInt;
                if (!int.TryParse(squaresRow[j].ToString(), out squareTypeInt))
                {
                    continue;
                }
                SquareType squareType = (SquareType)squareTypeInt;
                if (squareType == SquareType.Default)
                {
                    continue;                        // nothing on that square
                }
                PosFace posFace = new PosFace(j, y); // facing==Undefined

                // (Checks length of facingsRow, in case it's shorter...)
                int facingInt;
                if (j < facingsRow.Length && int.TryParse(facingsRow[j].ToString(), out facingInt))
                {
                    posFace.Facing = (Facing)facingInt;
                }

                b.AddThingToBoard((SquareType)squareTypeInt, posFace);
            }
            y--;
        }
    }
コード例 #5
0
 public PositionedThing(Thing thing, PosFace posFace)
 {
     this.Thing   = thing;
     this.PosFace = posFace;
 }
コード例 #6
0
ファイル: GameVisuals.cs プロジェクト: kslesinsky/PushABlock
 Transform Instantiate(Transform transform, PosFace posFace)
 {
     return(Instantiate(transform, GameConvert.Vector3From(posFace), GameConvert.QuaternionFrom(posFace.Facing)));
 }
コード例 #7
0
 public PosFace(PosFace posFace) : base(posFace)
 {
     this.Facing = posFace.Facing;
 }