It looks like you're new here. If you want to get involved, click one of these buttons!
I followed the tutorial on how to code but I don't know how to make it so my enemy loses health when I cast a spell.
I also need help so when I get a certain number of experience, my spell slots increase but when my program checks the condition for meditating (which I haven't done a method for yet) it automatically checks if spellSlots < the newly updated number of spell slots. For example spellSlots < 2 ----- spellSlots < 3 and so on. I'm sorry if it sounds confusing ask me any questions if you want further explanations. My code is above and below.
using System;
using System.Collections.Generic;
namespace MyApp
{
internal class Program
{
static void Main(string[] args)
{
Wizard wizard01 = new Wizard("Kelonial", "Sword");
Enemy enemy01 = new Enemy("Corrupted Robot", "Electric Whip");
Console.WriteLine(enemy01.health);
//Console doesn't automatically shut down
Console.ReadKey();
}
}
class Wizard
{
public string name;
public string favoriteWeapon;
public int spellSlots;
public int health;
public float experience;
public Wizard(string _name, string _favoriteWeapon)
{
name = _name;
favoriteWeapon = _favoriteWeapon;
health = 10;
experience = 0f;
spellSlots = 2;
}
public void CastSpell()
{
if (spellSlots > 0) {
Console.WriteLine(name + " uses " + favoriteWeapon);
spellSlots--;
experience += 3f;
} else {
Console.WriteLine(name + " is out of spell slots");
}
}
}
class Enemy
{
public string name;
public string favoriteWeapon;
public int health;
public int spellSlots;
public float experience;
public List<int> spellCount = new List<int>();
public bool enemyCheck;
public Enemy(string _name, string _favoriteWeapon)
{
name = _name;
favoriteWeapon = _favoriteWeapon;
health = 10;
experience = 0f;
enemyCheck = false;
spellSlots = Convert.ToInt32(spellCount.Count);
}
}
}