Created
May 4, 2012 04:45
-
-
Save monokrome/2592093 to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
using System.Collections; | |
public class EnergyCompressor : Weapon { | |
public virtual string GetDisplayName() { | |
return "energy compressor"; | |
} | |
} |
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
using UnityEngine; | |
using System.Collections; | |
public class Player : MonoBehaviour { | |
public const short max_weapons = 3; | |
public string defaultWeaponClass = "EnergyCompressor"; | |
public Weapon[] equippedWeapons; | |
public Weapon currentWeapon { | |
get { | |
if (equippedWeapons != null && equippedWeapons[0]) | |
return equippedWeapons[0]; | |
return null; | |
} | |
} | |
void Start() { | |
equippedWeapons = new Weapon[max_weapons]; | |
equippedWeapons[0] = (EnergyCompressor) ScriptableObject.CreateInstance(defaultWeaponClass); | |
} | |
void OnGUI() { | |
if (currentWeapon != null) | |
GUILayout.Label("Current weapon: " + currentWeapon.GetDisplayName()); | |
} | |
} |
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
using UnityEngine; | |
using System.Collections; | |
public class Weapon : ScriptableObject { | |
public virtual string GetDisplayName() { | |
return "unknown weapon"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment