Early Access, v1.0.1
This commit is contained in:
111
Assets/Scripts/BasicSkill.cs
Normal file
111
Assets/Scripts/BasicSkill.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class BasicSkill
|
||||
{
|
||||
int level;
|
||||
int baseDamage;
|
||||
int secondaryConsumption;
|
||||
int cooldown;
|
||||
int maxCooldown;
|
||||
string skillname;
|
||||
Texture skillIcon;
|
||||
GameObject skillAnimation;
|
||||
|
||||
public BasicSkill(int baseDamage, int secondaryConsumption, int maxCooldown, string name, string skillIconPath, GameObject skillAnimation)
|
||||
{
|
||||
this.baseDamage = baseDamage;
|
||||
this.secondaryConsumption = secondaryConsumption;
|
||||
this.maxCooldown = maxCooldown;
|
||||
cooldown = 0;
|
||||
level = 1;
|
||||
skillname = name;
|
||||
skillIcon = Resources.Load<Texture>(skillIconPath);
|
||||
this.skillAnimation = skillAnimation;
|
||||
}
|
||||
|
||||
public int calculateDamage(int attribute, bool isCrit)
|
||||
{
|
||||
cooldown = maxCooldown;
|
||||
if (isCrit)
|
||||
{
|
||||
return (baseDamage + attribute)* level * 2;
|
||||
}
|
||||
return (baseDamage + attribute) * level ;
|
||||
}
|
||||
|
||||
public bool canPlayerCast(int playerSecondary)
|
||||
{
|
||||
bool result = false;
|
||||
if (playerSecondary >= secondaryConsumption && cooldown == 0)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void display(GameObject image, GameObject desc, int playerSecondary)
|
||||
{
|
||||
image.GetComponent<RawImage>().texture = skillIcon;
|
||||
if (canPlayerCast(playerSecondary))
|
||||
{
|
||||
desc.GetComponent<Text>().text = skillname + "(Lvl." + level + ") (" + secondaryConsumption + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.GetComponent<Text>().text = "Not castable (" + secondaryConsumption + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void reduceCooldown()
|
||||
{
|
||||
if (cooldown > 0)
|
||||
{
|
||||
cooldown--;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSecondaryConsumption()
|
||||
{
|
||||
return secondaryConsumption;
|
||||
}
|
||||
|
||||
public void playSound(AudioHandler audioHandler)
|
||||
{
|
||||
switch (skillname)
|
||||
{
|
||||
case "Slash":
|
||||
audioHandler.playHit();
|
||||
break;
|
||||
case "Block":
|
||||
break;
|
||||
case "Execution":
|
||||
audioHandler.playHit();
|
||||
break;
|
||||
case "Stab":
|
||||
audioHandler.playDaggerHit();
|
||||
break;
|
||||
case "SmokeScreen":
|
||||
break;
|
||||
case "Heartstop":
|
||||
audioHandler.playDaggerHit();
|
||||
break;
|
||||
case "Icicle":
|
||||
audioHandler.playIceHit();
|
||||
break;
|
||||
case "Teleport":
|
||||
break;
|
||||
case "Fireball":
|
||||
audioHandler.playExplosion();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user