124 lines
4.0 KiB
C#
124 lines
4.0 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Assets.Scripts.Slimes
|
|
{
|
|
public class BasicSlime
|
|
{
|
|
protected int health;
|
|
protected int maxHealth;
|
|
protected int maxSecondary;
|
|
protected int secondary;
|
|
protected int strength;
|
|
protected int dexterity;
|
|
protected int intelligence;
|
|
protected int level;
|
|
protected int experience;
|
|
protected Item item;
|
|
|
|
public BasicSlime(Player player)
|
|
{
|
|
//health,maxHealth,secondary,maxSecondary,strength,dexterity,intelligence,level,experience,maxExperience,points,luck
|
|
int[] playerStats = player.getStats();
|
|
maxHealth = playerStats[1];
|
|
health = maxHealth;
|
|
maxSecondary = playerStats[3];
|
|
secondary = maxSecondary;
|
|
strength = playerStats[4];
|
|
dexterity = playerStats[5];
|
|
intelligence = playerStats[6];
|
|
experience = (int)(10 + playerStats[7] * 2.5f);
|
|
level = playerStats[7];
|
|
if (new System.Random().Next(100) + 1 < 1000)//10 + playerStats[11])
|
|
{
|
|
item = new Item(playerStats[11]);
|
|
}
|
|
}
|
|
|
|
public BasicSlime(JToken json)
|
|
{
|
|
maxHealth = (int)json["maxHealth"];
|
|
maxSecondary = (int)json["maxSecondary"];
|
|
secondary = (int)json["secondary"];
|
|
health = (int)json["health"];
|
|
strength = (int)json["strength"];
|
|
dexterity = (int)json["dexterity"];
|
|
intelligence = (int)json["intelligence"];
|
|
level = (int)json["level"];
|
|
experience = (int)json["experience"];
|
|
}
|
|
|
|
public int[] getStats()
|
|
{
|
|
int[] result = { health, maxHealth, secondary, maxSecondary, strength, dexterity, intelligence };
|
|
return result;
|
|
}
|
|
|
|
public bool takeDamage(int amount, System.Random rand)
|
|
{
|
|
if (rand.Next(1, 101) > dexterity + (intelligence / 2))
|
|
{
|
|
health = health - amount;
|
|
}
|
|
return health <= 0;
|
|
}
|
|
|
|
public int calculateHeavy(System.Random rand)
|
|
{
|
|
int result = 0;
|
|
if (secondary >= maxSecondary / 2)
|
|
{
|
|
int bonus = 0;
|
|
if (rand.Next(1, 101) <= dexterity)
|
|
{
|
|
bonus = strength * 2;
|
|
}
|
|
result = strength + bonus + 10;
|
|
secondary = secondary - (maxSecondary / 2);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public int calculateDamage(System.Random rand)
|
|
{
|
|
int result;
|
|
int bonus = 0;
|
|
if (rand.Next(1, 101) <= dexterity)
|
|
{
|
|
bonus = strength * 2;
|
|
}
|
|
result = strength + bonus + 5;
|
|
return result;
|
|
}
|
|
|
|
public int getExperience()
|
|
{
|
|
return experience;
|
|
}
|
|
|
|
public Item getItem()
|
|
{
|
|
return item;
|
|
}
|
|
|
|
public string saveSlime()
|
|
{
|
|
string result = "";
|
|
result = result + FileHandler.generateJSON("health", health) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("maxHealth", maxHealth) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("maxSecondary", maxSecondary) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("secondary", secondary) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("strength", strength) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("dexterity", dexterity) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("intelligence", intelligence) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("level", level) + ",\r\n";
|
|
result = result + FileHandler.generateJSON("experience", experience);
|
|
return result;
|
|
}
|
|
}
|
|
}
|