Skip to content

Instantly share code, notes, and snippets.

View SenpaiRar's full-sized avatar
🎯
Focusing

Tio Marello SenpaiRar

🎯
Focusing
View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class Weapon_Parent : MonoBehaviour {
public AudioSource Source;
//Player weapon uses the Weapon_Template Scriptable object to get data for the weapon
@SenpaiRar
SenpaiRar / Player_Cursor.cs
Created May 1, 2019 03:01
How the game handles the player clicking on the screen
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_Cursor : MonoBehaviour {
public Camera main_Camera;
public GameObject Player;
// Update is called once per frame
@SenpaiRar
SenpaiRar / Weapon_Template.cs
Created May 1, 2019 13:42
This is the template for all weapons. Every weapon in the game has these stats.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Weapon_Template", menuName = "Weapons/Template", order = 1)]
public class Weapon_Template : ScriptableObject {
public float Damage;
public float RateOfFire;
@SenpaiRar
SenpaiRar / Weapon_Pickup.cs
Last active May 1, 2019 22:44
This is the script for weapons that are on the ground
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapon_Pickup : ClickableParent {
public Weapon_Template thisWeaponData;
public float MinimumDistance;
public override void OnClick(Vector3 ClickPosition)
{
@SenpaiRar
SenpaiRar / Player_Manager.cs
Last active May 2, 2019 01:52
1. This was the old implementation of the modifier system
public void CheckStatsForDebuffs() //
{
Sluggishness();
ShortSightedness();
}
//Debuffs and Buffs
private void Sluggishness() //Every modifier was a function in the Player_Manager Script
{
if (current_Hunger_Level < 90) //Inside every function they had their threshold check, in this case checking if
@SenpaiRar
SenpaiRar / Modifier_Template.cs
Last active May 2, 2019 02:38
This is the parent class of all modifiers. Every modifier we make will inherit from this class. The second file is an example of a completed modifier which slows the player down.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Notice how this class doesnn't inherit from Monobehaviour. This means we can't add this to gameobjects
public abstract class Modifier_Template
{
//By making all of these abstract, we force every modifier to have these functions
public abstract float Attribute { get; set; } //This is a property. We're essentially force every child to have a float number variabled named Attribute
//This attribute property usage depends on the modifier, but generally, it tells the modifier by how much to change a stat in Player_Manager
@SenpaiRar
SenpaiRar / Modifier_Manager.cs
Last active May 2, 2019 04:13
The Modifer Manager is the script that takes every modifier and runs the four components inside each modifier.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Modifier_Manager : MonoBehaviour
{
public Player_Manager Player; //Every modifier needs a Player_Mangager, so we create one here instead of getting it for each modifier
public List<Modifier_Template> Debuffs = new List<Modifier_Template>(); //We create a list of modifiers
@SenpaiRar
SenpaiRar / FoodScript.cs
Created May 2, 2019 04:28
This script is an item script that replenishes the player's food and then deletes itself.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class FoodScript : ClickableParent {
public string Name;
public float food_Value;
public float MMinimumDistance;
@SenpaiRar
SenpaiRar / WaterScript.cs
Created May 2, 2019 04:29
This script is similar to the food script. It replenishes the player's water stat and then it deletes itself.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaterScript : ClickableParent {
public string Name;
public float water_Value;
public float MinimumDistance;
private Player_Manager Master_Manager;
@SenpaiRar
SenpaiRar / Crate.cs
Last active May 4, 2019 04:29
This is the code that handles Crates. Notice how it inherits from ClickableParent, giving it the ability to be clicked on.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Crate : ClickableParent
{
public List<GameObject> ItemsInside = new List<GameObject>(); //A list is a collection of objects that can be accessed through a numbered list. In this case it holds our prefabs (Picture 1)
public int NumberOfItemsToSpawn; //This decides how many times we loop in OnClick(); IE it decides how many objects to spawn
public float MinimumDistance;
public AudioClip Clip;