Skip to content

Instantly share code, notes, and snippets.

@vjgrayman
Last active July 24, 2019 12:25
Show Gist options
  • Save vjgrayman/72bfa3ee31a4bdd7255e8c45d88fe136 to your computer and use it in GitHub Desktop.
Save vjgrayman/72bfa3ee31a4bdd7255e8c45d88fe136 to your computer and use it in GitHub Desktop.
[CSharpSurviver_5]#CSharp
// vim: syntax=CSharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Item
{
[SerializeField]
public string name;
public int id;
public string description;
public Sprite icon;
//This is Item Constructor Method
public Item()
{
}
public Item(string name, int id, string description)
{
this.name = name;
this.id = id;
this.description = description;
}
}
// vim: syntax=CSharp
// Script file should be in "Empty GameObject(named ItemDatabase)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemDatabase : MonoBehaviour
{
public Item[] items;
/*
public Item sword;
public Item hammer;
public Item bread;
*/
// Start is called before the first frame update
void Start()
{
Debug.Log(items[0].name);
/*
sword = new Item();
sword.name = "Sword";
sword.id = 1;
sword.description = "This is a sword!";
// 상위 클라스에 콘스트럭터를 만들어 두면 아래처럼 직접입력 가능
hammer = new Item("Hammer", 2, "This is a Hammer!");
bread = CreateItem("Bread", 3, "I can eat this.");
*/
}
/*
private Item CreateItem(string name, int id, string description)
{
var item = new Item(name, id, description);
return item;
}
*/
}
// vim: syntax=CSharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Customers
{
// [SerializeField]
public string firstName;
public string lastName;
public int age;
public string gender;
public string occupation;
public Customers(string first, string last, int age, string gender, string occupation)
{
this.firstName = first;
this.lastName = last;
this.age = age;
this.gender = gender;
this.occupation = occupation;
}
}
// vim: syntax=CSharp
// On Empty GameObject(named: CustomerDataBase)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CustomerDatabase : MonoBehaviour
{
public Customers jonnathan;
public Customers jannet;
public Customers eric;
// Start is called before the first frame update
void Start()
{
jonnathan = new Customers("Jonnathan", "Weinberger", 26, "M", "Software Engineer");
jannet = new Customers("Jannet", "Lee", 30, "F", "Instructor");
eric = new Customers("Eric", "Brown", 21, "M", "Artist");
}
// Update is called once per frame
void Update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment