Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
need to make buttons work
  • Loading branch information
rkv14001 committed Sep 13, 2016
1 parent 3f7d701 commit 819c423
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 5 deletions.
Binary file removed .DS_Store
Binary file not shown.
Binary file modified First Project/Assets/DnDBattle.unity
Binary file not shown.
76 changes: 72 additions & 4 deletions First Project/Assets/Scripts/DNDFight.cs
Expand Up @@ -3,6 +3,7 @@ using System.Collections;
using UnityEngine.UI;
public class DNDFight : MonoBehaviour {

public Text log;
public Text pName;
public Text pHitPoints;
public Text pDMG;
Expand All @@ -16,13 +17,14 @@ public class DNDFight : MonoBehaviour {
public int pHitPointsInt;
public int pDMGLow;
public int pDMGHigh;
public float pAccf;
public int pAccf;

public string eNameStr;
public int eHitPointsInt;
public int eDMGLow;
public int eDMGHigh;
public float eAccf;
public int eAccf;


// Use this for initializations
void Start () {
Expand All @@ -35,6 +37,7 @@ public class DNDFight : MonoBehaviour {
eHitPoints = eHitPoints.GetComponent<Text> ();
eDMG = eDMG.GetComponent<Text> ();
eAcc = eAcc.GetComponent<Text> ();
log = log.GetComponent<Text> ();

}

Expand All @@ -44,14 +47,79 @@ public class DNDFight : MonoBehaviour {
pName.text = pNameStr;
pHitPoints.text = "HP: " + pHitPointsInt.ToString ();
pDMG.text = pDMGLow.ToString () + " - " + pDMGHigh.ToString ();
pAcc.text = "Accuracy: " + pAccf.ToString ();
pAcc.text = "Accuracy: " + pAccf.ToString () + " %";

eName.text = eNameStr;
eHitPoints.text = "HP: " + eHitPointsInt.ToString ();
eDMG.text = eDMGLow.ToString () + " - " + eDMGHigh.ToString ();
eAcc.text = "Accuracy: " + eAccf.ToString ();
eAcc.text = "Accuracy: " + eAccf.ToString () + " %";
}

public void Roll () {
pNameStr = "PLAYER 1";
pHitPointsInt = getRandomInt (4.0f, 24.0f);
int pdmg1 = getRandomInt (4.0f, 24.0f);
int pdmg2 = getRandomInt (4.0f, 24.0f);
pDMGHigh = Mathf.Max (pdmg1, pdmg2);
pDMGLow = Mathf.Min (pdmg1, pdmg2);
pAccf = getRandomInt(0.0f, 100.0f);

eNameStr = "Enemy 1";
eHitPointsInt = getRandomInt (4.0f, 24.0f);
int edmg1 = getRandomInt (4.0f, 24.0f);
int edmg2 = getRandomInt (4.0f, 24.0f);
eDMGHigh = Mathf.Max (edmg1, edmg2);
eDMGLow = Mathf.Min (edmg1, edmg2);
eAccf = getRandomInt(0.0f, 100.0f);
}
public void Fight () {
string final = playerAttackEnemy () + enemyAttackPlayer ();
log.text = final;
}

string playerAttackEnemy () {
string result = "";
if (getRandomInt (0.0f, 100.0f) < pAccf) {
result += "Hit! " + pNameStr + " hit " + eNameStr + " for ";
int dmg = getRandomInt ((float)pDMGLow, (float)pDMGHigh);
eHitPointsInt = eHitPointsInt - dmg;
result += dmg.ToString () + " damage. \n";

if (eHitPointsInt <= 0) {
result += "Dead! " + eNameStr + " has died! \n";

}

} else {
result += "Miss! " + pNameStr + " missed " + eNameStr + "! \n";
}
return result;
}
string enemyAttackPlayer () {
string result = "";
if (getRandomInt (0.0f, 100.0f) < pAccf) {
result += "Hit! " + eNameStr + " hit " + pNameStr + " for ";
int dmg = getRandomInt ((float)eDMGLow, (float)eDMGHigh);
pHitPointsInt = pHitPointsInt - dmg;
result += dmg.ToString () + " damage. \n";

if (pHitPointsInt <= 0) {
result += "Dead! " + pNameStr + " has died! \n";

}

} else {
result += "Miss! " + eNameStr + " missed " + pNameStr + "! \n";
}
return result;
}




int getRandomInt(float i, float j) {
return Mathf.RoundToInt(Random.Range (i, j));
}
// Update is called once per frame
void Update () {
set ();
Expand Down
Binary file modified First Project/Library/CurrentLayout.dwlt
Binary file not shown.
2 changes: 1 addition & 1 deletion First Project/Library/LastSceneManagerSetup.txt
@@ -1,4 +1,4 @@
sceneSetups:
- path: Assets/Scene/DnDCombat.unity
- path: Assets/DnDBattle.unity
isLoaded: 1
isActive: 1
Binary file modified First Project/Library/ProjectSettings.asset
Binary file not shown.
Binary file modified First Project/Library/assetDatabase3
Binary file not shown.
Binary file modified First Project/Library/expandedItems
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified First Project/ProjectSettings/ProjectSettings.asset
Binary file not shown.
Binary file modified First Project/ProjectSettings/UnityConnectSettings.asset
Binary file not shown.
Binary file modified First Project/Temp/__Backupscenes/0.backup
Binary file not shown.

0 comments on commit 819c423

Please sign in to comment.