-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Powar Version 2 is now available! Feature List: -AI Bot Feature! (There is an AI Bot in the game so that you won't get bored playing alone!) -Menu Screen (The game now starts with a Menu Screen where you can start the game, look at the amazing view, look at the tutorial or exit) -Game Over Screen (The game now shows a game over screen when one of the players win the game) -Colors! (Cubes now have colors on them to look more fancy!) -Tutorial Screen (You can now learn the skills from this screen) -2 New Abilities! (The game now has 2 new mechanics) -Dash (You can now dash forward to quickly hit your enemy) -Freeze (You can now freeze for 2 seconds in the game to juke the enemy) -Scoreboard (You can now track the score of the players) -Ability Cooldowns (You can now track the cooldowns of the abilities by looking at the images) -Platform Texture (The platform now has an icy texture to look like an ice mountain -It's still pretty far from being one though we need Modelling Artists) Fix List: -AI's problems are fixed (There were so many... I won't even try listing them) -The problem where some dashes wouldn't register is now fixed (FixedUpdate() is life!) -The bug that was causing AI to crash the game is now fixed -The missing texture problem after the freeze ability is now fixed
- Loading branch information
1 parent
9b34fa7
commit 47b4b7e
Showing
1,927 changed files
with
65,164 additions
and
54 deletions.
There are no files selected for viewing
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
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
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,160 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class AImovement : MonoBehaviour { | ||
|
||
public GameObject player; | ||
public float speed; | ||
public Vector3 playerorigin; | ||
public Vector3 AIorigin; | ||
public float targetdistance; | ||
public float distance; | ||
public Rigidbody rb; | ||
public float dashspeed; | ||
public bool dash; | ||
public bool freeze; | ||
public Image dashpng; | ||
public Image freezepng; | ||
public float dashcooldowntime; | ||
public bool dashcooldown; | ||
public bool freezecooldown; | ||
public float freezecooldowntime; | ||
public bool attackstate; | ||
public GameObject cube; | ||
public Material Frost; | ||
public Material red; | ||
public Material blu; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
rb = GetComponent<Rigidbody> (); | ||
speed = 0.3f; | ||
player = GameObject.FindGameObjectWithTag ("player1"); | ||
if (player != null) { | ||
playerorigin = player.transform.position; | ||
} | ||
AIorigin = transform.position; | ||
distance = 3f; | ||
dashspeed = 1; | ||
attackstate = true; | ||
dashpng.enabled = false; | ||
dashcooldowntime = 2; | ||
dashcooldown = true; | ||
freezepng.enabled = false; | ||
freezecooldowntime = 10; | ||
freezecooldown = false; | ||
} | ||
|
||
void Update(){ | ||
if (player == null) { | ||
player = GameObject.FindGameObjectWithTag ("player1"); | ||
} else { | ||
playerorigin = player.transform.position; | ||
AIorigin = transform.position; | ||
targetdistance = Vector3.Distance (playerorigin, AIorigin); | ||
} | ||
|
||
if(AIorigin.x > 6 && freezecooldown == false || AIorigin.x < -6 && freezecooldown == false){ | ||
freeze = true; | ||
freezecooldown = true; | ||
freezepng.enabled = true; | ||
|
||
}; | ||
if(AIorigin.z > 4 && freezecooldown == false || AIorigin.z < -8 && freezecooldown == false){ | ||
freeze = true; | ||
freezecooldown = true; | ||
freezepng.enabled = true; | ||
|
||
}; | ||
if (freeze) { | ||
StartCoroutine ("froze"); | ||
} | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate () { | ||
if (dashcooldown == true && dashcooldowntime > 0) { | ||
dashcooldowntime -= Time.deltaTime; | ||
dashpng.fillAmount = (dashcooldowntime / 5f); | ||
} else { | ||
dashcooldowntime = 5; | ||
dashcooldown = false; | ||
dashpng.enabled = false; | ||
} | ||
|
||
if (dash) { | ||
dashspeed = 40; | ||
dash = false; | ||
} else | ||
dashspeed = 1; | ||
|
||
if (freezecooldown == true && freezecooldowntime > 0) { | ||
freezecooldowntime -= Time.deltaTime; | ||
freezepng.fillAmount = (freezecooldowntime / 10f); | ||
} else { | ||
freezecooldowntime = 10; | ||
freezecooldown = false; | ||
freezepng.enabled = false; | ||
} | ||
|
||
if (player != null) { | ||
if (targetdistance > distance) { | ||
if (playerorigin.x - AIorigin.x > 0) { | ||
rb.AddForce (speed * dashspeed, 0, 0, ForceMode.VelocityChange); | ||
} else | ||
rb.AddForce (dashspeed * speed * -1, 0, 0, ForceMode.VelocityChange); | ||
if (playerorigin.z - AIorigin.z > 0) { | ||
rb.AddForce (0, 0, speed * dashspeed, ForceMode.VelocityChange); | ||
} else | ||
rb.AddForce (0, 0, dashspeed * speed * -1, ForceMode.VelocityChange); | ||
} else if (targetdistance < distance && dashcooldown == false) { | ||
dash = true; | ||
dashcooldown = true; | ||
dashpng.enabled = true; | ||
|
||
} else { | ||
if (Random.value >= 0.2f) { | ||
attackstate = true; | ||
} else | ||
attackstate = false; | ||
if (playerorigin.x - AIorigin.x > 0 && attackstate == true) { | ||
rb.AddForce (speed * dashspeed, 0, 0, ForceMode.VelocityChange); | ||
} else if (playerorigin.x - AIorigin.x > 0 && attackstate == false) { | ||
rb.AddForce (-1 * speed * dashspeed, 0, 0, ForceMode.VelocityChange); | ||
} else if (playerorigin.x - AIorigin.x < 0 && attackstate == true) | ||
rb.AddForce (dashspeed * speed * -1, 0, 0, ForceMode.VelocityChange); | ||
else if (playerorigin.x - AIorigin.x < 0 && attackstate == false) { | ||
rb.AddForce (dashspeed * speed, 0, 0, ForceMode.VelocityChange); | ||
} | ||
if (playerorigin.z - AIorigin.z > 0 && attackstate == true) { | ||
rb.AddForce (0, 0, speed * dashspeed, ForceMode.VelocityChange); | ||
} else if (playerorigin.z - AIorigin.z > 0 && attackstate == false) { | ||
rb.AddForce (0, 0, dashspeed * speed * -1, ForceMode.VelocityChange); | ||
} else if (playerorigin.z - AIorigin.z < 0 && attackstate == true) { | ||
rb.AddForce (0, 0, dashspeed * speed * -1, ForceMode.VelocityChange); | ||
} else if (playerorigin.z - AIorigin.z < 0 && attackstate == false) { | ||
rb.AddForce (0, 0, dashspeed * speed, ForceMode.VelocityChange); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
IEnumerator froze(){ | ||
rb.velocity = Vector3.zero; | ||
rb.angularVelocity = Vector3.zero; | ||
rb.isKinematic = true; | ||
cube.GetComponent<Renderer> ().material = Frost; | ||
yield return new WaitForSeconds (2); | ||
rb.isKinematic = false; | ||
freeze = false; | ||
if (cube.tag == "player1") { | ||
cube.GetComponent<Renderer> ().material = red; | ||
} else if (cube.tag == "player2") { | ||
cube.GetComponent<Renderer> ().material = blu; | ||
} | ||
} | ||
|
||
} |
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.
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.
Oops, something went wrong.