mynote6590 2024. 12. 18. 15:47
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Buff
    {
        public string _buffName;
        public int _buffTime;

        public Buff(string buffName, int buffTime)
        {
            _buffName = buffName;
            _buffTime = buffTime;
        }

    }

    class BuffManager
    {
        LinkedList<Buff> _buffs = new LinkedList<Buff>();

        public void AddBuff(Buff buff)
        {
            _buffs.AddLast(buff);
        }
        public void UpdateBuffs()
        {
            LinkedList<Buff> copy = new LinkedList<Buff>(_buffs);


            foreach (var buff in copy)
            {
                if (buff._buffTime > 0)
                {
                    buff._buffTime -= 1;
                } 
                else
                {
                    _buffs.Remove(buff);
                }


            }


        }
        public void ShowActiveBuffs()
        {
            foreach (var buff in _buffs)
            {
                Console.WriteLine("버프 이름 : " + buff._buffName);
                Console.WriteLine("버프 쿨타임 : " + buff._buffTime);
            }

        }

    }
    internal class Apqp
    {
        static void Main(string[] args)
        {
            BuffManager buffManager = new BuffManager();


            while (true)
            {
                Console.SetCursorPosition(0, 0);
                Console.WriteLine("_____________________\n");
                Console.WriteLine("1. 버프추가");
                Console.WriteLine("2. 버프 쿨타임 -1");
                Console.WriteLine("3. 버프목록\n");
                Console.WriteLine("_____________________");
                ConsoleKeyInfo key = Console.ReadKey();


                if (key.Key == ConsoleKey.D1)
                {
                    Console.Write("버프 이름 : ");
                    string name = Console.ReadLine();
                    Console.Write("버프 쿨타임 : ");
                    int time = int.Parse(Console.ReadLine());
                    Buff buff = new Buff(name, time);
                    buffManager.AddBuff(buff);
                    Console.Clear();

                }
                else if (key.Key == ConsoleKey.D2)
                {
                    buffManager.UpdateBuffs();
                    Console.WriteLine("버프 -1\n");
                }
                else if (key.Key == ConsoleKey.D3)
                {
                    Console.WriteLine(" 버프 목록 \n ");
                    buffManager.ShowActiveBuffs();
                }



            }



        }
    }
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq;
using System.Xml.Serialization;


namespace List
{
    class Teran
    {
        public string _name;
        protected int _hp;
        protected bool attackPossable;
    }

    class Marin : Teran
    {
        public Marin()
        {
            _name = "마린";
            _hp = 100;
            attackPossable = true;
        }

        public void SteamPack()
        {
            _hp -= 10;
            Console.WriteLine("공속,데미지 일시 상승");
        }
    }

    class Medic : Teran
    {
        public Medic()
        {
            _name = "메딕";
            _hp = 80;
            attackPossable = false;
        }

        public void ObticalPlaer()
        {
            Console.WriteLine("옵티컬 플레어 사용");
        }
    }

    class Beruck
    {
        Queue<Teran> _beruck;

        public Beruck()
        {
            _beruck = new Queue<Teran>();
        }

        public void EnqueueUnit(Teran unit)
        {
            _beruck.Enqueue(unit);

        }

        public void DequeueUnit()
        {
            Teran teran = new Teran();
            teran = _beruck.Dequeue();

            Console.WriteLine(teran._name + "생성");
        }
        public void ShowQueueLine()
        {
            //Teran teran = new Teran();
            foreach (var item in _beruck)
            {
                Console.WriteLine(item._name);
            }

        }

    }


    internal class Program
    {
        static void Main(string[] args)
        {
            Beruck beruck = new Beruck();
            Marin marin = new Marin();
            Medic medic = new Medic();


            beruck.EnqueueUnit(marin);
            beruck.EnqueueUnit(marin);
            beruck.EnqueueUnit(medic);
            beruck.EnqueueUnit(marin);
            beruck.EnqueueUnit(medic);

            beruck.DequeueUnit();
            beruck.ShowQueueLine();
        }
    }


}

 

 

using ConsoleApp2;
using System;
using System.Collections.Generic;
using System.Xml.Linq;

namespace ConsoleApp2
{
    class Player
    {
        List<Item> items;
        int _money;

        public Player()
        {
            items = new List<Item>();
            _money = 10000;
        }

        public void PrintInventory()
        {

        }
    }



    class Item
    {
        Dictionary<string, int> _items;

        public Item()
        {
            _items = new Dictionary<string, int>();
            _items.Add("무기", 500);
            _items.Add("방어구", 300);
            _items.Add("악세사리", 200);
        }

        public void PrintStore()
        {
            int count = 1;
            Console.WriteLine("상점 아이템 목록");
            foreach (var item in _items)
            {
                Console.WriteLine($"[{count}]" + item.Key + " - " + item.Value + "원");
                count++;
            }

            Console.WriteLine();
        }
    }

    class Weapon : Item
    {

    }


    class Armor : Item
    {

    }







    internal class Program
    {
        static void Main(string[] args)
        {
            Item item = new Item();

            ConsoleKeyInfo inputKey;
            while (true)
            {
                Console.WriteLine("[ 상점 구현 프로그램 ] \n");
                Console.WriteLine("해당하는 숫자의 키를 누르시오 \n");
                Console.WriteLine("1. 장비창 2. 인벤토리 3.상점  4.종료 \n");

                inputKey = Console.ReadKey(true);

                switch (inputKey.Key)
                {
                    // 무기 선택
                    case ConsoleKey.D1:

                        break;

                    // 인벤토리 선택
                    case ConsoleKey.D2:

                        break;

                    // 상점 선택
                    case ConsoleKey.D3:
                        item.PrintStore();

                        break;

                    // 종료
                    case ConsoleKey.D4:
                        break;
                }



            }

        }


    }
}