test
testing
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
//EnableHelper used to interact between C# and JS
|
||||
//Create empty game object and tag it "EnableHelper"
|
||||
//When this object active, assigned scripts are enabled
|
||||
//Once we deactivate this object, all script become disabled aswell
|
||||
//Usefull for pausing game without changing timeScale
|
||||
|
||||
#pragma strict
|
||||
import System.Collections.Generic;
|
||||
|
||||
var fpsController : FPScontroller;
|
||||
var weaponManager : WeaponManager;
|
||||
//Assign 2 mouse looks
|
||||
var mouseLook1 : FPSMouseLook;
|
||||
var mouseLook2 : FPSMouseLook;
|
||||
|
||||
private var enablerReferenceObject : GameObject;
|
||||
|
||||
function Start () {
|
||||
enablerReferenceObject = gameObject.FindWithTag("EnableHelper").gameObject;
|
||||
}
|
||||
|
||||
function Update () {
|
||||
//Reference object is enabled, enable all assigned scripts
|
||||
if(enablerReferenceObject && enablerReferenceObject.active == true){
|
||||
if(fpsController.canControl == false){
|
||||
fpsController.canControl = true;
|
||||
}
|
||||
if(weaponManager.enabled == false && weaponManager.SelectedWeapon && weaponManager.SelectedWeapon.enabled == false){
|
||||
weaponManager.enabled = true;
|
||||
weaponManager.SelectedWeapon.enabled = true;
|
||||
}
|
||||
if(mouseLook1.enabled == false && mouseLook2.enabled == false){
|
||||
mouseLook1.enabled = true;
|
||||
mouseLook2.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Reference object is disabled, deactivate all assigned scripts
|
||||
if(!enablerReferenceObject || enablerReferenceObject.active == false){
|
||||
if(fpsController.canControl == true ){
|
||||
fpsController.canControl = false;
|
||||
}
|
||||
if(weaponManager.enabled == true && weaponManager.SelectedWeapon && weaponManager.SelectedWeapon.enabled == true){
|
||||
weaponManager.SelectedWeapon.enabled = false;
|
||||
weaponManager.enabled = false;
|
||||
}
|
||||
if(mouseLook1.enabled == true && mouseLook2.enabled == true){
|
||||
mouseLook1.enabled = false;
|
||||
mouseLook2.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!enablerReferenceObject && gameObject.FindWithTag("EnableHelper").gameObject != null){
|
||||
enablerReferenceObject = gameObject.FindWithTag("EnableHelper").gameObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bda6d37470bc9374ba19cf642d57eb5c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,186 @@
|
||||
//NSdesignGames @ 2012
|
||||
//FPS Kit | Version 2.0
|
||||
|
||||
#pragma strict
|
||||
import System.Collections.Generic;
|
||||
|
||||
var guiStyle : GUISkin;
|
||||
var objective : String;
|
||||
var showTime : boolean = true;
|
||||
|
||||
@HideInInspector
|
||||
var finishedGame : boolean;
|
||||
private var weaponManager : WeaponManager;
|
||||
private var startGame : boolean = true;
|
||||
private var timer : float;
|
||||
private var mainMenu : boolean;
|
||||
private var resolutions : Resolution[];
|
||||
private var QualityNames : String[];
|
||||
private var resolutionIndex : int = 3;
|
||||
private var scroll : Vector2;
|
||||
private var scroll2 : Vector2;
|
||||
private var scroll3 : Vector2;
|
||||
private var niceTime : String;
|
||||
|
||||
function Start () {
|
||||
weaponManager = GameObject.FindWithTag("WeaponManager").GetComponent.<WeaponManager>();
|
||||
mainMenu = true;
|
||||
Invoke("Pause", 0.01);
|
||||
resolutions = Screen.resolutions;
|
||||
resolutionIndex = (resolutions.Length-1)/2;
|
||||
QualityNames = QualitySettings.names;
|
||||
}
|
||||
|
||||
function Update () {
|
||||
if(startGame && weaponManager.SelectedWeapon){
|
||||
weaponManager.SelectedWeapon.gameObject.SetActiveRecursively(false);
|
||||
}
|
||||
if(!startGame){
|
||||
if(!finishedGame){
|
||||
timer += Time.deltaTime;
|
||||
}
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.Tab)){
|
||||
mainMenu = !mainMenu;
|
||||
Pause();
|
||||
}
|
||||
|
||||
if(!mainMenu){
|
||||
Screen.lockCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.P)){
|
||||
Screen.fullScreen = !Screen.fullScreen;
|
||||
if(!Screen.fullScreen){
|
||||
Screen.SetResolution(resolutions[resolutionIndex].width, resolutions[resolutionIndex].height, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnGUI(){
|
||||
GUI.skin = guiStyle;
|
||||
|
||||
GUI.color.a = 0.7;
|
||||
//Timer
|
||||
var minutes : int = Mathf.FloorToInt(timer / 60F);
|
||||
var seconds : int = Mathf.FloorToInt(timer - minutes * 60);
|
||||
niceTime = String.Format("{0:0}:{1:00}", minutes, seconds);
|
||||
if(showTime){
|
||||
if(!finishedGame){
|
||||
GUI.Box(new Rect(Screen.width/2 - 50,40,100,30), niceTime);
|
||||
}else{
|
||||
GUI.Box(new Rect(Screen.width/2 - 100,40,200,30), "Your Time | " + niceTime);
|
||||
}
|
||||
}
|
||||
|
||||
if(mainMenu){
|
||||
GUI.Window (0, Rect (Screen.width/2 - 250, Screen.height/2 - 150, 500, 300), MainMenu, "Main Menu");
|
||||
GUI.Window (1, Rect (Screen.width/2-240, Screen.height/2 - 100, 150, 100), Resolutions, "Resolution");
|
||||
GUI.Window (2, Rect (Screen.width/2-85, Screen.height/2 - 100, 150, 100), QualityWindow, "Quality");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function MainMenu (windowID : int) {
|
||||
GUILayout.Space (10);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Box(resolutions[resolutionIndex].width + " x " + resolutions[resolutionIndex].height, GUILayout.Width(150), GUILayout.Height(20));
|
||||
|
||||
GUILayout.Box(QualityNames[QualitySettings.GetQualityLevel ()], GUILayout.Width(150), GUILayout.Height(20));
|
||||
|
||||
|
||||
GUILayout.Space (15);
|
||||
if(startGame){
|
||||
if(GUILayout.Button("Start Game", GUILayout.Width(150), GUILayout.Height(30))){
|
||||
startGame = false;
|
||||
mainMenu = false;
|
||||
Pause();
|
||||
weaponManager.SelectedWeapon.gameObject.SetActiveRecursively(true);
|
||||
weaponManager.TakeFirstWeapon(weaponManager.SelectedWeapon.gameObject);
|
||||
}
|
||||
}else{
|
||||
GUILayout.BeginVertical();
|
||||
if(GUILayout.Button("Restart Game", GUILayout.Width(150), GUILayout.Height(30))){
|
||||
Time.timeScale = 1;
|
||||
Application.LoadLevel(0);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space (90);
|
||||
GUI.color = Color(0, 20, 0, 0.6);
|
||||
if(!finishedGame){
|
||||
//GUILayout.Label("Objective: Find secret room using less time");
|
||||
GUILayout.Label(objective);
|
||||
}else{
|
||||
GUILayout.Label("Objective: Completed with time: " + niceTime + " min");
|
||||
}
|
||||
GUILayout.Space (5);
|
||||
GUI.color = Color.white;
|
||||
scroll3 = GUILayout.BeginScrollView(scroll3, GUILayout.Width(480), GUILayout.Height(115));
|
||||
GUI.color = Color(20, 20,0, 0.6);
|
||||
GUILayout.Label("Tab - Main Menu");
|
||||
GUILayout.Label("Q - slow motion");
|
||||
GUILayout.Label("P - Fullscreen");
|
||||
GUILayout.Label("C - crouch");
|
||||
GUILayout.Label("Left Ctrl - prone");
|
||||
GUILayout.Label("LMB - fire");
|
||||
GUILayout.Label("RMB - aim");
|
||||
GUILayout.Label("F - weapon pick up");
|
||||
GUILayout.Label("R - reload");
|
||||
GUILayout.Label("Left Shift - run");
|
||||
GUILayout.Label("Space - jump");
|
||||
GUILayout.Label("1/2 - weapon change");
|
||||
GUILayout.Label("While selected STW-25 press G for flashlight");
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
function Resolutions(windowID : int){
|
||||
GUI.BringWindowToFront(windowID);
|
||||
scroll = GUILayout.BeginScrollView(scroll, GUILayout.Width(140), GUILayout.Height(75));
|
||||
GUILayout.BeginVertical();
|
||||
for(var a : int; a < resolutions.Length; a++){
|
||||
if(resolutions[a].width == Screen.width && resolutions[a].height == Screen.height){
|
||||
GUI.color = Color(0, 20, 20, 0.6);
|
||||
}else{
|
||||
GUI.color = Color(20, 20, 20, 0.6);
|
||||
}
|
||||
if(GUILayout.Button(resolutions[a].width + " x " + resolutions[a].height)){
|
||||
resolutionIndex = a;
|
||||
if(Screen.fullScreen){
|
||||
Screen.SetResolution (resolutions[resolutionIndex].width,resolutions[resolutionIndex].height, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
function QualityWindow(windowID : int){
|
||||
GUI.BringWindowToFront(windowID);
|
||||
scroll2 = GUILayout.BeginScrollView(scroll2, GUILayout.Width(140), GUILayout.Height(75));
|
||||
GUILayout.BeginVertical();
|
||||
for (var i = 0; i < QualityNames.Length; i++){
|
||||
if(QualityNames[i] == QualityNames[QualitySettings.GetQualityLevel ()]){
|
||||
GUI.color = Color(0, 20, 20, 0.6);
|
||||
}else{
|
||||
GUI.color = Color(20, 20, 20, 0.6);
|
||||
}
|
||||
if (GUILayout.Button (QualityNames[i]))
|
||||
QualitySettings.SetQualityLevel (i, true);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
function Pause(){
|
||||
if(mainMenu){
|
||||
Time.timeScale = 0.0001;
|
||||
Screen.lockCursor = false;
|
||||
}else{
|
||||
Time.timeScale = 1;
|
||||
Screen.lockCursor = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e1d6e920c6be1d41b60a009c430f70a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,49 @@
|
||||
//NSdesignGames @ 2012
|
||||
//FPS Kit | Version 2.0
|
||||
|
||||
#pragma strict
|
||||
|
||||
var slowMotion : boolean;
|
||||
//How much should we slow time
|
||||
//Recomended values from 0.2 to 0.9
|
||||
var guiSkin : GUISkin;
|
||||
var slowTimeTo : float = 0.5;
|
||||
|
||||
@HideInInspector
|
||||
var audios : AudioSource[];
|
||||
|
||||
function Start () {
|
||||
|
||||
}
|
||||
|
||||
function Update () {
|
||||
if(Time.timeScale < 0.01)
|
||||
return;
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.Q)){
|
||||
slowMotion = !slowMotion;
|
||||
}
|
||||
|
||||
if(slowMotion){
|
||||
audios = FindObjectsOfType(AudioSource) as AudioSource[];
|
||||
for (var i = 0; i < audios.Length; i++){
|
||||
audios[i].pitch = slowTimeTo;
|
||||
}
|
||||
Time.timeScale = slowTimeTo;
|
||||
Time.fixedDeltaTime = 0.005;
|
||||
}
|
||||
else if(!slowMotion && Time.deltaTime != 1){
|
||||
audios = FindObjectsOfType(AudioSource) as AudioSource[];
|
||||
for (var a = 0; a < audios.Length; a++){
|
||||
audios[a].pitch = 1;
|
||||
}
|
||||
Time.timeScale = 1;
|
||||
Time.fixedDeltaTime = 0.02;
|
||||
}
|
||||
}
|
||||
|
||||
function OnGUI(){
|
||||
GUI.skin = guiSkin;
|
||||
GUI.color.a = 0.8;
|
||||
GUI.Box(Rect(Screen.width-205, 60, 200, 30), "Slow Mo: " + slowMotion.ToString());
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70f41bcd87b209b4b922cc992145b9e6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,49 @@
|
||||
//NSdesignGames @ 2012
|
||||
//FPS Kit | Version 2.0
|
||||
|
||||
#pragma strict
|
||||
|
||||
var guiStyle : GUISkin;
|
||||
var weaps : GameObject;
|
||||
var teleportPoint : Transform;
|
||||
var mm : MainMenu;
|
||||
|
||||
private var inside : boolean;
|
||||
|
||||
function OnTriggerEnter(weapon : Collider){
|
||||
//Detect if we on pickable weapon
|
||||
if(weapon.gameObject.tag == "Player"){
|
||||
inside = true;
|
||||
}
|
||||
}
|
||||
|
||||
function OnTriggerExit(weapon : Collider){
|
||||
if(weapon.gameObject.tag == "Player"){
|
||||
inside = false;
|
||||
}
|
||||
}
|
||||
|
||||
function Update(){
|
||||
if(inside){
|
||||
if(Input.GetKeyDown(KeyCode.F)){
|
||||
GameObject.FindWithTag("Player").transform.position = teleportPoint.position;
|
||||
GameObject.FindWithTag("Player").transform.rotation = teleportPoint.rotation;
|
||||
inside = false;
|
||||
weaps.SetActiveRecursively(true);
|
||||
mm.finishedGame = true;
|
||||
RenderSettings.fog = false;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function OnGUI(){
|
||||
if(!inside)
|
||||
return;
|
||||
GUI.skin = guiStyle;
|
||||
GUI.color.a = 0.9;
|
||||
GUI.depth = -10;
|
||||
var text : String = "Press ´F´ for MORE GUNS! ";
|
||||
var rect : Rect = Rect (Screen.width/2 - text.Length*9/2,Screen.height/2 - 25,text.Length*9,50);
|
||||
GUI.Box (rect, text);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81a0b172b1a8efd4c947788984213bfa
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in New Issue
Block a user