Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Commit for Homework 9/14
- Loading branch information
Showing
99 changed files
with
69,225 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEngine.UI; | ||
|
||
public class PlayerHits : MonoBehaviour { | ||
|
||
public float PlayerHitPointsText = 0.0f; | ||
public float PlayerDamage = 0.0f; | ||
public float PlayerChanceToHit = 0.0f; | ||
public float EnemyHitPoints = 0; | ||
public float EnemyDamage = 0; | ||
public float EnemyChanceToHit = 0.0f; | ||
|
||
public Text pName; | ||
public Text pDamage; | ||
public Text pChance; | ||
public Text eHits; | ||
public Text eDamage; | ||
public Text eChance; | ||
|
||
public Text status; | ||
public Text status2; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
|
||
Debug.Log (EnemyHitPoints); | ||
|
||
} | ||
|
||
public void RollStats () { | ||
PlayerHitPointsText = Random.Range (4, 6); | ||
PlayerDamage = Random.Range (1, 3); | ||
PlayerChanceToHit = Random.Range (0, 100); | ||
EnemyHitPoints = Random.Range (2, 8); | ||
EnemyDamage = Random.Range (1,3); | ||
EnemyChanceToHit = Random.Range (0, 100); | ||
|
||
pName = pName.GetComponent<Text>(); | ||
pName.text = PlayerHitPointsText.ToString(); | ||
|
||
pDamage = pDamage.GetComponent<Text>(); | ||
pDamage.text = PlayerDamage.ToString(); | ||
|
||
pChance = pChance.GetComponent<Text>(); | ||
pChance.text = PlayerChanceToHit + "%".ToString(); | ||
|
||
eHits = eHits.GetComponent<Text>(); | ||
eHits.text = EnemyHitPoints.ToString(); | ||
|
||
eDamage = eDamage.GetComponent<Text>(); | ||
eDamage.text = EnemyDamage.ToString(); | ||
|
||
eChance = eChance.GetComponent<Text>(); | ||
eChance.text = EnemyChanceToHit + "%".ToString(); | ||
|
||
|
||
Debug.Log (EnemyHitPoints); | ||
|
||
} | ||
|
||
//player health - enemy damage | ||
|
||
public void Fight() { | ||
var roll = Random.Range (0.0f, 100.0f); | ||
var playerstatus = "status"; | ||
var enemystatus = "status"; | ||
|
||
if (PlayerChanceToHit >= roll) { | ||
|
||
EnemyHitPoints = EnemyHitPoints - PlayerDamage; | ||
|
||
|
||
playerstatus = "You hit the enemy! Enemy Health is now " + EnemyHitPoints; | ||
|
||
|
||
} else { | ||
playerstatus = "You missed the enemy! Enemy Health is still " + EnemyHitPoints; | ||
}; | ||
|
||
if (EnemyChanceToHit >= roll) { | ||
|
||
PlayerHitPointsText = PlayerHitPointsText - EnemyDamage; | ||
|
||
|
||
enemystatus = "The enemy hit you! Your health is now " + PlayerHitPointsText; | ||
|
||
} else { | ||
enemystatus = "The enemy missed you! Your health is still " + PlayerHitPointsText; | ||
}; | ||
|
||
status = status.GetComponent<Text> (); | ||
status.text = playerstatus.ToString (); | ||
|
||
status2 = status2.GetComponent<Text> (); | ||
status2.text = enemystatus.ToString (); | ||
|
||
if (EnemyHitPoints <= 0) { | ||
enemystatus = ""; | ||
playerstatus = "You won!"; | ||
|
||
status = status.GetComponent<Text> (); | ||
status.text = playerstatus.ToString (); | ||
|
||
status2 = status2.GetComponent<Text> (); | ||
status2.text = enemystatus.ToString (); | ||
}; | ||
|
||
if (PlayerHitPointsText <= 0) { | ||
enemystatus = ""; | ||
playerstatus = "You Lost"; | ||
|
||
status = status.GetComponent<Text> (); | ||
status.text = playerstatus.ToString (); | ||
|
||
status2 = status2.GetComponent<Text> (); | ||
status2.text = enemystatus.ToString (); | ||
}; | ||
|
||
|
||
} | ||
|
||
|
||
// Update is called once per frame | ||
void Update () { | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf1348\cocoasubrtf170 | ||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;} | ||
{\colortbl;\red255\green255\blue255;} | ||
\margl1440\margr1440\vieww10800\viewh8400\viewkind0 | ||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural | ||
|
||
\f0\fs24 \cf0 This is a character combat game.\ | ||
\ | ||
Click Roll to Get your Health, Damage, and chance to hit value.\ | ||
\ | ||
Hit Fight to to fight the enemy. Keep clicking fight until you have destroyed the enemy or the enemy has destroyed you. \ | ||
\ | ||
Click roll to play again, then start fighting.} |
Oops, something went wrong.