public override void OnInspectorGUI() { PrefabDictionary dict = target as PrefabDictionary; EditorGUILayout.BeginVertical(); int tsize = EditorGUILayout.IntField("Size", dict.names.Count); if (tsize != dict.names.Count) { resizeArrays(tsize); } int digits = (dict.prefabs.Count > 0 ? (dict.prefabs.Count - 1) + "" : "0").Length; int pixels = 12; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(digits * pixels)); EditorGUILayout.LabelField("Key", GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField("Prefab", GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); for (int i = 0; i < dict.prefabs.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(i + "", GUILayout.Width(digits * pixels)); dict.names[i] = EditorGUILayout.TextField(dict.names[i]); dict.prefabs[i] = EditorGUILayout.ObjectField(dict.prefabs[i], typeof(GameObject), false) as GameObject; EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("+", GUILayout.Width(digits * pixels)); string newLabel = EditorGUILayout.TextField(string.Empty); if (!string.IsNullOrEmpty(newLabel)) { dict.Add(newLabel, null); } GameObject newPrefab = EditorGUILayout.ObjectField(null, typeof(GameObject), false) as GameObject; if (newPrefab != null) { dict.Add("key", newPrefab); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
public static PrefabDictionary Instance() { if (!prefabDictionary) { prefabDictionary = FindObjectOfType <PrefabDictionary>(); } return(prefabDictionary); }
/// <summary> /// The data that this block adds to the mesh /// </summary> /// <param name="chunk">Chunk the block is in</param> /// <param name="x">X pos of the block</param> /// <param name="y">Y pos of the block</param> /// <param name="z">Z pos of the block</param> /// <param name="meshData">meshdata to add to</param> /// <param name="addToRenderMesh">should the block also be added to the render mesh not just the collsion mesh</param> /// <returns>Given <paramref name="meshData"/> with this blocks data added to it</returns> /// <remarks> /// Only adds to the colision mesh as the model is handlled by the unity prefab system /// </remarks> public override MeshData BlockData(Chunk chunk, int x, int y, int z, MeshData meshData, bool addToRenderMesh = true) { if (myGameobject == null) { myGameobject = UnityEngine.Object.Instantiate(PrefabDictionary.GetPrefab("CraftingTable"), new THVector3(x, y, z) + chunk.chunkWorldPos, Quaternion.identity, chunk.transform); } return(base.BlockData(chunk, x, y, z, meshData, true)); }
public void Fill() { items = UnityEditor.AssetDatabase.FindAssets("t:Prefab").Select(UnityEditor.AssetDatabase.GUIDToAssetPath) .Select(UnityEditor.AssetDatabase.LoadAssetAtPath <Object>) .ToList(); UnityEditor.EditorUtility.SetDirty(this); }
/// <summary> /// Returns the game object for this and gives the object the correct colouring /// </summary> /// <returns><see cref="GameObject"/> for <see cref="this"/></returns> public override GameObject GetGameObject() { GameObject obj = PrefabDictionary.GetPrefab("HoneyComb"); //* cannot acess the instance material from here have to do it on the obejct obj.GetComponent <ApplyColour>().colour = CombColour; return(obj); }
public void createDodgeText(Transform target) { Vector2 screenPosition = battleCamera.WorldToScreenPoint(target.position); GameObject go = Instantiate(PrefabDictionary.Instance().DodgeText); go.transform.SetParent(battleCanvas, false); go.transform.position = screenPosition; }
public override GameObject GetGameObject() { var go = PrefabDictionary.GetPrefab("Bee"); go.GetComponent <SetBeeGOColours>().colour = BeeDictionaries.GetBeeColour(normalBee?.pSpecies ?? queenBee.queen.pSpecies); go.GetComponent <SetBeeGOColours>().beeType = beeType; return(go); }
/// <summary> /// Loads the sprites and prefab dictionarys /// </summary> void Awake() { Serialization.Serialization.MakeDirectorys(); Serialization.Serialization.LoadPlayerPosition(GameObject.Find("Player").GetComponent <Transform>()); Serialization.Serialization.LoadQuests(); SpriteDictionary.LoadSprites(); PrefabDictionary.LoadPrefabs(); }
/// <summary> /// The data that this block adds to the mesh /// </summary> /// <param name="chunk">Chunk the block is in</param> /// <param name="x">X pos of the block</param> /// <param name="y">Y pos of the block</param> /// <param name="z">Z pos of the block</param> /// <param name="meshData">meshdata to add to</param> /// <param name="addToRenderMesh">should the block also be added to the render mesh not just the collision mesh</param> /// <returns>Given <paramref name="meshData"/> with this blocks data added to it</returns> /// <remarks> /// Only adds to the collision mesh as the model is handled by the unity prefab system /// </remarks> public override MeshData BlockData(Chunk chunk, int x, int y, int z, MeshData meshData, bool addToRenderMesh = true) { if (myGameobject == null) { myGameobject = UnityEngine.Object.Instantiate(PrefabDictionary.GetPrefab("Apiary"), new THVector3(x, y, z) + chunk.chunkWorldPos, Quaternion.identity, chunk.transform); myGameobject.GetComponent <ChestInventory>().inventoryPosition = new THVector3(x, y, z) + chunk.chunkWorldPos; myGameobject.GetComponent <ChestInventory>().SetChestInventory(); } return(base.BlockData(chunk, x, y, z, meshData, true)); }
public static void CreatePrefabDictionary() { PrefabDictionary asset = ScriptableObject.CreateInstance <PrefabDictionary>(); AssetDatabase.CreateAsset(asset, "Assets/Resources/PrefabDictionary.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public void createFloatingDamageText(Transform target, int rawDamage, int armor, int block, int healthLost) { Vector2 screenPosition = battleCamera.WorldToScreenPoint(target.position); GameObject go = Instantiate(PrefabDictionary.Instance().FloatingDamageText); go.transform.SetParent(battleCanvas, false); go.transform.position = screenPosition; go.GetComponent <FloatingDamageText>().SetText(rawDamage, armor, block, healthLost); }
protected void startListening() { listeningStarted = true; GameObject go = Instantiate(PrefabDictionary.Instance().targetListener, details.cardBase.transform); targetListener = go.GetComponent <TargetListener>(); targetListener.targetCatgeory = targetCategory; targetListener.targetSource = details.cardBase; targetListener.sourceAbility = this; GameAlertUI.Instance().setText(getAlertPromptText()); }
/// <summary> /// Makes the text object when the cursor is over the slot /// </summary> /// <param name="eventData">Not used but required for the interface</param> public void OnPointerEnter(PointerEventData eventData) { //* if the item is null or the floating item has something in it dont display the item text as it is not necissary if (item != null && myInventory.floatingItem == null) { itemText = Instantiate(PrefabDictionary.GetPrefab("ItemDetails")); //* sets the text to the correct postion itemText.transform.GetChild(0).position = Input.mousePosition; //* puts the correct text in the box itemText.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = $"{item.GetItemName()}\nStack: {item.itemStackCount}"; } }
private void displayPlayerCardCollection() { foreach (GameObject cardGO in PlayerCardCollection.Instance().cardCollection) { GameObject go = Instantiate(PrefabDictionary.Instance().cardBase, Vector3.zero, Quaternion.Euler(collectionHolder.transform.rotation.eulerAngles + new Vector3(90, 0, 0)), collectionHolder.transform); go.AddComponent <PreadventureCardSelector>(); BaseCard card = go.GetComponent <BaseCard>(); //Instantiate(PrefabDictionary.Instance().inDeckOverlay, go.transform); card.loadCardDetails(cardGO); collectionCards.Add(go); } }
public void addCard(GameObject details) { GameObject go = Instantiate(PrefabDictionary.Instance().cardBase, spawnPoint.position, Quaternion.identity, transform.transform); BaseCard card = go.GetComponent <BaseCard>(); card.character = character; card.hiddenCard = getDefaultHiddenStatus(); card.loadCardDetails(details); cards.Add(card); organizeCards(); }
public override void preCastTriggerOther(CardDetails details) { precastResolve = false; this.details = details; GameObject go = Instantiate(PrefabDictionary.Instance().multiTargetListener, details.cardBase.transform); targetListener = go.GetComponent <MultiTargetListener>(); targetListener.targetCatgeory = targetCategory; targetListener.targetSource = details.cardBase; targetListener.multiTargetSourceAbility = this; targetListener.targetCount = targetCount; targetListener.uniqueTargets = uniqueTargets; GameAlertUI.Instance().setText(getAlertPromptText()); }
private void displayCollectionSection(List <GameObject> cardPrefabs, bool includedInDeck) { int cardIndex = collectionCards.Count; foreach (GameObject cardGO in cardPrefabs) { GameObject go = Instantiate(PrefabDictionary.Instance().cardBase, Vector3.zero, Quaternion.Euler(90, 0, 0), collectionHolder.transform.transform); BaseCard card = go.GetComponent <BaseCard>(); if (includedInDeck) { //Instantiate(PrefabDictionary.Instance().inDeckOverlay, go.transform); } card.loadCardDetails(cardGO); collectionCards.Add(go); } }
private void OnMouseDown() { if (!EventSystem.current.IsPointerOverGameObject()) { if (inDeck) { Destroy(overlay); overlay = null; } else { overlay = Instantiate(PrefabDictionary.Instance().preadventureCardInDeckOverlay, gameObject.transform); } inDeck = !inDeck; PreadventureCardController.Instance().toggleCard(GetComponent <BaseCard>().details, inDeck); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } instance = this; DontDestroyOnLoad(this.gameObject); for (int i = 0; i < allBuildingBlockTypes.Length; i++) { BuildingBlockType bbt = allBuildingBlockTypes[i]; BuildingBlock buildingBlock = new BuildingBlock(i, bbt.blockName, bbt.prefab); buildingBlockDictionary.Insert(i, buildingBlock); Debug.Log("Block added to dictionary " + buildingBlockDictionary[i].blockName); } }
/// <summary> /// Draws the <see cref="floatingItem"/>s <see cref="Item.GetItemSprite()"/> at the mouse position /// </summary> private void DrawItemAtCursor() { if (floatingItem != null) { if (spriteAtCursor == null) { spriteAtCursor = Instantiate(PrefabDictionary.GetPrefab("ItemIcon")); spriteAtCursor.GetComponentInChildren <UnityEngine.UI.Image>().sprite = floatingItem.GetItemSprite(); } //* will update a the sprite of in item is swapped between a slot and teh floating item if the previous item wasnt put into a slot first else if (spriteAtCursor != null) { spriteAtCursor.GetComponentInChildren <UnityEngine.UI.Image>().sprite = floatingItem.GetItemSprite(); } spriteAtCursor.transform.GetChild(0).position = Input.mousePosition; } else { Destroy(spriteAtCursor); } }
// Use this for initialization void Start() { dictionary = GetComponent <PrefabDictionary>(); reader = GetComponent <LogReader>(); if (reader == null) { Debug.LogError("No LogReader attached to the Replay Analysis Engine."); } calculator = GetComponent <Calculator>(); if (calculator == null) { Debug.LogError("No Calculator attached to the Replay Analysis Engine."); } writer = GetComponent <AnalysisWriter>(); if (writer == null) { Debug.LogError("No LogWriter attached to the Replay Analysis Engine."); } extender = GetComponent <ReplayExtender>(); if (extender == null) { Debug.LogWarning("No ReplayExtender attached to the Replay Analysis Engine. Adding a DummyExtender."); } this.gameObject.AddComponent <ReplayExtender>(); foreach (GameObject go in (FindObjectsOfType(typeof(GameObject)) as GameObject[])) { if (go != this.gameObject && go.GetComponent <ReplayBehavior>() == null) { ReplayBehavior rb = go.AddComponent <ReplayBehavior>(); rb.ReplayTag = ReplayBehavior.RAETag.Given; rb.RecordTouching = false; } } }
protected void ReceivePrefab(string providerName) { _providerName = providerName; _prefabs = GameObject.Find(providerName).GetComponent <PrefabProvider>().Prefabs; }
// Use this for initialization void Start() { dictionary = GetComponent<PrefabDictionary>(); reader = GetComponent<LogReader>(); if(reader == null) Debug.LogError("No LogReader attached to the Replay Analysis Engine."); calculator = GetComponent<Calculator>(); if (calculator == null) Debug.LogError("No Calculator attached to the Replay Analysis Engine."); writer = GetComponent<AnalysisWriter>(); if (writer == null) Debug.LogError("No LogWriter attached to the Replay Analysis Engine."); extender = GetComponent<ReplayExtender>(); if (extender == null) Debug.LogWarning("No ReplayExtender attached to the Replay Analysis Engine. Adding a DummyExtender."); this.gameObject.AddComponent<ReplayExtender>(); foreach (GameObject go in (FindObjectsOfType(typeof(GameObject)) as GameObject[])) { if (go != this.gameObject && go.GetComponent<ReplayBehavior>() == null) { ReplayBehavior rb = go.AddComponent<ReplayBehavior>(); rb.ReplayTag = ReplayBehavior.RAETag.Given; rb.RecordTouching = false; } } }
/// <summary> /// Returns this <see cref="Block"/>s game object /// </summary> /// <returns></returns> public override GameObject GetGameObject() { return(PrefabDictionary.GetPrefab("CraftingTable")); }
/// <summary> /// Gets the game object for this apiary /// </summary> /// <returns>THe chest game object</returns> public override GameObject GetGameObject() { return(PrefabDictionary.GetPrefab("Apiary")); }