コード例 #1
0
    void CreateHotbarUIElements()
    {
        for (int i = 0; i < builder.objectCategories.Length; i++)
        {
            ObjectCategory category = builder.objectCategories[i];

            // Creating objects parent for objects.
            GameObject objectsParent = Instantiate(objectsParentPrefab, objectsTrans.position, Quaternion.identity, objectsTrans);
            objectsParent.name = category.Name;

            // Creating Category UI Element.
            CategoryUIElement CUIE = Instantiate(CategoryUIElementPrefab, categoriesTrans.position, Quaternion.identity, categoriesTrans).GetComponent <CategoryUIElement>();
            CUIE.Text.text     = category.Name;
            CUIE.ObjectsParent = objectsParent;
            CUIEs.Add(CUIE);

            CUIE.ObjectsParent.SetActive(false);
            if (i == 0)
            {
                CUIE.ObjectsParent.SetActive(true);
            }

            for (int j = 0; j < category.objectsData.Length; j++)
            {
                // Creating Object UI Element for current Category UI Element.
                ObjectUIElement OUIE = Instantiate(ObjectUIElementPrefab, objectsParent.transform.position, Quaternion.identity, objectsParent.transform).GetComponent <ObjectUIElement>();
                OUIE.iconImg.sprite = category.objectsData[j].Sprite;
                OUIE.Text.text      = category.objectsData[j].Name;
            }
        }
    }
コード例 #2
0
 private void ChangeToggle(int index)
 {
     currentTab        = tabCategorizes[index];
     swapScroll.Source = modelParty.GetDataList(currentTab);
     swapScroll.Reposition();
     UpdateContents();
 }
コード例 #3
0
ファイル: ObjectManager.cs プロジェクト: TopKekstar/IAV
            /// <summary>
            /// Returns a random object from the Objects array.
            /// </summary>
            /// <param name="category">The category used to get the object.</param>
            /// <param name="retrievedObject">The object retrieved for the specific item type, layer, and category.</param>
            /// <returns>Was an object successfully retrieved?</returns>
            public bool RandomObject(ObjectCategory category, ref Object retrievedObject)
            {
                Object[] objects = null;
                switch (category)
                {
                case ObjectCategory.Audio:
                    objects = m_Audio;
                    break;

                case ObjectCategory.Decal:
                    objects = m_Decals;
                    break;

                case ObjectCategory.Dust:
                    objects = m_Dust;
                    break;

                case ObjectCategory.Spark:
                    objects = m_Sparks;
                    break;
                }

                if (objects != null && objects.Length > 0)
                {
                    retrievedObject = objects[Random.Range(0, objects.Length)];
                    return(true);
                }
                return(false);
            }
コード例 #4
0
ファイル: RadarShapes.cs プロジェクト: Sergoffan/mRadar
        /// <summary>
        /// Returns a Brush color that represents an ObjectCategory, used when drawing simple dots and text names
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static Brush Color(this ObjectCategory self)
        {
            switch (self)
            {
                case ObjectCategory.HarvestableTree:
                    return Brushes.DarkSeaGreen;

                case ObjectCategory.HarvestablePlant:
                    return Brushes.SeaGreen;

                case ObjectCategory.Ore:
                    return Brushes.MediumSeaGreen;

                case ObjectCategory.EnemyPlayer:
                    return Brushes.Red;

                case ObjectCategory.EnemyNPC:
                    return Brushes.OrangeRed;

                case ObjectCategory.FriendlyPlayer:
                    return FriendlyPlayerText;
                case ObjectCategory.FriendlyNPC:
                    return Brushes.DarkGreen;
                case ObjectCategory.TradePack:
                    return Brushes.White;
                case ObjectCategory.Treasure:
                    return Brushes.Yellow;
                case ObjectCategory.FishSchool:
                    return Brushes.Aqua;
                default:
                    return Brushes.SlateGray;
            }
        }
コード例 #5
0
        public void Optmimize <VertexType>() where VertexType : struct
        {
            lock (_lock) {
                _originalObjects = _opaqueObjects.Concat(_transparentObjects).ToList();

                _opaqueObjects.Clear();
                _transparentObjects.Clear();

                // categorize objects:
                var categories = new Dictionary <ObjectCategory, List <I3DObject> >();
                foreach (var obj in _originalObjects)
                {
                    if (!obj.IsOpaque || !obj.IsOptimizable)
                    {
                        Add(obj);
                    }
                    else
                    {
                        var category = ObjectCategory.Create(obj);
                        if (category.BlendStateId == -1) // unknown/custom blendstate
                        {
                            Add(obj);
                        }
                        else
                        {
                            if (categories.ContainsKey(category))
                            {
                                categories[category].Add(obj);
                            }
                            else
                            {
                                categories.Add(category, new List <I3DObject>()
                                {
                                    obj
                                });
                            }
                        }
                    }
                }

                // morph categories of objects into a single geometry object:
                foreach (var category in categories.Keys)
                {
                    var objects = categories[category];
                    if (objects.Count == 1)
                    {
                        AddRange(objects.ToArray());
                    }
                    else
                    {
                        var morphed = new Morphed3DObject <VertexType>(objects);
                        morphed.LoadContent();
                        Add(morphed);
                    }
                }

                Optimized = true;
            }
        }
コード例 #6
0
        /***************************************************/
        /**** Constructors                              ****/
        /***************************************************/

        public GlobalWarmingPotentialResult(IComparable objectId,
                                            IComparable resultCase,
                                            double timeStep,
                                            ObjectScope scope,
                                            ObjectCategory category,
                                            IEnvironmentalProductDeclarationData environmentalProductDeclaration,
                                            double globalWarmingPotential) : base(objectId, resultCase, timeStep, scope, category, environmentalProductDeclaration)
        {
            GlobalWarmingPotential = globalWarmingPotential;
        }
コード例 #7
0
ファイル: ObjectManager.cs プロジェクト: TopKekstar/IAV
        /// <summary>
        /// Internal method to return the object which should spawn based on the item type, layer, and cateogry.
        /// </summary>
        /// <param name="tag">The tag which the object is spawning above.</param>
        /// <param name="itemType">The type of item.</param>
        /// <param name="objectCategory">The category of the object to spawn.</param>
        /// <param name="retrievedObject">The object retrieved for the specific item type, layer, and category.</param>
        /// <returns>Was an object successfully retrieved?</returns>
        private bool ObjectForItemInternal(string tag, ItemType itemType, ObjectCategory objectCategory, ref Object retrievedObject)
        {
            TagObjectArray tagObject = null;

            if (m_ObjectsPerTagMap.TryGetValue(tag, out tagObject))
            {
                return(tagObject.ObjectForItem(itemType, objectCategory, ref retrievedObject));
            }
            return(false);
        }
コード例 #8
0
ファイル: RadarShapes.cs プロジェクト: Sergoffan/mRadar
        public static UIElement Shape(this ObjectCategory self)
        {
            Canvas shape;
            switch (self)
            {
                case ObjectCategory.ThunderstruckTree: shape = new Thunderstruck(); break;

                case ObjectCategory.HarvestableTree: shape = new Tree(false); break;
                case ObjectCategory.FruitedTree: shape = new Tree(true); break;

                //case ObjectCategory.Uprootable: shape = new Up(); break;

                case ObjectCategory.ScarecrowGarden: shape = new Garden(); break;

                case ObjectCategory.SmallHousing: shape = new SmallHouse(); break;

                case ObjectCategory.Farmhouse: shape = new Farmhouse(); break;
                case ObjectCategory.LargeHousing: shape = new LargeHouse(); break;

                case ObjectCategory.HarvestablePlant: shape = new Leaf(); break;
                case ObjectCategory.ScarecrowFarm: shape = new Farm(); break;
                case ObjectCategory.HousingWorkbench: shape = new HousingWorkbench(); break;
                
                case ObjectCategory.FriendlyPlayer: shape = new PlayerShape(true); break;
                case ObjectCategory.EnemyPlayer: shape = new PlayerShape(false); break;

                case ObjectCategory.FriendlyClipper: shape = new Clipper(true); break;
                case ObjectCategory.EnemyClipper: shape = new Clipper(false); break;

                case ObjectCategory.FriendlyMerchantShip: shape = new MerchantShip(true); break;
                case ObjectCategory.EnemyMerchantShip: shape = new MerchantShip(false); break;

                case ObjectCategory.FriendlyFishingBoat: shape = new FishingShip(true); break;
                case ObjectCategory.EnemyFishingBoat: shape = new FishingShip(false); break;

                case ObjectCategory.FriendlyGalleon: shape = new Galleon(true); break;
                case ObjectCategory.EnemyGalleon: shape = new Galleon(false); break;
                case ObjectCategory.FriendlyNPC: shape = new NpcShape(true); break;
                
                case ObjectCategory.TradePack: shape = new TradePack(); break;
                case ObjectCategory.Treasure: shape = new Treasure(); break;
                case ObjectCategory.FishSchool: shape = new Fish(); break;

                case ObjectCategory.EnemyNPC: shape = new NpcShape(false); break;
                    
                default:
                    Ellipse dot = DrawSimpleDot();
                    dot.Fill = self.Color();
                    return dot;       
            }

            //need to flip the shape because our canvas is inverted (due to game coordinate system)
            return Flip(shape);
        }
コード例 #9
0
    public List <ObjectCategory> ConvertScoresToCategoryList(JSONObject cat)
    {
        List <ObjectCategory> visionGuesses = new List <ObjectCategory>();

        for (int i = 0; i < cat.Count; i++)
        {
            JSONObject     lineObj = cat[i];
            ObjectCategory c       = new ObjectCategory(lineObj.list[0].ToString(), float.Parse(lineObj.list[1].ToString()));
            visionGuesses.Add(c);
            Debug.Log(c.ToString());
        }
        return(visionGuesses);
    }
コード例 #10
0
        /***************************************************/
        /**** Constructors                              ****/
        /***************************************************/

        protected LifeCycleAssessmentElementResult(IComparable objectId,
                                                   IComparable resultCase,
                                                   double timeStep,
                                                   ObjectScope scope,
                                                   ObjectCategory category,
                                                   List <IEnvironmentalProductDeclarationData> environmentalProductDeclaration)
        {
            ObjectId   = objectId;
            ResultCase = resultCase;
            TimeStep   = timeStep;
            Scope      = scope;
            Category   = category;
            EnvironmentalProductDeclaration = environmentalProductDeclaration;
        }
コード例 #11
0
 /// <summary>
 /// Set the properties that are set in an ObjectPropertiesFamily packet
 /// </summary>
 /// <param name="props"><seealso cref="ObjectProperties"/> that has
 /// been partially filled by an ObjectPropertiesFamily packet</param>
 public void SetFamilyProperties(ObjectProperties props)
 {
     ObjectID      = props.ObjectID;
     OwnerID       = props.OwnerID;
     GroupID       = props.GroupID;
     Permissions   = props.Permissions;
     OwnershipCost = props.OwnershipCost;
     SaleType      = props.SaleType;
     SalePrice     = props.SalePrice;
     Category      = props.Category;
     LastOwnerID   = props.LastOwnerID;
     Name          = props.Name;
     Description   = props.Description;
 }
コード例 #12
0
    public ObjectCategory GetHighestObjectCategory()
    {
        ObjectCategory max = categories[0];

        foreach (ObjectCategory e in categories)
        {
            if (e.score > max.score)
            {
                max = e;
            }
        }
        Debug.Log("Best ObjectCategory Guess: " + max.ToString());
        txt.text = max.ToString();
        return(max);
    }
コード例 #13
0
ファイル: ObjectManager.cs プロジェクト: TopKekstar/IAV
            /// <summary>
            /// Returns the object for the specified tag and category.
            /// </summary>
            /// <param name="tag">The tag used to get the object.</param>
            /// <param name="category">The category used to get the object.</param>
            /// <param name="retrievedObject">The object retrieved for the specific item type, layer, and category.</param>
            /// <returns>Was an object successfully retrieved?</returns>
            public bool ObjectForItem(ItemType itemType, ObjectCategory category, ref Object retrievedObject)
            {
                if (itemType != null)
                {
                    ItemObjectCategoryArray objectArray;
                    if (m_ItemObjectMap.TryGetValue(itemType, out objectArray))
                    {
                        // Randomly choose an object.
                        return(objectArray.RandomObject(category, ref retrievedObject));
                    }
                }

                // Fallback to NullItemObjects if an object doesn't exist for the specified category.
                if (m_NullItemObjects != null)
                {
                    return(m_NullItemObjects.RandomObject(category, ref retrievedObject));
                }
                return(false);
            }
コード例 #14
0
    public void TabClick(string filter)
    {
        foreach (string f in filters)
        {
            if (f == filter)
            {
                tabs[f].gameObject.GetComponent <Button>().interactable = false;
            }
            else
            {
                tabs[f].gameObject.GetComponent <Button>().interactable = true;
            }
        }

        ObjectCategory option = ObjectCategory.All;

        Enum.TryParse(filter, out option);

        mapEditor?.LoadObjectsButtons(option);
    }
コード例 #15
0
ファイル: FrmDesigner.cs プロジェクト: jalil1408/BiomPSP
 private void CrCopyObj(string id_obj, ObjectCategory c, string id_rpt_dest)
 {
     switch (c)
     {
         case ObjectCategory.Line:
             MprObjLine line = MprObjLine.FromDb(id_obj);
             line.IDReport = id_rpt_dest;
             MprObjLine.ToDb(line, null);
             break;
         case ObjectCategory.Rectangle:
             MprObjRect rect = MprObjRect.FromDb(id_obj);
             rect.IDReport = id_rpt_dest;
             MprObjRect.ToDb(rect, null);
             break;
         case ObjectCategory.Ellipse:
             MprObjEllp ellp = MprObjEllp.FromDb(id_obj);
             ellp.IDReport = id_rpt_dest;
             MprObjEllp.ToDb(ellp, null);
             break;
         case ObjectCategory.TextField:
             MprObjTxtFld txt = MprObjTxtFld.FromDb(id_obj);
             txt.IDReport = id_rpt_dest;
             MprObjTxtFld.ToDb(txt, null);
             break;
         case ObjectCategory.ImageField:
             MprObjImgFld img = MprObjImgFld.FromDb(id_obj);
             img.IDReport = id_rpt_dest;
             MprObjImgFld.ToDb(img, null);
             break;
         case ObjectCategory.Grid:
             MprObjGrd grd = MprObjGrd.FromDb(id_obj);
             grd.IDReport = id_rpt_dest;
             MprObjGrd.ToDb(grd, null);
             break;
         default:
             break;
     }
 }
コード例 #16
0
ファイル: ObjectManager.cs プロジェクト: TopKekstar/IAV
 /// <summary>
 /// Return the object which should spawn based on the item type, layer, and cateogry.
 /// </summary>
 /// <param name="tag">The tag which the object is spawning above.</param>
 /// <param name="itemType">The type of item.</param>
 /// <param name="objectCategory">The category of the object to spawn.</param>
 /// <param name="retrievedObject">The object retrieved for the specific item type, layer, and category.</param>
 /// <returns>Was an object successfully retrieved?</returns>
 public static bool ObjectForItem(string tag, ItemType itemType, ObjectCategory objectCategory, ref Object retrievedObject)
 {
     return(Instance.ObjectForItemInternal(tag, itemType, objectCategory, ref retrievedObject));
 }
コード例 #17
0
    public void LoadObjectsButtons(ObjectCategory filter = 0)
    {
        foreach (Transform child in objectList.transform)
        {
            GameObject.Destroy(child.gameObject);
        }


        foreach (var so in SessionManager.Instance.sceneObjects.objectSet)
        {
            ISceneObject isc = (ISceneObject)so;

            if (isc == null)
            {
                continue;
            }

            UISceneObject uisc = isc.GetUISceneObject();

            if (filter != ObjectCategory.All && filter != uisc.category)
            {
                continue;
            }


            GameObject soButton = Instantiate(sceneObjectUiPrefab, objectList);
            Button     button   = soButton.GetComponent <Button>();
            soButton.GetComponentInChildren <TextMeshProUGUI>()?.SetText(so.GetDisplayName());

            button.onClick.AddListener(() => { SetPlacementObject(isc); });

            button.targetGraphic.color = uisc.color;
            soButton.transform.Find("Icon").GetComponent <Image>().sprite = uisc.icon;
        }


        foreach (var so in SessionManager.Instance.sceneObjects.prefabSet)
        {
            ISceneObject isc = (ISceneObject)so;

            if (isc == null)
            {
                continue;
            }

            UISceneObject uisc = isc.GetUISceneObject();

            if (filter != ObjectCategory.All && filter != ObjectCategory.UserPrefabs && filter != uisc.category)
            {
                continue;
            }

            GameObject soButton = Instantiate(sceneObjectUiPrefab, objectList);

            Button button = soButton.GetComponent <Button>();
            soButton.GetComponentInChildren <TextMeshProUGUI>()?.SetText(so.GetDisplayName());


            button.onClick.AddListener(() => { SetPlacementObject(isc); });

            button.targetGraphic.color = Color.yellow;
            soButton.transform.Find("Icon").GetComponent <Image>().sprite = uisc.icon;
        }
    }
コード例 #18
0
    void SpawnDecoration()
    {
        int[] arr = new int[] { 0, 2, 2, 1, 1, 3, 3, 0 };
        for (int i = 0; i < room.roomData.parts.Count; i++)
        {
            Part currentPart = room.roomData.parts[i];

            Vector3 insideSW = Vector3.Lerp(currentPart.SW, currentPart.NE, 0.05f);
            Vector3 insideNE = Vector3.Lerp(currentPart.SW, currentPart.NE, 0.95f);
            Vector3 insideSE = Vector3.Lerp(currentPart.SE, currentPart.NW, 0.05f);
            Vector3 insideNW = Vector3.Lerp(currentPart.SE, currentPart.NW, 0.95f);

            Vector3[] insideArr = new Vector3[] { insideSW, insideNE, insideSE, insideNW };

            List <Vector3> list = new List <Vector3>();


            for (int p = 0; p < themeSettings.decorateObjects.Length; p++)
            {
                ObjectCategory cat    = themeSettings.decorateObjects[p];
                int            amount = room.roomData.roomType == RoomType.Room ? rng.Next(cat.roomAmountDecorate.x, cat.roomAmountDecorate.y) : rng.Next(cat.roomAmountDecorate.x / room.roomData.parts.Count, cat.roomAmountDecorate.y / room.roomData.parts.Count);

                list.Clear();

                while (list.Count < amount)
                {
                    //for (int k = 0; k < amount / room.roomData.parts.Count; k++) {
                    bool    add     = false;
                    Vector3 addVec3 = Vector3.zero;
                    for (int h = 0; h < (list.Count == 0 ? 1 : list.Count); h++)
                    {
                        //foreach (Vector3 item in list) {
                        if (cat.place == Place.Wall)
                        {
                            int ran   = rng.Next(0, 4);
                            int perc1 = rng.Next(10, 190);

                            Vector3 place = new Vector3();
                            float   rotY  = 0;;
                            if (ran == 0 && currentPart.hasNorth)
                            {
                                if (currentPart.hasNorthEnt && perc1 >= 80 && perc1 <= 120)
                                {
                                    perc1 += 40;
                                }

                                place = Vector3.Lerp(currentPart.NW, currentPart.NE, perc1 * 0.005f);
                                rotY  = Quaternion.LookRotation(currentPart.NW - currentPart.NE).eulerAngles.y;
                            }
                            else if (ran == 1 && currentPart.hasEast)
                            {
                                if (currentPart.hasEastEnt && perc1 >= 80 && perc1 <= 120)
                                {
                                    perc1 += 40;
                                }

                                place = Vector3.Lerp(currentPart.NE, currentPart.SE, perc1 * 0.005f);
                                rotY  = Quaternion.LookRotation(currentPart.NE - currentPart.SE).eulerAngles.y;
                            }
                            else if (ran == 2 && currentPart.hasSouth)
                            {
                                if (currentPart.hasSouthEnt && perc1 >= 80 && perc1 <= 120)
                                {
                                    perc1 += 40;
                                }

                                place = Vector3.Lerp(currentPart.SE, currentPart.SW, perc1 * 0.005f);
                                rotY  = Quaternion.LookRotation(currentPart.SE - currentPart.SW).eulerAngles.y;
                            }
                            else if (ran == 3 && currentPart.hasWest)
                            {
                                if (currentPart.hasWestEnt && perc1 >= 80 && perc1 <= 120)
                                {
                                    perc1 += 40;
                                }

                                place = Vector3.Lerp(currentPart.SW, currentPart.NW, perc1 * 0.005f);
                                rotY  = Quaternion.LookRotation(currentPart.SW - currentPart.NW).eulerAngles.y;
                            }

                            if (list.Count == 0 ? true : Vector3.Distance(list[h], place) > 2f)
                            {
                                add     = true;
                                addVec3 = place;

                                GameObject go = Instantiate(cat.objects[rng.Next(0, cat.objects.Length)], room.transform.GetChild(0));
                                go.transform.position    = place + Vector3.up * cat.positionGridPlace;
                                go.transform.eulerAngles = new Vector3(0, rotY, 0);
                                break;
                            }
                        }
                        else
                        {
                            int     index1 = rng.Next(0, 4), index2 = rng.Next(0, 4);
                            int     perc1 = rng.Next(0, 200), perc2 = rng.Next(0, 200), perc3 = rng.Next(0, 200);
                            Vector3 pos1 = Vector3.Lerp(insideArr[arr[index1 * 2]], insideArr[arr[(index1 * 2) + 1]], perc1 * 0.005f);
                            Vector3 pos2 = Vector3.Lerp(insideArr[arr[index2 * 2]], insideArr[arr[(index2 * 2) + 1]], perc2 * 0.005f);
                            Vector3 pos3 = Vector3.Lerp(pos1, pos2, perc3 * 0.005f);

                            if (list.Count == 0 ? true : Vector3.Distance(list[h], pos3) > 2f)
                            {
                                add     = true;
                                addVec3 = pos3;

                                GameObject go = Instantiate(cat.objects[rng.Next(0, cat.objects.Length)], room.transform.GetChild(0));

                                if (cat.positionGridPlace > float.Epsilon)
                                {
                                    float point = cat.positionGridPlace;
                                    pos3.x = (int)(pos3.x / point + 0.5f) * point;
                                    pos3.z = (int)(pos3.z / point + 0.5f) * point;
                                }
                                go.transform.position = pos3 + Vector3.up * 0.0001f;

                                float y = Mathf.Clamp(cat.rotationMinMax.x + rng.Next(0, (int)cat.rotationMultiplier) * cat.rotationIncrements, cat.rotationMinMax.x, cat.rotationMinMax.y);

                                go.transform.eulerAngles = new Vector3(0, y, 0);
                                break;
                            }
                        }
                    }
                    if (add)
                    {
                        list.Add(addVec3);
                    }
                }
            }
        }
    }
コード例 #19
0
    void Start()
    {
        Transform[] allImported = gameObject.GetComponentsInChildren <Transform>();
        foreach (Transform item in allImported)
        {
            // add object to hold parameters before final tagging and parenting
            ObjectCategory holder = item.gameObject.AddComponent <ObjectCategory>();

            // if item has @, it needs parenting
            if (item.name.Contains("@"))
            {
                // to the left of @ is the name, to the right is the parents name
                string[] splitName = item.name.Split('@');

                // get rid of blender's numbering
                for (int i = 0; i < splitName.Length; i++)
                {
                    if (splitName[i].Contains("."))
                    {
                        splitName[i] = splitName[i].Split('.')[0];
                    }
                }

                // store names
                holder.temporaryName = splitName[0];
                holder.parentName    = splitName[1];

                // match names with possible tags
                foreach (PartialNameTagPair nt in partialNameTagPair)
                {
                    if (holder.temporaryName.Contains(nt.partialName))
                    {
                        holder.temporaryTag = nt.tag;
                        item.tag            = nt.tag;
                    }
                }

                // otherwise it might be a root object still needing to be tagged, or a misc object, that needs to be left untouched
            }
            else
            {
                holder.temporaryName = item.name;
                foreach (PartialNameTagPair nt in partialNameTagPair)
                {
                    if (item.name.Contains(nt.partialName))
                    {
                        holder.temporaryTag = nt.tag;
                        item.tag            = nt.tag;
                    }
                }
            }
        }

        foreach (Transform child in allImported)
        {
            foreach (Transform parent in allImported)
            {
                if (child.gameObject.GetComponent <ObjectCategory>().parentName == parent.gameObject.GetComponent <ObjectCategory>().temporaryName)
                {
                    child.parent = parent;
                }
            }
        }



        animator = Resources.Load("Animations/Cube") as RuntimeAnimatorController;

        foreach (Transform item in allImported)
        {
            if (item.CompareTag("Origin"))
            {
                GameObject g = item.gameObject;
                Mover      m = g.AddComponent <Mover>();

                GameObject colliderMeshSource = GameObject.Find(g.GetComponent <ObjectCategory>().parentName);

                /*
                 * GameObject colliderMeshSource = null;
                 * foreach (GameObject source in GameObject.FindGameObjectsWithTag("Collider"))
                 * {
                 *  Debug.Log("Object with collider tag: " + source.name);
                 *  if (source.transform.parent == g.transform.parent)
                 *  {
                 *      colliderMeshSource = source;
                 *      Debug.Log("Collider found at " + source.name);
                 *  }
                 * }
                 */
                colliderMeshSource.GetComponent <MeshRenderer>().enabled = false;
                g.AddComponent <MeshCollider>().sharedMesh            = colliderMeshSource.GetComponent <MeshFilter>().sharedMesh;
                g.AddComponent <Animator>().runtimeAnimatorController = animator;
                g.layer = LayerMask.NameToLayer("KinectTouchable");
            }
        }

        foreach (Transform item in allImported)
        {
            if (item.CompareTag("Element"))
            {
                GameObject g = item.gameObject;
                if (g.GetComponent <MeshRenderer>() != null)
                {
                    g.GetComponent <MeshRenderer>().enabled = false;
                }
            }
        }

        foreach (Transform item in allImported)
        {
            if (item.CompareTag("Origin"))
            {
                GameObject g = item.gameObject;
                if (g.GetComponent <MeshRenderer>() != null)
                {
                    g.GetComponent <MeshRenderer>().enabled = false;
                }
            }
        }

        AudioClip ping = Resources.Load("Audio/Ping") as AudioClip;
        AudioClip drag = Resources.Load("Audio/Drag") as AudioClip;

        foreach (Transform item in allImported)
        {
            if (item.CompareTag("Slot"))
            {
                GameObject g = item.gameObject;
                Debug.Log(g.name + " is a slot");
                Mover      m = g.GetComponentInChildren <Mover>();
                GameObject pingSourceObject = new GameObject("Ping_audio_source");
                pingSourceObject.transform.position = g.transform.position;
                pingSourceObject.transform.parent   = g.transform;
                AudioSource pingSource = pingSourceObject.AddComponent <AudioSource>();
                pingSource.loop        = false;
                pingSource.playOnAwake = false;
                pingSource.clip        = ping;
                m.pingSource           = pingSource;

                GameObject dragSourceObject = new GameObject("Drag_audio_source");
                dragSourceObject.transform.position = g.transform.position;
                dragSourceObject.transform.parent   = g.transform;
                AudioSource dragSource = dragSourceObject.AddComponent <AudioSource>();
                dragSource.loop        = true;
                dragSource.playOnAwake = true;
                dragSource.clip        = drag;
                m.dragSource           = dragSource;
                if (g.GetComponent <MeshRenderer>() != null)
                {
                    g.GetComponent <MeshRenderer>().enabled = false;
                }
            }
        }

        //GameObject.Find("Solution").AddComponent<SolutionHandler>();
    }
コード例 #20
0
        public static bool CreatePrefab(string prefabID, SceneGameObject root, string name = "", int sprite = 0, ObjectCategory category = ObjectCategory.UserPrefabs)
        {
            if (string.IsNullOrEmpty(prefabID))
            {
                return(false);
            }

            string prefabFolder = exportPath + "/";

            if (!Directory.Exists(exportPath))
            {
                Directory.CreateDirectory(prefabFolder);
            }

            SavedPrefab savedPrefab = new SavedPrefab {
                name          = name,
                category      = category,
                sprite        = sprite,
                root          = root.data.id,
                prefabObjects = new List <SceneGameObject>(root.GetComponentsInChildren <SceneGameObject>(true))
            };

            byte[] exportData = SerializationUtility.SerializeValue(savedPrefab, dataFormat);

            File.WriteAllBytes(exportPath + "/" + prefabID + ".nt", exportData);

            return(true);
        }
コード例 #21
0
        /// <summary>
        /// Add a object type.
        /// </summary>
        /// <param name="type">The object type. Use typeof() to get the type.</param>
        /// <param name="counterName">The name of the counter this type belongs.</param>
        /// <param name="maxCount">The maximum count of objects of this type allowed.</param>
        public void AddObjectType(Type type, string categoryName, int maxCount)
        {
            if(type == null) {
                throw new ArgumentNullException("type");
            }

            ObjectCategory category = new ObjectCategory(categoryName, type, maxCount);
            counters.Add(category.GetHashCode(), category);
        }
コード例 #22
0
ファイル: DungeonData.cs プロジェクト: ggrrin/DungeonMaster
        public ItemDescriptor  GetItemDescriptor(ObjectCategory category, int categoryIndexType)
        {
            int baseIndex = 0;
            switch (category)
            {
                //                    +0(1 item type)
                case Scroll:
                    baseIndex = 0;
                    break;
                //                    +1(1 item types)
                case Container:
                    baseIndex = 1;
                    break;
                //                    +2(21 item types)
                case Potion:
                    baseIndex = 2;
                    break;
                //                    +23(46 item types)
                case Weapon:
                    baseIndex = 23;
                    break;
                //                    +69(58 item types)
                case Clothe:
                    baseIndex = 69;
                    break;
                //                    +127(53 item types)
                case Miscellenaous:
                    baseIndex = 127;
                    break;

                default: throw new NotSupportedException();
            }
            var index = baseIndex + categoryIndexType;
            return ItemDescriptors[index];
        }
コード例 #23
0
    //add collidable objects
    void SpawnGameplay() {
        foreach (Room room in roomLayout) {
            if (room.roomData.node == spawnNode || room.roomData.node == endNode)
                continue;

            if (room.roomData.roomType == RoomType.Room) {
                List<Vector3> list = new List<Vector3>();
                Vector3 insideSW = Vector3.Lerp(room.roomData.SW, room.roomData.NE, 0.2f);
                Vector3 insideNE = Vector3.Lerp(room.roomData.SW, room.roomData.NE, 0.8f);
                Vector3 insideSE = Vector3.Lerp(room.roomData.SE, room.roomData.NW, 0.2f);
                Vector3 insideNW = Vector3.Lerp(room.roomData.SE, room.roomData.NW, 0.8f);
                Vector3[] insideArr = new Vector3[] { insideSW, insideNE, insideSE, insideNW };
                int[] arr = new int[] { 0, 2, 2, 1, 1, 3, 3, 0 };
                int amount = rng.Next(themeSettings.roomAmountGameplay.x, themeSettings.roomAmountGameplay.y);
                while (list.Count < amount) {
                    int index1 = rng.Next(0, 4), index2 = rng.Next(0, 4);
                    int perc1 = rng.Next(0, 200), perc2 = rng.Next(0, 200), perc3 = rng.Next(0, 200);
                    Vector3 pos1 = Vector3.Lerp(insideArr[arr[index1 * 2]], insideArr[arr[(index1 * 2) + 1]], perc1 * 0.005f);
                    Vector3 pos2 = Vector3.Lerp(insideArr[arr[index2 * 2]], insideArr[arr[(index2 * 2) + 1]], perc2 * 0.005f);
                    Vector3 pos3 = Vector3.Lerp(pos1, pos2, perc3 * 0.005f);
                    if (list.Count <= 0) {
                        ObjectCategory cat = themeSettings.gameplayObjects[rng.Next(themeSettings.gameplayObjects.Length)];

                        GameObject go = Instantiate(cat.objects[rng.Next(0, cat.objects.Length)], room.transform.GetChild(0));

                        go.layer = LayerMask.NameToLayer("Room");

                        if (cat.positionGridPlace > float.Epsilon) {
                            float point = cat.positionGridPlace;
                            pos3.x = (int)(pos3.x / point + 0.5f) * point;
                            pos3.z = (int)(pos3.z / point + 0.5f) * point;
                        }
                        list.Add(pos3);
                        go.transform.position = pos3 + Vector3.up * 0.0001f;

                        float y = Mathf.Clamp(cat.rotationMinMax.x + rng.Next(0, (int)cat.rotationMultiplier) * cat.rotationIncrements, cat.rotationMinMax.x, cat.rotationMinMax.y);

                        go.transform.eulerAngles = new Vector3(0, y, 0);
                    } else {
                        bool add = false;
                        Vector3 addVec3 = Vector3.zero;
                        foreach(Vector3 vec3 in list) {
                            if (Vector3.Distance(vec3, pos3) > 5.5f) {
                                add = true;
                                ObjectCategory cat = themeSettings.gameplayObjects[rng.Next(themeSettings.gameplayObjects.Length)];

                                GameObject go = Instantiate(cat.objects[rng.Next(0, cat.objects.Length)], room.transform.GetChild(0));

                                go.layer = LayerMask.NameToLayer("Room");

                                if (cat.positionGridPlace > float.Epsilon) {
                                    float point = cat.positionGridPlace;
                                    pos3.x = (int)(pos3.x / point + 0.5f) * point;
                                    pos3.z = (int)(pos3.z / point + 0.5f) * point;
                                }
                                addVec3 = pos3;
                                go.transform.position = pos3 + Vector3.up * 0.0001f;

                                float y = Mathf.Clamp(cat.rotationMinMax.x + rng.Next(0, (int)cat.rotationMultiplier) * cat.rotationIncrements, cat.rotationMinMax.x, cat.rotationMinMax.y);

                                go.transform.eulerAngles = new Vector3(0, y, 0);
                                break;
                            } else {
                                continue;
                            }
                        }
                        if (add) {
                            list.Add(addVec3);
                        }
                    }
                }
            } else {
                continue;
            }
        }
    }
コード例 #24
0
        /// <summary>
        /// Checks if the number of objects exceeds the maximum allowed number.
        /// If the <paramref name="OnObjectCountExceeded"/> event is set, the event is called.
        /// If the <paramref name="ObjectCounterNotifier"/> notifier is set, the notifier is launched.
        /// </summary>
        /// <param name="counter"></param>
        private void CheckObjectCount(ObjectCategory counter)
        {
            if(counter == null) {
                throw new ArgumentNullException("counter");
            }

            if(counter.MaximumCount > 0 && counter.Count > counter.MaximumCount && counter.Enabled) {
                if(OnObjectCountExceeded != null) {
                    OnObjectCountExceeded(counter.Type, counter.Name, counter.Count);
                }

                // show the notifier
                if(ObjectCounterNotifier != null && ObjectCounterNotifier.Enabled) {
                    ObjectCounterNotifier.CounterType = counter.Type;
                    ObjectCounterNotifier.CounterName = counter.Name;
                    ObjectCounterNotifier.CounterCount = counter.Count;
                    ObjectCounterNotifier.CounterMaximumCount = counter.MaximumCount;
                    ObjectCounterNotifier.Counter = this;

                    if(!ObjectCounterNotifier.Launch()) {
                        Console.WriteLine("Couldn't launch IObjectCounterNotifier {0}",
                                          ObjectCounterNotifier.GetType().Name);
                    }

                    // check if the counter was disabled
                    if(ObjectCounterNotifier.CounterEnabled.HasValue &&
                       ObjectCounterNotifier.CounterEnabled == false) {
                        counter.Enabled = false;
                    }
                }

                if(_autoResetCounter) {
                    counter.Count = 0;
                }
            }
        }