-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
futaba
committed
Oct 27, 2019
1 parent
0c450e6
commit 5d40547
Showing
14 changed files
with
1,025 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29209.62 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testConsoleGame", "testConsoleGame\testConsoleGame.csproj", "{BC35A3B8-E56E-420E-95CD-3693732579B6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{BC35A3B8-E56E-420E-95CD-3693732579B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{BC35A3B8-E56E-420E-95CD-3693732579B6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{BC35A3B8-E56E-420E-95CD-3693732579B6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{BC35A3B8-E56E-420E-95CD-3693732579B6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0DBA61CA-DE4C-44B1-BFE7-7BE5F1F5CF70} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace testConsoleGame | ||
{ | ||
public class Ability | ||
{ | ||
public string Name { get; set; } | ||
public int Level { get; set; } | ||
public int Damage { get { return _basedDamage * Level; } set { Damage = _basedDamage * Level; } } | ||
public int Cost { get; set; } | ||
|
||
int _basedDamage; | ||
|
||
string[] mageAbilities = { "Огненный шар", "Ледяная стрела", "Чародейская вспышка", "Огненная глыба" }; | ||
int[] basedMageDamage = { 95, 80, 190, 240 }; | ||
|
||
string[] warriorAbilities = { "Смертельный удар", "Превосходство", "Удар героя", "Мощный удар" }; | ||
int[] basedWarriorDamage = { 110, 80, 120, 160 }; | ||
|
||
string[] hunterAbilities = { "Укус гадюки", "Оглушающий выстрел", "Чародейский выстрел", "Атака питомца" }; | ||
int[] basedHunterDamage = { 135, 160, 170, 210 }; | ||
|
||
string[] rogueAbilities = { "Удар в спину", "Потрошение", "Внезапный удар", "Расправа" }; | ||
int[] basedRogueDamage = { 85, 165, 140, 180 }; | ||
|
||
|
||
int[] basicCost = { 30, 25, 40, 60 }; | ||
|
||
public Ability(int index, int classId) | ||
{ | ||
switch(classId) | ||
{ | ||
case 0: | ||
{ | ||
Name = warriorAbilities[index]; | ||
_basedDamage = basedWarriorDamage[index]; | ||
Level = 1; | ||
Cost = basicCost[index]; | ||
break; | ||
} | ||
case 1: | ||
{ | ||
Name = mageAbilities[index]; | ||
_basedDamage = basedMageDamage[index]; | ||
Level = 1; | ||
Cost = basicCost[index]; | ||
break; | ||
} | ||
case 2: | ||
{ | ||
Name = hunterAbilities[index]; | ||
_basedDamage = basedHunterDamage[index]; | ||
Level = 1; | ||
Cost = basicCost[index]; | ||
break; | ||
} | ||
case 3: | ||
{ | ||
Name = rogueAbilities[index]; | ||
_basedDamage = basedRogueDamage[index]; | ||
Level = 1; | ||
Cost = basicCost[index]; | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace testConsoleGame | ||
{ | ||
public class Fight | ||
{ | ||
int _playersHealth; | ||
int _playersBasicAttack; | ||
int _enemiesHealth; | ||
int _enemiesBasicAttack; | ||
Random Random; | ||
int _playerResource; | ||
Monster thisMonster; | ||
public Fight(Player p, Monster m) | ||
{ | ||
Random = new Random(); | ||
thisMonster = m; | ||
_playersHealth = (p.Level * 120); | ||
_enemiesHealth = (m.Level * 140); | ||
_playersBasicAttack = (p.Level * 50); | ||
_enemiesBasicAttack = (p.Level * 25); | ||
_playerResource = 100; | ||
} | ||
void YourTurn(Player p) | ||
{ | ||
Console.WriteLine("\n?????[!] - Ваша очередь атаковать, выберите способ атаки (Нажмите на соответствующую цифру на клавиатуре)\n" + | ||
"?????[!] - Нажатие на несоответствующую клавишу приведёт к использованию случайного заклинания!\n"); | ||
bool turnEnded = false; | ||
int damageToEnemy; | ||
while (!turnEnded) | ||
{ | ||
Console.WriteLine("\nXXXXX[?] - Доступные способности в бою:\n"); | ||
Console.WriteLine($"XXXXX[1] - Базовая атака холодным оружием [Не требует маны] / Наносит {(int)(_playersBasicAttack * 0.8)}-{(int)(_playersBasicAttack * 1.4)} единиц урона."); | ||
for (int i = 0; i < p.Class.AvaliableAbilities.Count; i++) | ||
{ | ||
Ability a = p.Class.AvaliableAbilities[i]; | ||
Console.WriteLine($"XXXXX[{i + 2}] - " + a.Name + | ||
$" [{a.Cost} маны] / Наносит {(int)(a.Damage*0.8)}-{(int)(a.Damage * 1.7)} единиц урона."); | ||
} | ||
ConsoleKeyInfo key; | ||
key = Console.ReadKey(); | ||
bool isParsed = Int32.TryParse(key.KeyChar.ToString(), out int parsedKey); | ||
if (key.Key == ConsoleKey.D1) | ||
{ | ||
damageToEnemy = Random.Next(_playersBasicAttack - (int)(_playersBasicAttack * 0.8), _playersBasicAttack + (int)(_playersBasicAttack * 1.4)); | ||
_enemiesHealth -= damageToEnemy; | ||
Console.Clear(); | ||
Console.WriteLine($"+++++Вы атакуете вашего врага в ближнем бою, нанося {damageToEnemy} единиц урона\n"); | ||
turnEnded = true; | ||
} | ||
else if (isParsed && parsedKey < 6 && parsedKey > 1) | ||
{ | ||
Ability temp = p.Class.AvaliableAbilities[Int32.Parse(key.KeyChar.ToString()) - 2]; | ||
if(temp.Cost<=_playerResource) | ||
{ | ||
_playerResource -= temp.Cost; | ||
damageToEnemy = Random.Next((int)(temp.Damage * 0.8), (int)(temp.Damage * 1.9)); | ||
_enemiesHealth -= damageToEnemy; | ||
Console.Clear(); | ||
Console.WriteLine($"+++++Вы атакуете вашего врага, используя заклинание {temp.Name} и наносите {damageToEnemy} единиц урона!\n"); | ||
turnEnded = true; | ||
} | ||
else | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine($"\nXXXXX Недостаточно маны. Ваш запас маны: [{_playerResource}]"); | ||
} | ||
} | ||
else | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine($"\nXXXXX Вы ошиблись при вводе используемой способности. Попробуйте ещё раз!\n"); | ||
} | ||
} | ||
} | ||
|
||
int EnemyTurn(Monster m) | ||
{ | ||
int damageToHero = Random.Next(_enemiesBasicAttack - (int)(_enemiesBasicAttack * 0.7), _enemiesBasicAttack + (int)(_enemiesBasicAttack * 1.3)); | ||
Console.WriteLine($"-----{m.Name} атакует вашего героя, нанося {damageToHero}\n"); | ||
_playersHealth -= damageToHero; | ||
return damageToHero; | ||
} | ||
public void FightStart(Player p, Map map) | ||
{ | ||
bool someOneIsDead = false; | ||
Console.WriteLine($"\n*****[?] - Ваш противник: {thisMonster.Name} {thisMonster.Level} уровня с уровнем здоровья {_enemiesHealth} единиц. Желаем удачи!"); | ||
Console.WriteLine($"*****[?] - Небольшие сведения о Вас: {p.Class.Name} {p.Level} уровня. Ваш базовый урон в ближнем бою: {_playersBasicAttack} единиц."); | ||
Console.WriteLine($"*****[?] - Вы вступаете в бой имея {_playersHealth} единиц здоровья и {_playerResource} единиц ресурса.\n" + | ||
$"*****[?] - Уровень ресура расходуется на использование заклинаний"); | ||
while (!someOneIsDead) | ||
{ | ||
Console.WriteLine($"\n\nВАШЕ ЗДОРОВЬЕ: {_playersHealth} ВАШ ЗАПАС МАНЫ: {_playerResource} ЗДОРОВЬЕ ПРОТИВНИКА: {_enemiesHealth}\n"); | ||
if (_playersHealth>0) | ||
{ | ||
YourTurn(p); | ||
if(_enemiesHealth<=0) | ||
{ | ||
someOneIsDead = true; | ||
_enemiesHealth = 0; | ||
p.Experience += thisMonster.Value; | ||
Console.WriteLine($"Вы победели в бою с противником {thisMonster.Name}. Вы получаете {thisMonster.Value} очков опыта. Продолжайте Ваше путешествие!\n"); | ||
map.Monsters.Remove(thisMonster); | ||
} | ||
} | ||
if(_enemiesHealth>0) | ||
{ | ||
EnemyTurn(thisMonster); | ||
if(_playersHealth<=0) | ||
{ | ||
someOneIsDead = true; | ||
_playersHealth = 0; | ||
thisMonster.Position = new Position((Random.Next(0, map.MaxX)), (Random.Next(0, map.MaxY))); | ||
Console.WriteLine($"\n{thisMonster.Name} оделел Вас, но Вы его знатно напугали и он сбежал. Теперь он прячется в другом месте.\n"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace testConsoleGame | ||
{ | ||
public delegate void GameStateHandler(object sender, GameEventArgs e); | ||
class Game | ||
{ | ||
public event GameStateHandler InputInfo; | ||
string _gameIntroduce = "Привет. Это пошаговая текстовая игра в стиле РПГ."; | ||
string _gameInstructions = "\nЛаконично расскажу тебе о правилах: Ты - герой. Принадлежишь определенному классу, который выберешь сам. Тут их 4.\n" + | ||
"Твоё героическое тело передвигается по этому миру с помощью стрелок на клавиатуре.\n" + | ||
"(Клавиши: Вверх, Вниз - перемещение по оси Y в большую и меньшую сторону соответственно;\n" + | ||
"Влево, Вправо - перемемещение по оси X в меньшую и большую сторону соотвественно)\n" + | ||
"Надеюсь, с управлением у тебя не возникнет проблем и ты быстро разберешься.\n" + | ||
"На карте расположены сокровища и монстры в случайном порядке. \n" + | ||
"Как только ты пересечешься с ними, ты сразу об этом узнаешь.\n" + | ||
"У меня есть знакомый, который согласился подсказывать тебе путь, если ты не сможешь найти что-нибудь интересное.\n" + | ||
"Уверен, что Вы подружитесь.\n"; | ||
public void Run() | ||
{ | ||
GameIntroduce(); | ||
Player player = new Player(); | ||
player.PrintInfo += ShowMessage; | ||
Map Map = new Map(20, 20, player); | ||
Map.PrintInfo += ShowMessage; | ||
int n = 0; | ||
while (true) | ||
{ | ||
if (n == 15) | ||
{ | ||
n = 0; | ||
Map.NavigationHelp(); | ||
} | ||
if(Map.Treasures.Count<=Map.TreasuresListCap*0.25) | ||
{ | ||
Map.TreasureRefresh(); | ||
} | ||
if(Map.Monsters.Count<=Map.MonstersListCap*0.25) | ||
{ | ||
Map.MonsterRefresh(player); | ||
} | ||
player.Moving(Map); | ||
Map.Founded(player) ; | ||
Map.MonsterFound(player); | ||
player.Progress(); | ||
n++; | ||
} | ||
} | ||
|
||
void GameIntroduce() | ||
{ | ||
InputInfo.Invoke(this, new GameEventArgs(_gameIntroduce, ConsoleColor.DarkGreen)); | ||
InputInfo.Invoke(this, new GameEventArgs(_gameInstructions, ConsoleColor.DarkGreen)); | ||
} | ||
|
||
static void ShowMessage(object sender, GameEventArgs e) | ||
{ | ||
Console.ForegroundColor = e.MsgColor; | ||
Console.WriteLine(e.Message); | ||
Console.ResetColor(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace testConsoleGame | ||
{ | ||
public class HeroClass | ||
{ | ||
public static string[] NameOfClass = { "Воин", "Маг", "Охотник", "Разбойник" }; | ||
int _abilityQuantity = 4; | ||
public string Name { get;set; } | ||
public List<Ability> AvaliableAbilities; | ||
public HeroClass(int choise) | ||
{ | ||
Name = NameOfClass[choise]; | ||
AvaliableAbilities = new List<Ability>(); | ||
SetAbil(choise); | ||
} | ||
|
||
void SetAbil(int choise) | ||
{ | ||
switch(choise) | ||
{ | ||
case 0: | ||
{ | ||
for (int i = 0; i < _abilityQuantity; i++) | ||
{ | ||
AvaliableAbilities.Add(new Ability(i, choise)); | ||
} | ||
break; | ||
} | ||
case 1: | ||
{ | ||
for(int i =0; i<_abilityQuantity; i++) | ||
{ | ||
AvaliableAbilities.Add(new Ability(i, choise)); | ||
} | ||
break; | ||
} | ||
case 2: | ||
{ | ||
for (int i = 0; i < _abilityQuantity; i++) | ||
{ | ||
AvaliableAbilities.Add(new Ability(i, choise)); | ||
} | ||
break; | ||
} | ||
case 3: | ||
{ | ||
for (int i = 0; i < _abilityQuantity; i++) | ||
{ | ||
AvaliableAbilities.Add(new Ability(i, choise)); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public void ShowAvalAb() | ||
{ | ||
foreach(Ability a in AvaliableAbilities) | ||
{ | ||
Console.WriteLine(a.Name); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.