Beispiel #1
0
        //private void ClearLines(int numLines)
        //{
        //    Console.SetCursorPosition(0, Console.CursorTop);
        //    Console.Write(new string(' ', Console.BufferWidth));

        //    for (int i = 0; i < numLines; i++)
        //    {
        //        Console.SetCursorPosition(0, Console.CursorTop - 2);
        //        Console.Write(new string(' ', Console.BufferWidth));
        //    }

        //    Console.SetCursorPosition(0, Console.CursorTop - 1);
        //}
        #endregion

        #region Event Handlers
        /// <summary>
        /// Handles the <see cref="Player.ItemGained"/> event
        /// </summary>
        /// <param name="sender">The object that invoked the event</param>
        /// <param name="e">The arguments sent with the event</param>
        private void OnItemGained(object sender, ItemGainedEventArgs e)
        {
            string message = e.FirstItem ? "Found " : "Also found ";

            message += e.Item.Stackable ? e.Item.Count.ToString() : Utils.AnOrA(e.Item.Name, false);
            message += " " + e.Item.Name;
            message += e.ItemKept ? '!' : '.';
            DisplayMessage(message);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the item to the player's list of items if it is: 1) new; 2) better than the current item of that type; or 3) stackable.
        /// Adds the value of the item that was not kept to <see cref="JunkValue"/>.
        /// Invokes the <see cref="ItemGained"/> event.
        /// </summary>
        /// <param name="newItem">The item to give the player</param>
        /// <param name="compareFunc">The function for comparing the new item to the existing one</param>
        /// <param name="firstItem">Whether this is the first item in a group that the player is receiving</param>
        private void AddOrReplaceItem(Item newItem, bool firstItem = true)
        {
            Item junkedItem = Items.AddOrReplace(newItem);

            if (junkedItem != null)
            {
                JunkValue += junkedItem.Value;
            }

            ItemGainedEventArgs eventArgs = new ItemGainedEventArgs()
            {
                Item      = newItem,
                ItemKept  = junkedItem != newItem,
                FirstItem = firstItem
            };

            UpdateStats();

            ItemGained?.Invoke(this, eventArgs);
        }