Commit 2016919c authored by Zami's avatar Zami

added supporting files

parent ceecfe4c
# CP 2019-20
Blog Link: https://zorrozami.wixsite.com/mysite
Uploaded whole game (355mb) to test game just download the zip files
Upladed all the Scripts I wrote
Uploaded all Sound tracks i wrote
Uploaded both the scenes I made
Uploaded Unity Version Controll history / commit history pdf since dashboard cant be made public
Uploaded all resource references txt
** Model and Animation For Character - https://www.mixamo.com/#/?page=1&query=walk&type=Motion%2CMotionPack
** Watch - https://www.youtube.com/watch?v=5ozKp5qC4aA
https://www.youtube.com/watch?v=U0dlWhB_e0E
**Health Obj source - https://sketchfab.com/3d-models/rpg-health-relic-work-in-progress-4b6dc3367e514d25ab1c776232b80810
** Hit Particle Source - https://www.google.com/search?q=sparkle+png&client=opera&hs=3kx&sxsrf=ALeKk003shj5akF_KlIYcieXlQ7hYIlpHg:1591929920129&source=lnms&tbm=isch&sa=X&ved=2ahUKEwj44pWLofvpAhULSRUIHRiTDssQ_AUoAXoECA8QAw&biw=1880&bih=949#imgrc=y9LhNS3-bNJqyM
**PLayer hit sfx : https://freesound.org/people/shelbyshark/sounds/444703/
**player Footstep sfx: https://freesound.org/people/InspectorJ/sounds/397946/
**Sword SFX1: https://freesound.org/people/Streety/sounds/30248/
**Sword SFX2: https://freesound.org/people/LukeSharples/sounds/209081/
**Sword SFX3: https://freesound.org/people/byronabadia/sounds/444950/
**Enemy hit SFX: https://freesound.org/people/florianreichelt/sounds/460509/
**Enemy Death / score SFX: https://freesound.org/people/Scrampunk/sounds/345297/
File added
File added
File added
File added
File added
This diff is collapsed.
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
//Adapted from: https://www.youtube.com/watch?v=gXpi1czz5NA&t=1001s
public class EnemyAI : MonoBehaviour
{
// Start is called before the first frame update
public Transform player;
private Animator anim;
public Slider healthBar;
public static bool isHit;
public bool isAlive;
public ParticleSystem hitEffect; //particle system
public AudioSource hitSFX;
public AudioClip hit;
public AudioClip score;
//Animator enemyAnims;
void Start()
{
anim = GetComponent<Animator>();
isAlive = true;
}
// Update is called once per frame
void Update()
{
if(healthBar.value <= 0)
{
return;
}
Vector3 direction = player.position - this.transform.position;
float angle = Vector3.Angle(direction, this.transform.position);
if (Vector3.Distance( player.position, this.transform.position)< 20)//DETECTION RANGE
{
direction.y = 0;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
Quaternion.LookRotation(direction), 0.08f); // ROTATION / LOOK TOWARDS PLAYER SPEED
anim.SetBool("idle", false);
if(direction.magnitude > 6) // When distance from player is greater than 6 AI runs
{
this.transform.Translate(0, 0, 0.07f);
anim.SetBool("run", true);
anim.SetBool("attack", false);
anim.SetBool("walk", false);
anim.SetBool("hit", false);
}
else if (direction.magnitude >= 4)
{
this.transform.Translate(0, 0, 0.03f);// When distance from player is greater than 6 AI Walks
anim.SetBool("run", false);
anim.SetBool("attack", false);
anim.SetBool("walk", true);
anim.SetBool("hit", false);
}
else if(direction.magnitude >=2)
{
this.transform.Translate(0, 0, 0.02f);// When distance from player is greater than 6 AI Attacks
anim.SetBool("attack", true);
anim.SetBool("walk", false);
anim.SetBool("run", false);
anim.SetBool("hit", false);
}
else if( isHit == true)
{
anim.SetBool("hit", true);
anim.SetBool("attack", false);
anim.SetBool("walk", false);
anim.SetBool("run", false);
hitEffect.Play();
hitSFX.clip = hit;
hitSFX.Play();
}
}
else
{
anim.SetBool("idle", true);
anim.SetBool("walk", false);
anim.SetBool("attack", false);
anim.SetBool("run", false);
anim.SetBool("hit", false);
}
}
private void OnTriggerEnter(Collider enemy)
{
if (isAlive == true)
{
if (enemy.gameObject.tag == "swords")//Take Damage when hit by GameObjects tagged "swords" <---Weapons
{
Debug.Log("HITTING");
isHit = true; //Triggers the getting hit animation on hit
healthBar.value -= 25;
}
else if(enemy.gameObject.tag == "magicBalls")
{
Debug.Log("MAGICCCCCC");
isHit = true;
healthBar.value -= 75;
}
else
{
isHit = false;
}
if (healthBar.value <= 0)//When health is <= 0 triggers death animation and sets alive state to false
{
anim.SetBool("isDead", true);
isAlive = false;
hitSFX.clip = score;
hitSFX.Play();
}
}
//try is dead is true as well*********
else if (!isAlive) //When alive state is false i.e. the bot dies call in the "Score" script and add 100 to the default score value <--- Score system
{
Score.defaultScore += 100; //Importing the Score Script so that it gets activated everytime an AI bot Dies
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movements : MonoBehaviour
{
// Start is called before the first frame update
public Animator anim;
void Start()
{
anim.SetFloat("vertical", Input.GetAxis("Vertical"));
anim.SetFloat("horizontal", Input.GetAxis("Horizontal"));
}
// Update is called once per frame
void Update()
{
if(Input.GetKey("w"))
{
anim.SetFloat("vertical", 0);
}
else if (Input.GetKeyUp("w")){
anim.SetFloat("vertical", 1);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
//Used this Script In a seperate Cylinder Collider for the player object instead of adding it directly to the player object is because if added directly to the player object it causes problem with detection when enemy hits the shield, causing player to take damage through the shield
public class PlayerHealth : MonoBehaviour
{
public Slider playerHealth;
public AudioSource hitAudio;
public GameObject loseMassege;
public GameObject winMassege;
public GameObject instructions;
public string menuScreen;
void Start()
{
playerHealth.value = 200;
loseMassege.SetActive(false);
winMassege.SetActive(false);
instructions.SetActive(true);
}
// Update is called once per frame
void Update()
{
StartCoroutine("WaitForInstructions");
if(playerHealth.value <= 0)
{
Debug.Log("player dead");
loseMassege.SetActive(true);
StartCoroutine("WaitForSec");
}
if(Score.defaultScore >= 800)
{
Debug.Log("player Win");
winMassege.SetActive(true);
StartCoroutine("WaitForSec");
}
}
private void OnTriggerEnter(Collider player)
{
if(player.gameObject.tag == "enemy")
{
playerHealth.value -= 25;
hitAudio.Play();
}
}
IEnumerator WaitForSec()
{
yield return new WaitForSeconds(3);
Destroy(loseMassege);
SceneManager.LoadScene(menuScreen);
Cursor.lockState = CursorLockMode.None;
yield return new WaitForSeconds(5);
instructions.SetActive(false);
}
IEnumerator WaitForInstructions()
{
yield return new WaitForSeconds(5);
Destroy(instructions);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Code Ref: https://www.firemind-academy.com/p/create-healthbar-in-3d-space-unity/
public class PlayerViewLock : MonoBehaviour
{
// Start is called before the first frame update
public Camera player;
void Start()
{
}
// Update is called once per frame
void Update() //Rotates the enemy healthBar based on and to face the Player
{
Vector3 lookDir = player.transform.position - transform.position;
lookDir.x = lookDir.z = 0.0f;
transform.LookAt(player.transform.position - lookDir);
transform.Rotate(0, 0, 0); //Look Angle
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
// Start is called before the first frame update
public static int defaultScore;
public Text score;
void Start()
{
score.GetComponent<Text>();
defaultScore = 0;
}
// Update is called once per frame
void Update()
{
score.text = "Score : " + defaultScore;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class healthPicked : MonoBehaviour
{
public Slider healthBar;
private void OnTriggerEnter(Collider health)
{
if(health.gameObject.tag == "Player") //Disappears when picked
{
this.gameObject.SetActive(false);
healthBar.value += 50;
Debug.Log("HPUP");
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class menu : MonoBehaviour
{
// Start is called before the first frame update
public string gameScene;
public void Play()
{
SceneManager.LoadScene(gameScene);
}
public void Exit()
{
Application.Quit();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mousex = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; //to adjust speed based on the last time the update functon was called
float mousey = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mousey;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mousex);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pickUp : MonoBehaviour
{
public GameObject picked;
public GameObject pick;
public GameObject pickedKatana;
public GameObject pickKatana;
public GameObject pickedDarkSword;
public GameObject pickDarkSword;
public GameObject pickedModernSword;
public GameObject pickModernSword;
public GameObject shieldPickUp;
public GameObject shieldPicked;
public bool isEquipped;
// Start is called before the first frame update
void Start()//Primarily deacivating all puickupable and usable objects
{
picked.SetActive(false);
pickedKatana.SetActive(false);
pickedDarkSword.SetActive(false);
pickedModernSword.SetActive(false);
shieldPicked.SetActive(false);
}
private void OnTriggerEnter(Collider weaponCollider)
{
if (isEquipped || !isEquipped) //Calling these conditions while in or not in Equipped state so that, player can pick another weapon while player is equipped or is not
{
if (weaponCollider.gameObject.tag == "pickupObj") //Picks up the sword Tagged "pickupObj" and deactivates the rests ---> similar goes for The next weapons
{
picked.SetActive(true); // makes picked up weapon visible on hand
pick.SetActive(false);// makes picked up weapon invisible from Pickup location
pickedKatana.SetActive(false);
pickedDarkSword.SetActive(false);
pickedModernSword.SetActive(false);
isEquipped = true;
}
else if (weaponCollider.gameObject.tag == "katana")
{
pickedKatana.SetActive(true);
pickKatana.SetActive(false);
picked.SetActive(false);
pickedDarkSword.SetActive(false);
pickedModernSword.SetActive(false);
isEquipped = true;
}
else if (weaponCollider.gameObject.tag == "darkSword")
{
pickedDarkSword.SetActive(true);
pickDarkSword.SetActive(false);
picked.SetActive(false);
pickedKatana.SetActive(false);
pickedModernSword.SetActive(false);
isEquipped = true;
}
else if (weaponCollider.gameObject.tag == "bigSword")
{
pickedModernSword.SetActive(true);
pickModernSword.SetActive(false);
picked.SetActive(false);
pickedKatana.SetActive(false);
pickedDarkSword.SetActive(false);
isEquipped = true;
}
if(weaponCollider.gameObject.tag == "shield")
{
shieldPicked.SetActive(true);
shieldPickUp.SetActive(false);
isEquipped = true;
}
}
}
}
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shieldColToggle : MonoBehaviour
{
// Start is called before the first frame update
public Collider cols;
void Start()
{
cols = GetComponent<Collider>(); //gets the collider component of this GameObject
}
// Update is called once per frame
void Update() //updates everyframe so that the collider toggles and stays that way every frame Rigth mouse button is pressed
{
if (Input.GetMouseButtonDown(1))
{
cols.enabled = true;
}
else if (Input.GetMouseButtonUp(1))
{
cols.enabled = false;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Adapted from 2 tutorials : grabbing: https://www.youtube.com/watch?v=bA12WEA5MLo , thorwing: https://www.youtube.com/watch?v=_xMhkK6GTXA
public class throwObj : MonoBehaviour
{
RaycastHit grabRay;
GameObject grabAble;
public Transform grabPos;
public float force = 200;
public GameObject throwDirection;
public static bool magicState;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey("e") && Physics.Raycast(transform.position, transform.forward, out grabRay, 50) && grabRay.transform.GetComponent<Rigidbody>())
{
grabAble = grabRay.transform.gameObject;
magicState = true;
}
else if(Input.GetMouseButtonUp(0))
{
grabAble.GetComponent<Rigidbody>().AddForce(throwDirection.transform.forward*force) ;
grabAble = null;
magicState = false;
}
if (grabAble)
{
grabAble.GetComponent<Rigidbody>().velocity = (grabPos.position - grabAble.transform.position) * 50;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment