C#프로그래밍

저글링 vs 마린

다모아 2023. 7. 21. 18:14

1.App 클래스 [이동 미완]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static LearnDotnet.Weapon;

namespace LearnDotnet
{
    internal class App
    {
        //데이터

        //생성자
        public App()
        {
            Marine marine = new Marine();
            Zergling zergling = new Zergling();
            marine.Attack(zergling);
            zergling.Move();
            zergling.Burrow();
            zergling.UnBurrow();
            zergling.Move();
            zergling.Attack(marine);
            marine.Move();
            marine.StimPacks();
        }
        //기능
    }
}

 

1. Marine 클래스 [이동 미완]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LearnDotnet
{
    internal class Marine
    {
        //멤버 변수 [데이터]
        public string name = "마린";
        public int hp;
        public int maxHp = 40;
        public int damage = 6;
        int armor = 0;
        public int x, y;
        int attackSpeed;
        //생성자 메서드
        public Marine()
        {
            Console.WriteLine("{0}이 생성되었습니다.", name);
            this.hp = maxHp;
        }
        //멤버 메서드 [기능]
        public void Move()
        {
            Console.WriteLine("\n이동가능위치 : 왼쪽 위 오른쪽 아래");
            Console.Write("{0}이 이동할 위치를 입력해주세요 : ", name);
        POS:
            string move = Console.ReadLine();
            if (move == "왼쪽")
            {
                this.x -= 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if (move == "오른쪽")
            {
                this.x += 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if (move == "위")
            {
                this.y += 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if (move == "아래")
            {
                this.y -= 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else
            {
                Console.Write("잘못입력했습니다. 재입력해주세요 :");
                goto POS;
            }
        }
        public void StimPacks()
        {
            this.attackSpeed += 2;
            Console.WriteLine("{0}이 스팀팩을 사용했습니다. 공격속도 증가: (+{1})", name, attackSpeed);
        }
        public void Attack(Zergling zergling)
        {
            Console.WriteLine("{0}이 {1}을 공격(-{2})했습니다.", name, zergling.name, damage);
            zergling.hp -= damage;
            Console.WriteLine("{0} 남은체력 : {1}/{2}", zergling.name, zergling.hp, zergling.maxHp);
        }
    }
}

 

1. Zergling 클래스 [이동 미완]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LearnDotnet
{
    internal class Zergling
    {
        //멤버 변수[데이터]
        public string name = "저글링";
        public int hp;
        public int maxHp = 35;
        public int damage = 5;
        int x, y;

        int armor = 0;
        //생성자 메서드
        public Zergling()
        {
            Console.WriteLine("{0}이 생성되었습니다.", name);
            this.hp = maxHp;
        }
        //멤버 메서드[기능]
        public void Move()
        {
            Console.WriteLine("\n이동가능위치 : 왼쪽 위 오른쪽 아래");
            Console.Write("{0}이 이동할 위치를 입력해주세요 : ", name);
            POS:
            string move = Console.ReadLine();
            if (move == "왼쪽")
            {
                this.x -= 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if (move == "오른쪽")
            {
                this.x += 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if(move == "위")
            {
                this.y += 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else if(move == "아래")
            {
                this.y -= 1;
                Console.WriteLine("({0},{1})위치로 이동했습니다.", x, y);
            }
            else
            {
                Console.Write("잘못입력했습니다. 재입력해주세요 :");
                goto POS;
            }
        }
        public void Burrow()
        {
            Console.WriteLine("{0}이 땅 속으로 들어갔습니다. 피재생(+2)", name);
            this.hp += 2;
            Console.WriteLine("{0} 남은체력 : {1}/{2}", name, hp, maxHp);
        }
        public void UnBurrow()
        {
            Console.WriteLine("\n{0}이 땅 속에서 올라왔습니다.", name);
        }
        public void Attack(Marine marine)
        {
                Console.WriteLine("{0}이 {1}을 공격(-{2})했습니다.", name, marine.name, damage);
                marine.hp -= 5;
                Console.WriteLine("{0}이 남은체력 : {1}/{2}", marine.name, marine.hp, marine.maxHp);
        }
    }
}

저글링
체력 : 35/35
공격력 : 5
방어력 : 0
사정거리 : 1

마린
체력 : 40/40
공격력 : 6
방어력 : 0
사정거리 : 3

마린이 생성되었습니다.
저글링이 생성되었습니다.
마린이 저글링을 공격했습니다.
저글링 남은체력 : 29/35

저글링이 마린을 공격했습니다.
마린 남은 체력 : 35/40

마린이 스팀팩을 사용했습니다.

 

-------------------------------------------------

 

TerranMarine
----------------
name
hp
maxHp
damage
armor
----------------
Move
StimPacks
Attack


Zergling
-----------------
name
hp
maxHp
damage
armor
-----------------
Move [x,y로 얼마 이동했습니다.]
Burrow
Attack