Exemplo n.º 1
0
    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
    }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
    } // 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));
    }
Exemplo n.º 4
0
    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--;
        }
    }
Exemplo n.º 5
0
 public PositionedThing(Thing thing, PosFace posFace)
 {
     this.Thing   = thing;
     this.PosFace = posFace;
 }
Exemplo n.º 6
0
 Transform Instantiate(Transform transform, PosFace posFace)
 {
     return(Instantiate(transform, GameConvert.Vector3From(posFace), GameConvert.QuaternionFrom(posFace.Facing)));
 }
Exemplo n.º 7
0
 public PosFace(PosFace posFace) : base(posFace)
 {
     this.Facing = posFace.Facing;
 }