Last active
July 11, 2019 23:16
-
-
Save vjgrayman/83aacbd54aa703d79d0b119b3e77fec4 to your computer and use it in GitHub Desktop.
[CSharpSurvival] #CSharp
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public float quiz1, quiz2, quiz3, quiz4, quiz5; | |
public float average; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
quiz1 = Random.Range(0, 100); | |
quiz2 = Random.Range(0, 100); | |
quiz3 = Random.Range(0, 100); | |
quiz4 = Random.Range(0, 100); | |
quiz5 = Random.Range(0, 100); | |
average = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5) / 5; | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (average >= 90) | |
{ | |
Debug.Log("Grade is A"); | |
} | |
else if (average >= 80 && average < 90) | |
{ | |
Debug.Log("Grade is B"); | |
} | |
else if (average >= 70 && average < 80) | |
{ | |
Debug.Log("Grade is C"); | |
} | |
else if (average >= 60 && average < 70) | |
{ | |
Debug.Log("Grade is D"); | |
} | |
else | |
{ | |
Debug.Log("Grade is F"); | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public GameObject Cube; | |
public int score; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
Cube.GetComponent<Renderer>().material.color = Color.green; | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Space) && score <= 50) | |
{ | |
score += 10; | |
} | |
else if (score > 50) | |
{ | |
Cube.GetComponent<Renderer>().material.color = Color.red; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
[SerializeField] | |
private int _points = 0; | |
private bool _hasMessageBeenSent; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
_points += 10; | |
} | |
if (_points >= 50 && _hasMessageBeenSent == false) | |
{ | |
Debug.Log("You Are Awsome!"); | |
_hasMessageBeenSent = true; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class LuckyDraw_Test : MonoBehaviour | |
{ | |
public float luckyResult; | |
public int luckyResult2; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
luckyResult = Random.Range(1f, 300f); | |
luckyResult2 = Mathf.RoundToInt(luckyResult); | |
Debug.Log("Lucky Number is: " + luckyResult2); | |
} | |
if (Input.GetKeyDown(KeyCode.Backspace)) | |
{ | |
luckyResult2 = 0; | |
Debug.Log("Reset to Zero: " + luckyResult2); | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public int speed; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.S)) | |
{ | |
speed += 5; | |
} | |
if (Input.GetKeyDown(KeyCode.A)) | |
{ | |
speed -= 5; | |
} | |
if (Input.GetKeyDown(KeyCode.S) && speed > 20) | |
{ | |
Debug.Log("Slow Down"); | |
speed = 20; | |
} | |
if (Input.GetKeyDown(KeyCode.A) && speed <= 0) | |
{ | |
Debug.Log("Speed Up"); | |
speed = 0; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public int selectedLevel; | |
private int _easy = 0; | |
private int _medium = 1; | |
private int _hard = 2; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
selectedLevel = Random.Range(0, 3); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
/* | |
if (selectedLevel == _easy) | |
{ | |
Debug.Log("You Selected Easy"); | |
} | |
else if (selectedLevel == _medium) | |
{ | |
Debug.Log("You Selected Medium"); | |
} | |
else if (selectedLevel == _hard) | |
{ | |
Debug.Log("You Selected Hard"); | |
} | |
else | |
{ | |
Debug.Log("Invalid Level"); | |
} | |
*/ | |
switch (selectedLevel) | |
{ | |
case 0: | |
Debug.Log("Easy!"); | |
break; | |
case 1: | |
Debug.Log("Medium!"); | |
break; | |
case 2: | |
Debug.Log("Hard!"); | |
break; | |
default: | |
Debug.Log("Invalid Level!"); | |
break; | |
} | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
selectedLevel = Random.Range(0, 3); | |
} | |
if (Input.GetKeyDown(KeyCode.Q)) | |
{ | |
selectedLevel = 55; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public int points; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Q)) | |
{ | |
points = 50; | |
} | |
else if (Input.GetKeyDown(KeyCode.W)) | |
{ | |
points = 100; | |
} | |
else if (Input.GetKeyDown(KeyCode.E)) | |
{ | |
points = 0; | |
} | |
/* | |
if (points == 50) | |
{ | |
Debug.Log("Points are 50"); | |
} | |
else if (points == 100) | |
{ | |
Debug.Log("Points are 100"); | |
} | |
else | |
{ | |
Debug.Log("You need 50 or 100 to get Message"); | |
} | |
*/ | |
switch (points) | |
{ | |
case 50: | |
Debug.Log("Points are 50"); | |
break; | |
case 100: | |
Debug.Log("Points are 100"); | |
break; | |
default: | |
Debug.Log("You need 50 or 100 to get Message"); | |
break; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public GameObject Cube; | |
private int _nextColor; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
_nextColor = 4; | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Alpha1)) | |
{ | |
_nextColor = 0; | |
} | |
if (Input.GetKeyDown(KeyCode.Alpha2)) | |
{ | |
_nextColor = 1; | |
} | |
if (Input.GetKeyDown(KeyCode.Alpha3)) | |
{ | |
_nextColor = 2; | |
} | |
if (Input.GetKeyDown(KeyCode.Alpha4)) | |
{ | |
_nextColor = 3; | |
} | |
switch (_nextColor) | |
{ | |
case 0: | |
Cube.GetComponent<Renderer>().material.color = Color.blue; | |
break; | |
case 1: | |
Cube.GetComponent<Renderer>().material.color = Color.red; | |
break; | |
case 2: | |
Cube.GetComponent<Renderer>().material.color = Color.green; | |
break; | |
case 3: | |
Cube.GetComponent<Renderer>().material.color = Color.black; | |
break; | |
default: | |
Debug.Log("Invalid Selection"); | |
break; | |
} | |
} | |
} |
This file contains hidden or 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
// vim: syntax=CSharp | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Player : MonoBehaviour | |
{ | |
public int weaponID; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
switch (weaponID) | |
{ | |
case 1: | |
Debug.Log("Gun"); | |
break; | |
case 2: | |
Debug.Log("Knife"); | |
break; | |
case 3: | |
Debug.Log("Machine Gun"); | |
break; | |
default: | |
Debug.Log("Invalid Selection"); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment