Skip to content
Snippets Groups Projects
Commit c17e65eb authored by BenniHome's avatar BenniHome
Browse files

Added Points and began Pythagoras Input

parent 4a1df0b9
No related branches found
No related tags found
No related merge requests found
Showing
with 314 additions and 60 deletions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DistanceDisplayScript : MonoBehaviour
{
public LengthObject fact;
public TextMeshProUGUI PointOne;
public TextMeshProUGUI PointTwo;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
PointOne.text = fact.PointA;
PointTwo.text = fact.PointB;
}
void setfact(LengthObject f){
this.fact = f;
}
}
fileFormatVersion: 2
guid: eec83b50c1e0c604aa91430f72c8dbb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -2,12 +2,16 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class DisplayFacts : MonoBehaviour
{
public Inventory inventory;
public GameObject prefab;
public GameObject prefab_Point;
public GameObject prefab_Distance;
public GameObject prefab_Angle;
public GameObject prefab_Default;
public int x_Start;
public int y_Start;
......@@ -30,10 +34,9 @@ public void UpdateDisplay()
{
for( int i = 0; i< inventory.Facts.Count; i++){
if(! inventory.Facts[i].isDisplayed){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
var item = inventory.Facts[i].item;
var obj = item.CreateDisplay(transform, getPrefab( item));
obj.GetComponent<RectTransform>().localPosition = GetPosition(i);
//obj.transform.FindChild("PointOne").text = "X";
//obj.transform.FindChild("PointTwo").text = "Y";
inventory.Facts[i].isDisplayed = true;
}
......@@ -44,4 +47,13 @@ public Vector3 GetPosition(int i)
{
return new Vector3(x_Start+ (X_Pacece_Between_Items * (i % number_of_Column)), y_Start + (-y_Pacece_Between_Items * (i / number_of_Column)), 0f);
}
public GameObject getPrefab(ItemObject item){
switch( item.type){
case ItemObject.ItemType.LengthFact:return prefab_Distance;
case ItemObject.ItemType.AngleFact: return prefab_Angle;
case ItemObject.ItemType.Point: return prefab_Point;
default: return prefab_Default;
}
}
}
......@@ -7,7 +7,6 @@ public class DisplayScrolls : MonoBehaviour
{
public Inventory inventory;
public GameObject prefab;
public int x_Start;
public int y_Start;
......@@ -30,7 +29,8 @@ public void UpdateDisplay()
{
for( int i = 0; i< inventory.Scrolls.Count; i++){
if(! inventory.Scrolls[i].isDisplayed){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
var item = inventory.Scrolls[i].item;
var obj = Instantiate(item.IconPrefab, Vector3.zero, Quaternion.identity, transform);
obj.GetComponent<RectTransform>().localPosition = GetPosition(i);
obj.GetComponentInChildren<Text>().text = inventory.Scrolls[i].item.Description;
inventory.Scrolls[i].isDisplayed = true;
......
......@@ -5,25 +5,25 @@
[CreateAssetMenu(fileName = "New Inventory", menuName= "Inventory System/Inventory" )]
public class Inventory : ScriptableObject
{
public List<InventorySlot> Facts = new List<InventorySlot>();
public List<InventorySlot> Scrolls = new List<InventorySlot>();
public List<InventorySlot<ItemObject>> Facts = new List<InventorySlot<ItemObject>>();
public List<InventorySlot<DefaultScroll>> Scrolls = new List<InventorySlot<DefaultScroll>>();
public void AddFact(ItemObject fact){
Facts.Add(new InventorySlot(fact));
Facts.Add(new InventorySlot<ItemObject>(fact));
}
public void AddScroll(ItemObject scroll){
Scrolls.Add(new InventorySlot(scroll));
public void AddScroll(DefaultScroll scroll){
Scrolls.Add(new InventorySlot<DefaultScroll>(scroll));
}
}
[System.Serializable]
public class InventorySlot
public class InventorySlot<T>
{
public ItemObject item;
public T item;
public bool isDisplayed;
public InventorySlot( ItemObject _item){
public InventorySlot( T _item){
item = _item;
isDisplayed = false;
}
......
......@@ -12,5 +12,3 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 14aa6bfc325535540999d9ee4927d556, type: 3}
m_Name: THE_INVENTORY
m_EditorClassIdentifier:
Facts: []
Scrolls: []
Assets/InventoryStuff/Items/images/Angle.png

129 B | W: | H:

Assets/InventoryStuff/Items/images/Angle.png

129 B | W: | H:

Assets/InventoryStuff/Items/images/Angle.png
Assets/InventoryStuff/Items/images/Angle.png
Assets/InventoryStuff/Items/images/Angle.png
Assets/InventoryStuff/Items/images/Angle.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -86,7 +86,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID: 4052110779d2c57468e5a62b993c6106
spriteID: 9af3561794fbc3c498c65122a71ed0ab
vertices: []
indices:
edges: []
......
Assets/InventoryStuff/Items/images/Point.png

129 B

fileFormatVersion: 2
guid: 61c389e99e8388e4e93070d2f5e6275f
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: f3b5ca21d35dcb943afb89c4af81b2f0
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Assets/InventoryStuff/Items/images/Pythagoras-form.png

130 B

fileFormatVersion: 2
guid: 9bd557fba9781c641bd2c93207499e81
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: e8b9ad55c552aee499fc7c5566df78aa
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[CreateAssetMenu(fileName = "new DefaultObject", menuName = "Inventory System/Items/Angle")]
public class AngleObject : ItemObject
{
......@@ -13,4 +14,12 @@ public void Awake()
{
type = ItemType.AngleFact;
}
//prefab should be "AngleDisplay"
public override GameObject CreateDisplay(Transform transform, GameObject prefab){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = pointA;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = pointB;
obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = pointC;
return obj;
}
}
......@@ -8,4 +8,10 @@ public void Awake()
{
type = ItemType.Default;
}
//prefab should be "DefaultObjectDisplay"
public override GameObject CreateDisplay(Transform transform, GameObject prefab){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
return obj;
}
}
......@@ -4,8 +4,18 @@
[CreateAssetMenu(fileName = "new DefaultScroll", menuName = "Inventory System/Items/DefaultScroll")]
public class DefaultScroll : ItemObject
{
public GameObject IconPrefab;
public GameObject UsagePrefab;
public void Awake()
{
type = ItemType.DefaultScroll;
}
//prefab should be "DefaultScrollDisplay"
public override GameObject CreateDisplay(Transform transform, GameObject prefab){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
return obj;
}
}
......@@ -2,16 +2,19 @@
using System.Collections.Generic;
using UnityEngine;
public enum ItemType{
LengthFact,
AngleFact,
DefaultScroll,
Default
}
public class ItemObject : ScriptableObject
public abstract class ItemObject : ScriptableObject
{
//public GameObject prefab;
public enum ItemType{
LengthFact,
AngleFact,
DefaultScroll,
Point,
Default
};
public ItemType type;
[TextArea(15,20)]
public string Description;
public abstract GameObject CreateDisplay(Transform transform, GameObject prefab);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[CreateAssetMenu(fileName = "new DefaultObject", menuName = "Inventory System/Items/Length")]
public class LengthObject : ItemObject
{
public string PointA;
public string PointB;
public string pointA;
public string pointB;
public double Lenght;
......@@ -13,4 +14,12 @@ public void Awake()
{
type = ItemType.LengthFact;
}
//prefab should be "LengthDisplay"
public override GameObject CreateDisplay(Transform transform, GameObject prefab){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = pointA;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = pointB;
return obj;
}
}
......@@ -3,7 +3,9 @@ guid: bc65288d8a9b7f343a6e221e4bdba74c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- prefab: {fileID: 4221381813544557775, guid: 8106c748f1aeb084d87fdc71dd009b67,
type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[CreateAssetMenu(fileName = "new PointObject", menuName = "Inventory System/Items/Point")]
public class PointObject : ItemObject
{
public string point;
public void Awake()
{
type = ItemType.Point;
}
//prefab should be "LengthDisplay"
public override GameObject CreateDisplay(Transform transform, GameObject prefab){
var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = point;
return obj;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: ab51f8628e4c07449aa2844882114144
guid: e50bfc6d769196d4e836ba779a6995ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment