본문 바로가기
C#/수업과제

[C# 5일차] Class 응용 과제&Method 활용_BRAWLSTARS(+궁극기, 스킬)

by 왹져박사 2023. 1. 6.
728x90

*BRAWLSTARS*


[브롤러]
---------
[속성]
---------
[기능]

 

 

 

 

App Class

using System;

namespace BRAWLSTARS
{
    class APP
    {

        //생성자

        public APP()
        {
            Console.WriteLine("APP 생성자");

            Tick tick = new Tick("tick");       //Tick 생성
            Console.WriteLine(tick.damage);
            Console.WriteLine(tick.hp);
            Console.WriteLine(tick.speed);
            tick.Attack();
            Console.WriteLine();

            Chester chester = new Chester("chester");       //Chester 생성
            Console.WriteLine(chester.damage);
            Console.WriteLine(chester.hp);
            Console.WriteLine(chester.speed);
            chester.Move();
            chester.Attack();       //공격 횟수에 따라 공격 변화
            chester.Attack();
            chester.Attack();
            chester.Attack();
            Console.WriteLine();

            Emz emz = new Emz("emz");       //Emz 생성
            Console.WriteLine(emz.damage);
            Console.WriteLine(emz.hp);
            Console.WriteLine(emz.speed);
            emz.Move();
            Console.WriteLine();

            Poco poco = new Poco("poco");       //Poco 생성
            Console.WriteLine(poco.damage);
            Console.WriteLine(poco.heal);
            Console.WriteLine(poco.hp);
            Console.WriteLine(poco.speed);
            poco.Move();
            poco.Attack();
            Console.WriteLine();

            Sprout sprout = new Sprout("sprout");       //Sprout 생성
            Console.WriteLine(sprout.damage);
            Console.WriteLine(sprout.hp);
            Console.WriteLine(sprout.speed);
            sprout.Move();
            Console.WriteLine();
                
            Ash ash = new Ash("ash");       //Ash 생성
            Console.WriteLine(ash.damage);
            Console.WriteLine(ash.hp);
            Console.WriteLine(ash.speed);
            ash.Move();
            ash.Attack();
            Console.WriteLine();

            HeadFirst headFirst0 = tick.HeadFirst();        //Tick의 궁극기 HeadFirst를 생성하고, ash를 공격, poco가 ash를 회복시킴
            headFirst0.Attack(ash);
            ash.Hit(headFirst0.damage);
            poco.Heal(ash);
            Console.WriteLine();

            HeadFirst headFirst1 = tick.HeadFirst();        //Tick의 궁극기 HeadFirst를 생성하고, sptout가 headFirst1을 공격, 제거
            sprout.Attack(headFirst1);
            headFirst1.Hit(sprout.damage);
            sprout.Attack(headFirst1);
            headFirst1.Hit(sprout.damage);
            Console.WriteLine();

            emz.Attack(chester);        //emz가 chester를 공격, chester의 궁극기를 이용하여 본인 회복
            chester.StrongMint();
            Console.WriteLine();

            tick.Move(sprout.hedge);        //sprout의 울타리가 주변에 설치되었을 경우 이동 불가
            sprout.Hedge(tick);
            tick.Move(sprout.hedge);
            sprout.Hedge(tick);
            tick.Move(sprout.hedge);
            Console.WriteLine();

            tick.Die();
            chester.Die();
            emz.Die();
            poco.Die();
            sprout.Die();
            ash.Die();
            Console.WriteLine();

        }
    }
}

 

Tick Class


TICK[장거리딜러]
----------
[속성]
공격력 3*640
HP 2200
이동속도 2.4
----------
[기능]
공격하기
사망
이동하기 (Sprout의 울타리가 설치되었을 경우 이동불가)

궁극기(HeadFirst) 폭탄 생성

using System;

namespace BRAWLSTARS
{
    class Tick
    {
        public string name;
        public int damage;
        public int hp;
        public float speed;

        //생성자
        public Tick(string name)
        {
            Console.WriteLine("TICK 생성자");
            this.name = name;
            this.damage = 640;
            this.hp = 2200;
            this.speed = 2.4f;

        }

        public void Attack()
        {
            Console.WriteLine("{0}이 지뢰를 던졌습니다.", this.name);
        }

        public void Die()
        {
            Console.WriteLine("{0}이 죽었습니다.", this.name);
        }
        public void Move(int hedge)
        {
            if(hedge == true)
            {
                Console.WriteLine("{0} 이동 불가 상태", this.name);
            }
            else
            {
                Console.WriteLine("{0}이 이동하였습니다.", this.name);
            }
        }
        public HeadFirst HeadFirst()
        {
            return new HeadFirst();
        }
    }
}

 

HeadFirst Class ( Tick의 궁극기)

공격(Ash를 타겟으로)

피해받음(hp가 0 이하일 경우 Die호출)

죽다

using System;

namespace BRAWLSTARS
{
    class HeadFirst
    {
        public string name = "tickHead";
        public int maxHp = 1600;
        public int hp;
        public int damage;

        //생성자
        public HeadFirst()
        {
            this.hp = 1600;
            this.damage = 2000;
            Console.WriteLine("Tick 궁극기 생성");
        }
        public void Attack(Ash target)
        {
            target.hp = target.hp - this.damage;
            Console.WriteLine("{0}의 머리폭탄 공격", this.name);
            this.Die();
        }
        public void Hit(int damage)
        {
            if (this.hp <= 0)
            {
                this.Die();
            }
            else
            {
                Console.WriteLine("{0}가 (-{1})피해받음 ({2}/{3})", this.name, damage, this.hp, this.maxHp);

            }

        }
        public void Die()
        {
            Console.WriteLine("{0}가 제거되었습니다. ", this.name);
        }
    }
}

 

Chester Class


CHESTER [장거리 딜러]
----------
[속성]
공격력 720
HP 3300
이동속도 2.57
----------
[기능]
공격하기_1번째 1개 구체, 2번째 2, 3번째 3까지
사망
이동하기

피해받음(hp가 0 이하일 경우 Die호출)

궁극기(StrongMint) 본인 회복

using System;

namespace BRAWLSTARS
{
    class Chester
    {
        public string name;
        int MAX_COUNT_BALL = 3;
        public int nowBall;
        public int damage;
        public int hp;
        public int maxHp = 3300;
        public float speed;
        int strongMintHeal = 2400;

        //생성자
        public Chester(string name)
        {
            Console.WriteLine("CHESTER 생성자");
            this.name = name;
            this.nowBall = 1;
            this.damage = 720;
            this.hp = 3300;
            this.speed = 2.57f;

        }

        public void Attack()
        {
            this.damage = 720 * this.nowBall;
            Console.WriteLine("{0}개의 구체로 공격하였습니다.데미지는 {1}", nowBall, damage);
            this.nowBall++;
            if (this.nowBall > MAX_COUNT_BALL)
            {
                this.nowBall = 1;
            }
        }

        public void Move()
        {
            Console.WriteLine("{0}가 이동하였습니다.", this.name);
        }
        public void Die()
        {
            Console.WriteLine("{0}가 죽었습니다.", this.name);
        }
        public void Hit(int damage)
        {
            if (this.hp <= 0)
            {
                this.Die();
            }
            else
            {
                Console.WriteLine("{0}가 (-{1})피해받음 ({2}/{3})", this.name, damage, this.hp, this.maxHp);

            }

        }

        public void StrongMint()
        {
            if (this.hp == this.maxHp)
            {
                Console.WriteLine("현재 최대 체력입니다. ");
            }
            else
            {
                this.hp = this.hp + strongMintHeal;

                if (this.hp > this.maxHp)
                {
                    this.hp = maxHp;
                }
                Console.WriteLine("{0}의 체력 회복 +{1} ({2}/{3})", this.name, this.strongMintHeal, this.hp, this.maxHp);
            }
        }
    }
}

 

 

Emz Class


EMZ [중거리 딜러]
----------
[속성]
공격력 520
HP 3600
이동속도 2.4
----------
[기능]
공격하기_spray
사망
이동하기

using System;

namespace BRAWLSTARS
{
    class Emz
    {
        public string name;
        public int damage;
        public int hp;
        public float speed;

        //생성자
        public Emz(string name)
        {
            Console.WriteLine("EMZ 생성자");
            this.name = name;
            this.damage = 520;
            this.hp = 3600;
            this.speed = 2.4f;

        }

        public void Attack(Chester target)
        {
            target.hp = target.hp - this.damage;
            Console.WriteLine("{0}가 {1}를 공격하였습니다.", this.name, target.name);
            target.Hit(this.damage);
        }

        public void Move()
        {
            Console.WriteLine("{0}가 이동하였습니다.", this.name);
        }
        public void Die()
        {
            Console.WriteLine("{0}가 죽었습니다.", this.name);
        }

    }
}

 

Poco Class


POCO[서포터]
----------
[속성]
공격력 760
회복량 700
HP 4000
이동속도 2.4
----------
[기능]
공격하기
사망
이동하기

아군을 회복시키기(Ash를 타겟으로)

using System;

namespace BRAWLSTARS
{
    class Poco
    {
        public string name;
        public int damage;
        public int hp;
        public int heal;
        public float speed;

        //생성자
        public Poco(string name)
        {
            Console.WriteLine("POCO 생성자");
            this.name = name;
            this.damage = 760;
            this.hp = 4000;
            this.heal = 700;
            this.speed = 2.4f;

        }

        public void Attack()
        {
            Console.WriteLine("{0}가 공격하였습니다.", this.name);
        }

        public void Move()
        {
            Console.WriteLine("{0}가 이동하였습니다.", this.name);
        }
        public void Die()
        {
            Console.WriteLine("{0}가 죽었습니다.", this.name);
        }

        public void Heal(Ash target)
        {
            target.hp = target.hp + this.heal;
            Console.WriteLine("{0}를 +{1}만큼 회복 ({2}/{3})", target.name, this.heal, target.hp, target.maxHp);
        }

    }
}

 

Sprout Class

 


SPROUT [중거리 딜러]
----------
[속성]
공격력 980
HP 3000
이동속도 2.4
----------
[기능]
공격하기
사망
이동하기

궁극기(Hedge) 틱을 타겟으로 울타리 설치

using System;

namespace BRAWLSTARS
{
    class Sprout
    {
        public string name;
        public int damage;
        public int hp;
        public float speed;
        public bool hedge = false;

        //생성자
        public Sprout(string name)
        {
            Console.WriteLine("SPROUT 생성자");
            this.name = name;
            this.damage = 980;
            this.hp = 3000;
            this.speed = 2.4f;

        }

        public void Attack(HeadFirst target)
        {
            target.hp = target.hp - this.damage;
            Console.WriteLine("{0}가 {1}를 공격하였습니다. ", this.name, target.name);
        }

        public void Move()
        {
            Console.WriteLine("{0}이 이동하였습니다.", this.name);
        }
        public void Die()
        {
            Console.WriteLine("{0}이 죽었습니다.", this.name);
        }

        public void Hedge(Tick target)
        {
            if (hedge == false)
            {
                hedge = true;
                Console.WriteLine("{0}가 {1}의 주변에 울타리를 설치하였습니다. ", this.name, target.name);
            }
            else
            {
                hedge = false;
                Console.WriteLine("울타리를 제거하였습니다. ");
            }
        }
    }
}

 

Ash Class


ASH[탱커]
----------
[속성]
공격력 800
HP 5400
이동속도 2.4
----------
[기능]
공격하기
사망
이동하기

피해받음(hp가 0 이하일 경우 Die호출)

using System;

namespace BRAWLSTARS
{
    class Ash
    {
        public string name;
        public int damage;
        public int hp;
        public int maxHp = 5400;
        public float speed;

        //생성자
        public Ash(string name)
        {
            Console.WriteLine("ASH 생성자");
            this.name = name;
            this.damage = 800;
            this.hp = 5400;
            this.speed = 2.4f;

        }

        public void Attack()
        {
            Console.WriteLine("{0}가 공격하였습니다.", this.name);
        }

        public void Move()
        {
            Console.WriteLine("{0}가 이동하였습니다.", this.name);
        }
        public void Hit(int damage)
        {
            if (this.hp <= 0)
            {
                this.Die();
            }
            else
            {
                Console.WriteLine("{0}가 (-{1})피해받음 ({2}/{3})", this.name, damage, this.hp, this.maxHp);

            }

        }

        public void Die()
        {
            Console.WriteLine("{0}가 죽었습니다.", this.name);
        }

    }
}

 

실행 결과

728x90