コード例 #1
0
ファイル: Building.cs プロジェクト: rodya-mirov/Cow-Mouse
        /// <summary>
        /// Sets the specified square to being used by the specified person.  Requires marking first.
        /// </summary>
        /// <param name="worldX"></param>
        /// <param name="worldY"></param>
        /// <param name="user"></param>
        /// <param name="marker"></param>
        public void UseByPerson(int worldX, int worldY, Person user, FullTask marker)
        {
            if (!IsSquareMarkedByAndFor(worldX, worldY, marker, BuildingInteractionType.USE))
                throw new InvalidOperationException("Can't use what you didn't mark!");

            int localX = worldX - XMin;
            int localY = worldY - YMin;

            SetSquareState(worldX, worldY, BuildingInteractionType.USE, BuildingAvailabilityType.IN_USE);
            users[localX, localY] = user;
        }
コード例 #2
0
ファイル: Building.cs プロジェクト: rodya-mirov/Cow-Mouse
        /// <summary>
        /// Stops using the specified square.  Obvious preconditions.
        /// </summary>
        /// <param name="worldX"></param>
        /// <param name="worldY"></param>
        /// <param name="user"></param>
        public void StopUsingSquare(int worldX, int worldY, Person user)
        {
            if (!this.ContainsSquare(worldX, worldY))
                throw new InvalidOperationException("Square out of bounds!");

            int localX = worldX - XMin;
            int localY = worldY - YMin;

            BuildingAvailabilityType currentBat = squareAvailabilityModes[localX, localY];
            BuildingInteractionType currentBit = squareActionModes[localX, localY];

            if (currentBat != BuildingAvailabilityType.IN_USE || currentBit != BuildingInteractionType.USE || users[localX, localY] != user)
                throw new InvalidOperationException("Square was not being used by the specified user!");

            users[localX, localY] = null;
            SetSquareState(worldX, worldY, BuildingInteractionType.USE, BuildingAvailabilityType.AVAILABLE);
        }