0% found this document useful (0 votes)
23 views4 pages

Using Using Using Using Using Using Namespace Class: Player

This document defines a Player class for a fighting game. The Player class tracks player name, health, attack intensities, super and ultra attack bars. Methods are defined for displaying player statistics, performing regular attacks like punch and kick with random defense outcomes, executing super and ultra attacks that deal damage based on health.

Uploaded by

Fasih Dawood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Using Using Using Using Using Using Namespace Class: Player

This document defines a Player class for a fighting game. The Player class tracks player name, health, attack intensities, super and ultra attack bars. Methods are defined for displaying player statistics, performing regular attacks like punch and kick with random defense outcomes, executing super and ultra attacks that deal damage based on health.

Uploaded by

Fasih Dawood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace ConsoleApplication2
{
class Player
{

//Initializing class Variables


public string pName;

public int pHealth;


public int _goneHealth;
//Intensities
public static int high;
public static int medium;
public static int low;

//initializing Super and Ultra Attack


public double super;
public int ultrabar;

//defence mechanism
char defH;
char defM;
//char defL;

//Default Constructor
public Player(string Pname, int health)
{
this.pName = Pname;
pHealth = health;

//to Show Current Statistics


public void stats(Player p)
{

// Console.WriteLine("\n\nName:{0}\t\tHp:{1}\n\nSuper Charged:{2}/100\n\n",
this.pName, this.pHealth,this.super);
Console.WriteLine("----------------------------------------------------------
-");
Console.WriteLine(" STATISTICS
");
Console.WriteLine("----------------------------------------------------------
-");
Console.WriteLine("PLAYER 1: {0}\t\t\tPLAYER 2: {1}\n", pName, p.pName);
Console.WriteLine("HP: {0}\t\t\t\tHP: {1}\n", pHealth, p.pHealth);
Console.WriteLine("SUPER BAR: {0}/100\t\tSUPER BAR: {1}/100\n", super,
p.super);
Console.WriteLine("NOTE: SUPER ATTACK WILL ONLY BE ACTIVITED WHEN SUPER BAR
\nREACHES 25.25 POINTS!!\n\n");
}
//Random number/Char GENERATOR

//defL = (char)r.Next('A', 'B');

//Just an example method(is not implemented)


public void attack(Player p)
{
high = (p.pHealth / 16) + (_goneHealth / 16);
medium = 12;
low = 17;
p.pHealth = p.pHealth - 5;
Console.WriteLine("{2} Hit an attack on {0} and gave damage of {3} HP and
remaining HP is {1} ", p.pName, p.pHealth, pName, 5);

//punching method**
public void punch(Player p, char c)
{
Random r = new Random();
defM = (char)r.Next('A', 'C');
defH = (char)r.Next('A', 'D');

//Console.WriteLine("{0}", defH);
high = (p.pHealth / 16) + (_goneHealth / 16);
medium = (p.pHealth / 33) + (_goneHealth / 33);
low = (p.pHealth / 50) + (_goneHealth / 50);

//Console.WriteLine("{0} {1} {2}",high,medium,low);


if (c == 'H' && defH == 'A')
{

p.pHealth = p.pHealth - high;


_goneHealth = _goneHealth + high;
super = super + 6;
p.ultrabar = p.ultrabar + 25;
Console.WriteLine("{0} Hits a High Punch of {1} AP on {2}", pName, high,
p.pName);

}
else if (c == 'M' && defM == 'A')
{
_goneHealth = _goneHealth + medium;
p.pHealth = p.pHealth - medium;
super = super + 3.75;
p.ultrabar = p.ultrabar + 15;
Console.WriteLine("{0} Hits a Medium Punch of {1} AP on {2}", pName,
medium, p.pName);
}

else if (c == 'L')
{
_goneHealth = _goneHealth + low;
p.pHealth = p.pHealth - low;
super = super + 1.5;
p.ultrabar = p.ultrabar + 10;
Console.WriteLine("{0} Hits a Low Punch of {1} AP on {2}", pName, low,
p.pName);

}
else
{

Console.WriteLine("{0} Defended Him/Herself", p.pName);

public void kick(Player p, char c)


{
high = 28;
medium = 18;
low = 12;
Random r = new Random();
defM = (char)r.Next('A', 'C');
defH = (char)r.Next('A', 'D');
//Console.WriteLine("{0} {1} {2}",high,medium,low);
if (c == 'H' && defH == 'A')
{
_goneHealth = _goneHealth + high;
p.pHealth = p.pHealth - high;
super = super + 6;
p.ultrabar = p.ultrabar + 25;
Console.WriteLine("{0} Hits a Hign Kick of {1} AP on {2}", pName, high,
p.pName);

}
else if (c == 'M' && defM == 'A')
{
_goneHealth = _goneHealth + medium;
p.pHealth = p.pHealth - medium;
super = super + 3.75;
p.ultrabar = p.ultrabar + 15;
Console.WriteLine("{0} Hits a Medium Kick of {1} AP on {2}", pName,
medium, p.pName);

else if (c == 'L')
{
_goneHealth = _goneHealth + low;
p.pHealth = p.pHealth - low;
super = super + 1.5;
p.ultrabar = p.ultrabar + 10;
Console.WriteLine("{0} Hits a Low Kick of {1} AP on {2}", pName, low,
p.pName);

}
public void superAttack(Player p)
{
int _superHit = (p.pHealth / 3) + (_goneHealth / 3);
p.pHealth = p.pHealth - _superHit;
Console.WriteLine("Player {0} lands a SUPER ATTACK of AP: {2} on {1}", pName,
p.pName, _superHit);
super = super - 25.25;
p.ultrabar = p.ultrabar + 50;
}

public void ultraAttack(Player p) {


int _ultraHit = (p.pHealth / 2)+(p._goneHealth/2);
p.pHealth = p.pHealth - _ultraHit;
Console.WriteLine("{0}*# {1}",pName,p.pName);
Thread.Sleep(500);
Console.WriteLine("{0}**# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0}***# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0}****# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0}*****# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0}******# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0} ******# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0} ******# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0} ******# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0} ******# {1}", pName, p.pName);
Thread.Sleep(500);
Console.WriteLine("{0} ******#{1}", pName, p.pName);
Thread.Sleep(1000);
Console.WriteLine("{0} landed an ULTRA ATTACK of AP:{2} on poor {1}", pName,
p.pName,_ultraHit);

}
}

You might also like