Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BuffSelecter basically finished #53

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 235 additions & 0 deletions server/src/Buff/BuffSelector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
using Serilog.Debugging;
using Thuai.Server.GameLogic;
using Thuai.Server.Buff;

namespace Thuai.Server.BuffSelector;


/// <summary>
/// Buffs that can be selected.
/// </summary>
public enum Buff
{
BULLET_COUNT, // 子弹数量
BULLET_SPEED, // 子弹移速
ATTACK_SPEED, // 攻速
LASER, // 激光
DAMAGE, // 伤害
ANTI_ARMOR, // 破甲
ARMOR, // 护盾
REFLECT, // 反弹
DODGE, // 闪避
KNIFE, // 名刀
GRAVITY, // 重力
BLACK_OUT, // 视野限制
SPEED_UP, // 加速
FLASH, // 闪现
DESTROY, // 破坏墙体
CONSTRUCT, // 建造墙体
TRAP, // 陷阱
MISSILE, // 导弹
KAMUI, // 虚化
}

/// <summary>
/// Selects a buff for a tank.
/// </summary>
public class BuffSelector
{
/// <summary>
/// Three types of buffs.
/// </summary>
private Buff[] OffensiveBuff = new Buff[]
{
Buff.BULLET_COUNT,
Buff.BULLET_COUNT,
Buff.BULLET_SPEED,
Buff.ATTACK_SPEED,
Buff.ATTACK_SPEED,
Buff.DAMAGE,
Buff.LASER,
Buff.ANTI_ARMOR
};
private Buff[] DefensiveBuff = new Buff[]
{
Buff.ARMOR,
Buff.ARMOR,
Buff.ARMOR,
Buff.REFLECT,
Buff.KNIFE,
Buff.GRAVITY,
Buff.DODGE,
Buff.DODGE
};
private Buff[] UtilityBuff = new Buff[]
{
Buff.BLACK_OUT,
Buff.SPEED_UP,
Buff.FLASH,
Buff.DESTROY,
Buff.CONSTRUCT,
Buff.KAMUI,
Buff.MISSILE,
Buff.TRAP
};
private int Round = 1;

/// <summary>
/// Contructor.
/// </summary>
public BuffSelector()
{
BuffInit();
}

/// <summary>
/// Initializes the buff selector.
/// </summary>
public bool BuffInit()
{
Random offensiverand = new Random();
Random defensiverand = new Random();
Random Utilityrand = new Random();
OffensiveBuff = OffensiveBuff.OrderBy(x => offensiverand.Next()).ToArray();
DefensiveBuff = DefensiveBuff.OrderBy(x => defensiverand.Next()).ToArray();
UtilityBuff = UtilityBuff.OrderBy(x => Utilityrand.Next()).ToArray();
return true;
}

/// <summary>
/// Show the available buffs.
/// </summary>
/// <param name="round">The round number.</param>
/// <returns>The available buffs.</returns>
public Buff[] ShowBuff(int round)
{
Buff[] availableBuff = new Buff[3];
Round = round;
availableBuff[0] = OffensiveBuff[round-1];
availableBuff[1] = DefensiveBuff[round-1];
availableBuff[2] = UtilityBuff[round-1];
return availableBuff;
}

/// <summary>
/// Selects a buff.
/// </summary>
/// <param name="tank","num">The tank and the number of the buff.</param>
/// <returns> void </returns>
public void SelectBuff(Tank tank, int num)
{
switch (num)
{
case 1:
ChooseOffensiveBuff(tank, OffensiveBuff[Round - 1]);
break;
case 2:
ChooseDefensiveBuff(tank, DefensiveBuff[Round - 1]);
break;
case 3:
ChooseUtilityBuff(tank, UtilityBuff[Round - 1]);
break;
default:
break;
}
}

/// <summary>
/// Chooses an offensive buff.
/// </summary>
/// <param name="tank","buff">The tank and the buff.</param>
/// <returns> void </returns>
private void ChooseOffensiveBuff(Tank tank, Buff buff)
{
switch (buff)
{
case Buff.BULLET_COUNT:
O_Buff.BULLET_COUNT(tank);
break;
case Buff.BULLET_SPEED:
O_Buff.BULLET_SPEED(tank);
break;
case Buff.ATTACK_SPEED:
O_Buff.ATTACK_SPEED(tank);
break;
case Buff.LASER:
O_Buff.LASER(tank);
break;
case Buff.DAMAGE:
O_Buff.DAMAGE(tank);
break;
case Buff.ANTI_ARMOR:
O_Buff.ANTI_ARMOR(tank);
break;
default:
break;
}
}

/// <summary>
/// Chooses a defensive buff.
/// </summary>
/// <param name="tank","buff">The tank and the buff.</param>
/// <returns> void </returns>
private void ChooseDefensiveBuff(Tank tank, Buff buff)
{
switch (buff)
{
case Buff.ARMOR:
D_Buff.ARMOR(tank);
break;
case Buff.REFLECT:
D_Buff.REFLECT(tank);
break;
case Buff.DODGE:
D_Buff.DODGE(tank);
break;
case Buff.KNIFE:
D_Buff.KNIFE(tank);
break;
case Buff.GRAVITY:
D_Buff.GRAVITY(tank);
break;
default:
break;
}
}

/// <summary>
/// Chooses a utility buff.
/// </summary>
/// <param name="tank","buff">The tank and the buff.</param>
/// <returns> void </returns>
private void ChooseUtilityBuff(Tank tank, Buff buff)
{
switch (buff)
{
case Buff.BLACK_OUT:
U_Buff.BLACK_OUT(tank);
break;
case Buff.SPEED_UP:
U_Buff.SPEED_UP(tank);
break;
case Buff.FLASH:
U_Buff.FLASH(tank);
break;
case Buff.DESTROY:
U_Buff.DESTROY(tank);
break;
case Buff.CONSTRUCT:
U_Buff.CONSTRUCT(tank);
break;
case Buff.TRAP:
U_Buff.TRAP(tank);
break;
case Buff.MISSILE:
U_Buff.MISSILE(tank);
break;
case Buff.KAMUI:
U_Buff.KAMUI(tank);
break;
default:
break;
}
}
}
34 changes: 34 additions & 0 deletions server/src/Buff/DefensiveBuff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Serilog.Debugging;
using Thuai.Server.GameLogic;

namespace Thuai.Server.Buff;

public static class D_Buff
{
public static void ARMOR(Tank tank)
{
// 护盾
tank.TankArmor.armorValue++;
}
public static void REFLECT(Tank tank)
{
// 反弹
tank.TankArmor.armorValue++;
tank.TankArmor.canReflect = true;
}
public static void DODGE(Tank tank)
{
// 闪避
tank.TankArmor.dodgeRate += 0.1
}
public static void KNIFE(Tank tank)
{
// 名刀
tank.TankArmor.knife = "AVAILABLE";
}
public static void GRAVITY(Tank tank)
{
// 重力
tank.TankArmor.gravityField = true;
}
}
Empty file.
49 changes: 49 additions & 0 deletions server/src/Buff/UtilityBuff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Serilog.Debugging;
using Thuai.Server.GameLogic;

namespace Thuai.Server.Buff;


public static class U_Buff
{
public static void BLACK_OUT(Tank tank)
{
// 视野限制
tank.skills.Add(Skill("BLACK_OUT", 10, 0, false));
}
public static void SPEED_UP(Tank tank)
{
// 加速
tank.skills.Add(Skill("SPEED_UP", 16, 0, false));
}
public static void FLASH(Tank tank)
{
// 闪现
tank.skills.Add(Skill("FLASH", 25, 0, false));
}
public static void DESTROY(Tank tank)
{
// 破坏墙体
tank.skills.Add(Skill("DESTROY", 18, 0, false));
}
public static void CONSTRUCT(Tank tank)
{
// 建造墙体
tank.skills.Add(Skill("CONSTRUCT", 17, 0, false));
}
public static void TRAP(Tank tank)
{
// 陷阱
tank.skills.Add(Skill("TRAP", 25, 0, false));
}
public static void MISSILE(Tank tank)
{
// 导弹
tank.skills.Add(Skill("MISSILE", 30, 0, false));
}
public static void KAMUI(Tank tank)
{
// 虚化
tank.skills.Add(Skill("KAMUI", 40, 0, false));
}
}
25 changes: 0 additions & 25 deletions server/src/Thuai.Server.csproj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove .csproj file.

This file was deleted.

Loading