Beispiel #1
0
 /// <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));
 }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 /// <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));
 }
Beispiel #5
0
 /// <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}";
     }
 }
Beispiel #6
0
        /// <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);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Gets the game object for this apiary
 /// </summary>
 /// <returns>THe chest game object</returns>
 public override GameObject GetGameObject()
 {
     return(PrefabDictionary.GetPrefab("Apiary"));
 }
Beispiel #8
0
 /// <summary>
 /// Returns this <see cref="Block"/>s game object
 /// </summary>
 /// <returns></returns>
 public override GameObject GetGameObject()
 {
     return(PrefabDictionary.GetPrefab("CraftingTable"));
 }
    private GameObject SpawnObject(XmlNode node, StudentAction action)
    {
        string key = extender.LookupPrefab(node, action);

        if (string.IsNullOrEmpty(key))
        {
            if (node[Logger.PREFAB] == null)
            {
                Debug.LogWarning("XmlNode contains no <Prefab> element, attempting to use the <Name> element instead.");
                if (node[Logger.NAME] == null)
                {
                    Debug.LogWarning("XmlNode contains no <Name> element. Giving up. Consider writing an extension to the LookupPrefab() " +
                                     "method in the ReplayExtender class if your log files do not conform to the standard format.\nNode:" + node.OuterXml);
                    return(null);
                }
                key = node[Logger.NAME].InnerText;
            }
            else
            {
                key = node[Logger.PREFAB].InnerText;
            }
        }

        GameObject prefab = dictionary.GetPrefab(key);

        if (prefab == null)
        {
            Debug.LogWarning("No Prefab found in dictionary for name:" + key + ", did you forget to add it, or spell the (case-sensative) key wrong? Giving up.");
            return(null);
        }

        GameObject gob = null;

        float   posX = float.Parse(node[Logger.TRANSFORM][Logger.POSITION]["X"].InnerText);
        float   posY = float.Parse(node[Logger.TRANSFORM][Logger.POSITION]["Y"].InnerText);
        Vector3 pos  = new Vector3(posX, posY, 0f);

        float      rotZ = float.Parse(node[Logger.TRANSFORM][Logger.ROTATION].InnerText);
        Quaternion rot  = Quaternion.Euler(0f, 0f, rotZ);

        gob = GameObject.Instantiate(prefab, pos, rot) as GameObject;

        gob.name = node[Logger.NAME].InnerText;
        ReplayBehavior rb = gob.AddComponent <ReplayBehavior>();

        if (node[Logger.PREFAB] != null)
        {
            rb.PrefabName = node[Logger.PREFAB].InnerText;
        }
        else
        {
            rb.PrefabName = ReplayBehavior.NO_PREFAB_TAG;
        }

        if (node[Logger.UNITY_TAG] != null)
        {
            rb.UnityTag = node[Logger.UNITY_TAG].InnerText;
        }
        else
        {
            rb.UnityTag = ReplayBehavior.NO_UNITY_TAG;
        }

        if (node[Logger.EXTRA_TAGS] != null)
        {
            List <string> newTags = new List <string>();
            foreach (XmlNode subNode in node[Logger.EXTRA_TAGS])
            {
                if (subNode[Logger.TAG] != null)
                {
                    newTags.Add(subNode[Logger.TAG].InnerText);
                }
            }
            rb.AddTags(newTags);
        }

        return(gob);
    }