Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a6c36a
Create RigidbodyFPSController.cs
dnysiusk12 Apr 13, 2016
d8507ed
Create WepScript.cs
dnysiusk12 Apr 13, 2016
f98bc2f
Adds GUI and animations
dnysiusk12 Apr 13, 2016
bf823bb
Added files via upload
dnysiusk12 May 9, 2016
0fe2ca2
Create WepMelee.cs
dnysiusk12 Jun 14, 2016
23c4cbf
Delete BarScript.cs
dnysiusk12 Jun 17, 2016
6542484
Delete Crosshair.cs
dnysiusk12 Jun 17, 2016
9bbbfbd
Delete DestroyCubes.cs
dnysiusk12 Jun 17, 2016
a2eb9b5
Delete FPSWalkerEnhanced.cs
dnysiusk12 Jun 17, 2016
a64da37
Delete FieldLight.cs
dnysiusk12 Jun 17, 2016
b1262fb
Delete GlowOn.cs
dnysiusk12 Jun 17, 2016
603f47d
Delete GunAnimSounds.cs
dnysiusk12 Jun 17, 2016
e21d446
Delete RigidbodyFPSController.cs
dnysiusk12 Jun 17, 2016
f01a3ce
Create WoodDestruction.cs
vincent123mak Jun 17, 2016
12fa700
Delete RigidbodyFPSWalker.cs
dnysiusk12 Jun 17, 2016
adf4f15
Create StackedWood.cs
vincent123mak Jun 17, 2016
5350185
Delete Shoot.cs
dnysiusk12 Jun 17, 2016
ae7a36d
Delete SimpleSmoothMouseLook.cs
dnysiusk12 Jun 17, 2016
7388fde
Delete StackedWood.cs
dnysiusk12 Jun 17, 2016
7c90494
Create EnemyAI.cs
vincent123mak Jun 17, 2016
57b1ca6
Delete WepMelee.cs
dnysiusk12 Jun 17, 2016
7405d55
Delete WepScript.cs
dnysiusk12 Jun 17, 2016
6e9ced2
Delete EnemyAI.cs
dnysiusk12 Jun 17, 2016
6f89142
Delete WoodDestruction.cs
dnysiusk12 Jun 17, 2016
80f4dd5
Add files via upload
dnysiusk12 Jun 17, 2016
d1df48d
Update README.md
vincent123mak Jun 17, 2016
e8cb30d
Update README.md
vincent123mak Jun 17, 2016
e15a0ce
Add files via upload
dnysiusk12 Jun 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# ICS4U Personal Coding Project

## Objective
State the objective of the project
The objective of this project is to learn how to use C# to a high degree of understanding and to implement these learned concepts into a Unity project.

## Technical Requirements
Mouse, keyboard, internet connection in order to download the project, monitor and speaker for both audio and visual elements of the game.

### Knowledge
An understanding of the C# language and the Unity engine, particularly the NavMeshAgent, GUI functions and the other useful built in unity functions.

### Hardware
A PC or mac

### Required Software
Executable project file, IDE capable of opening up C# documents. Microsoft's Visual Studio is recommended.

## Install and Set Up
Outline the steps required to install and run your project
Download everything from the dropbox link provided and run test.exe


## Usage
Outline anything the user needs to know to use your application

37 changes: 37 additions & 0 deletions Scripts/BarScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class BarScript : MonoBehaviour {

public WepScript wpScript;
public WepShotgun wpShotgun;
public WepMelee wpMelee;
public WepMarker wpMarker;

[SerializeField]
private float fillAmount = 1;

[SerializeField]
private Image content;



// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
HandleBar ();
}

private void HandleBar(){
if (wpScript.currentWeapon == 2){
content.fillAmount = (wpShotgun.currRounds / (float)wpShotgun.magazineSize);
} else if (wpScript.currentWeapon == 3){
content.fillAmount = (wpMarker.currRounds / (float)wpMarker.totalAmmo);
}
}
}
12 changes: 12 additions & 0 deletions Scripts/BarScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Scripts/Crosshair.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using UnityEngine;
using System.Collections;

public class Crosshair : MonoBehaviour {

void OnGUI(){
GUI.Box(new Rect((Screen.width/2) - 5,(Screen.height/2) - 5, 10, 10), "");
}
}
12 changes: 12 additions & 0 deletions Scripts/Crosshair.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Scripts/DestroyCubes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using UnityEngine;
using System.Collections;

public class DestroyCubes : MonoBehaviour
{
public GameObject enemySphere;
void Start(){

}

void OnCollisionEnter (Collision col)
{
if (col.gameObject.tag == "Enemy") {
EnemyHealthScript ehs = col.gameObject.GetComponent<EnemyHealthScript> ();
ehs.health -= 1;
GameObject bhole = Instantiate (enemySphere, this.gameObject.transform.position, this.gameObject.transform.rotation) as GameObject;
bhole.transform.parent = col.gameObject.transform;

Destroy (this.gameObject);

} else if (col.gameObject.tag == "Terrain" || col.gameObject.tag == "Untagged") {

Destroy (this.gameObject);

}
else if (col.gameObject.tag == "Wall") {

Destroy (this.gameObject);

}


}
}
12 changes: 12 additions & 0 deletions Scripts/DestroyCubes.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Scripts/EnemyHealthScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class EnemyHealthScript : MonoBehaviour {
public int health;

// Use this for initialization
void Start () {
}

// Update is called once per frame
void Update () {
if (health < 1) {
foreach (Transform child in this.transform) {
Destroy (child.gameObject);
}
Destroy (this.gameObject);
}



}



}
12 changes: 12 additions & 0 deletions Scripts/EnemyHealthScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Scripts/GlowOn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;
using System.Collections;

public class GlowOn : MonoBehaviour {
public int lightOn = -1;
public Material matWhite;
public Material matBlack;
public float targetTimeDuration = 2.0f;
public float timeCounter = 0.0f;

// Use this for initialization
void Start () {

}

void Update() {

if (lightOn == -1) {
GetComponent<Renderer> ().material = matBlack;
} else if (lightOn == 1) {
GetComponent<Renderer> ().material = matWhite;
}
if (timeCounter > targetTimeDuration) {
lightOn = -1;
timeCounter = 0;

}
timeCounter += Time.deltaTime;
}

void OnCollisionEnter (Collision col){
if (col.gameObject.tag == "Projectile") {
lightOn *= -1;
timeCounter = 0;
} else if (col.gameObject.tag == "Player") {
lightOn = 1;
timeCounter = 0;

}
}
}
12 changes: 12 additions & 0 deletions Scripts/GlowOn.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 148 additions & 0 deletions Scripts/RigidbodyFPSWalker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using UnityEngine;
using System.Collections;

[RequireComponent (typeof (Rigidbody))]
[RequireComponent (typeof (CapsuleCollider))]

public class RigidbodyFPSWalker : MonoBehaviour{

public float speed = 10.0f;
public float gravity = 10.0f;
public float maxVelocityChange = 10.0f;
public bool canJump = true;
public float jumpHeight = 2.0f;
public float thrust = 4;
public float limit = 1.0f;
public float chaseLimit;
public Rigidbody jetpackUser;
public bool isJumping = false;
public float regenFactor = 4f;
public float deprecFactor = 2f;
private bool grounded = false;
private bool isFlying = false;
private bool inAir = false;
private bool gotFuel = true;
private float chaseThrust;

public float air_accelerate = 5f;
public float ground_accelerate = 10f;
public float max_velocity_air = 20f;
public float max_velocity_ground = 5f;
public float friction = 0.5f;


void Awake () {
GetComponent<Rigidbody>().freezeRotation = true;
GetComponent<Rigidbody>().useGravity = false;
}

void Start(){
chaseLimit = limit;
chaseThrust = thrust;
}

void FixedUpdate () {
EnemyAI.targetPosition = transform.position;
if (isJumping || inAir) {
inAir = true;
grounded = false;
} else {
inAir = false;
grounded = true;
}
JetpackFuel ();
Jetpack ();


if (grounded || inAir || isJumping) {
// Calculate how fast we should be moving
Vector3 targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
targetVelocity = transform.TransformDirection(targetVelocity);
targetVelocity *= speed;

// Apply a force that attempts to reach our target velocity
Vector3 velocity = GetComponent<Rigidbody>().velocity;
Vector3 velocityChange = (targetVelocity - velocity);
velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange);
velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange);
velocityChange.y = 0;
GetComponent<Rigidbody>().AddForce(velocityChange, ForceMode.VelocityChange);


if (canJump && Input.GetButtonDown ("Jump") && grounded) {
GetComponent<Rigidbody> ().velocity = new Vector3 (velocity.x, CalculateJumpVerticalSpeed (), velocity.z);
isJumping = true;
}
else if (inAir && Input.GetButton("Jump")) {
isJumping = true;
}
else {
isJumping = false;
}

}


// We apply gravity manually for more tuning control
GetComponent<Rigidbody>().AddForce(new Vector3 (0, -gravity * GetComponent<Rigidbody>().mass, 0));
grounded = false;
}


void OnCollisionStay (Collision col) {
if (col.gameObject.tag == "Terrain" || col.gameObject.tag == "Wood") {
grounded = true;
inAir = false;
}
}

void JetpackFuel() {
bool fullTank = false;

if (chaseLimit < 0) {
gotFuel = false;
fullTank = false;
chaseLimit = 0;
} else if (chaseLimit == limit) {
fullTank = true;
gotFuel = true;
} else {
gotFuel = true;
fullTank = false;
}

if (isFlying) {
chaseLimit -= Time.deltaTime / (deprecFactor / 2f);
} else if (!fullTank && (grounded || Input.GetButtonDown("Jump"))) {

if (limit - chaseLimit <= 0.01f) {
chaseLimit = limit;
} else {
chaseLimit += Time.deltaTime / regenFactor;
}

}

}

void Jetpack() {
Vector3 velocity = GetComponent<Rigidbody>().velocity;
float jumpSpeed = 1f;
if (Input.GetButton ("Fire2") && gotFuel && chaseLimit > 0) {
jumpSpeed = thrust * chaseLimit;
jetpackUser.velocity = new Vector3 (velocity.x, jumpSpeed, velocity.z);
inAir = true;
isFlying = true;
} else {

isFlying = false;
}

}

float CalculateJumpVerticalSpeed () {
// From the jump height and gravity we deduce the upwards speed
// for the character to reach at the apex.
return Mathf.Sqrt(2 * jumpHeight * gravity);
}
}
Loading