Ok so I have this little game I am working on and I am tring to get some output for the user when he hits the enemy I would like to print out something so the player can see hey I hit the opponet. Just some simple line somewhere so I can test to see if my code is acctually doing something.
I have tried print(“something”);
and also Console.Writeline(“something”);
too see if I did the scripting right;
Thanks:)
here is the code:
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
public class Battle : MonoBehaviour {
//build and initialization of characters in the game
//do this somewhere else in real game
//build character 1
Player Mav = new Player();
//build enemy ninja
Enemy Ninja = new Enemy();
public double potion = 100;//hp boost
public double elixer = 200;//hp boost
// Use this for initialization
void Start () {
Mav.hp = 1220;
Mav.mp = 150;
Mav.sp = 100;
Mav.charaterName = "Mavrick";
//initialization of attacks and skill wheel
Mav.slash = 1;
Mav.flameSlash = 1.5;
Mav.shiningStrike = 2;
//skill wheel
Mav.powerDive = 150;
Mav.powerCharge = 250;
Mav.wildStrike = 350;
Mav.renegade = 400;
Mav.shiningStars = 500;
//magic
Mav.lightSpell = 150;
Mav.flame = 150;
Mav.snow = 300;
//initialization of enemy
Ninja.hp = 1000;
Ninja.atk1 = 100;
Ninja.atk2 = 150;
Ninja.specialAttack = 200;
Ninja.enemyName = "Ninja";
}
// Update is called once per frame
void Update () {
battle();
}
void battle()
{
//see if enemy dies
while(Ninja.hp > 0){
//random number for attack power Not C# but unity engine random number
int dice = UnityEngine.Random.Range(1,50);
string bInput;
char button;
bInput = Console.ReadLine();
button = char.Parse(bInput);
switch (button)
{
//slash attack
case 'x':
Ninja.hp = Ninja.hp - (Mav.slash * dice);
Console.WriteLine("Slash Attack");
print("Slash Attack");
print(Ninja.hp);
Thread.Sleep(5000);//sleep for 5 second Player cant attack
break;
//flame slash attack
case 'v':
Ninja.hp = Ninja.hp - (Mav.flameSlash * dice);
Thread.Sleep(5000);//sleep for 5 second Player cant attack
break;
//shining Srike attack
case 's':
Ninja.hp = Ninja.hp - (Mav.shiningStrike * dice);
Thread.Sleep(5000);//sleep for 5 second Player cant attack
break;
//skill wheel attacks
case 'l':
/*
Console.WriteLine("Skill Wheel");
Console.WriteLine("1 for Power Dive");
Console.WriteLine("2 for Power Charge");
Console.WriteLine("3 for Wild Strike");
Console.WriteLine("4 for Renegade");
Console.WriteLine("5 for Shining Stars");
*/
string b1Input;
int button1;
b1Input = Console.ReadLine();
button1 = int.Parse(b1Input);
//inner if else
if (button1 == 1)
{
Ninja.hp -= Mav.powerDive;
}
else if (button1 == 2)
{
Ninja.hp -= Mav.powerCharge;
}
else if (button1 == 3)
{
Ninja.hp -= Mav.wildStrike;
}
else if (button1 == 4)
{
Ninja.hp -= Mav.renegade;
}
else if (button1 == 5)
{
Ninja.hp -= Mav.shiningStars;
}
break;
//magic attacks
case 'r':
/*
Console.WriteLine("Press 1 for Light");
Console.WriteLine("Press 2 for Flame");
Console.WriteLine("Press 3 for Snow");
*/
string b2Input;
int button2;
b2Input = Console.ReadLine();
button2 = int.Parse(b2Input);
//inner if else
if (button2 == 1)
{
Mav.hp += Mav.lightSpell;
}
else if (button2 == 2)
{
Ninja.hp -= Mav.flame;
}
else if (button2 == 3)
{
Ninja.hp -= Mav.snow;
}
break;
case 'i':
//use for items
string b3Input;
int button3;
b3Input = Console.ReadLine();
button3 = int.Parse(b3Input);
if(button3 ==1)
{
Mav.hp += potion;
}else if(button3 == 2)
{
Mav.hp += elixer;
}
break;
case 'd':
//use for defense
break;
case 'c':
//charater switch command
break;
}//end of switch for input
}//end of while loop
}
}