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 }
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); } }
} // 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)); }
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--; } }
public PositionedThing(Thing thing, PosFace posFace) { this.Thing = thing; this.PosFace = posFace; }
Transform Instantiate(Transform transform, PosFace posFace) { return(Instantiate(transform, GameConvert.Vector3From(posFace), GameConvert.QuaternionFrom(posFace.Facing))); }
public PosFace(PosFace posFace) : base(posFace) { this.Facing = posFace.Facing; }