/// <summary> /// Initializes this <see cref="T:GuiMower"/>. /// </summary> /// <param name="guiGarden">The <see cref="T:GuiGarden/> where this <see cref="T:GuiMower"/> lives in.</param> public void Init(GuiGarden guiGarden) { this.GuiGarden = guiGarden; //set initial position this.MoveToPosition(Mower.Position); Mower.AddObserver(this); }
/// <summary> /// Initializes this <see cref="T:GuiMovingObstacle"/>. /// </summary> /// <param name="guiGarden">The surrounding <see cref="T:GuiGarden"/>.</param> /// <param name="movingObstacle">The <see cref="T:MovingObstacle/> that is represented by this object.</param> public void Init(GuiGarden guiGarden, MovingObstacle movingObstacle) { this.GuiGarden = guiGarden; this.MovingObstacle = movingObstacle; //set initial position this.MoveToPosition(MovingObstacle.Position); MovingObstacle.AddObserver(this); }
/// <summary> /// Moves this object to the given position on the 2D grid. /// </summary> /// <param name="gridPosition">Grid position.</param> private void MoveToPosition(Garden.GridPosition gridPosition) { this.transform.position = GuiGarden.GridPositionToUnityPosition(gridPosition); }