Exemple #1
0
        /// <summary>
        /// 游戏对象:出池
        /// </summary>
        /// <param name="objTag">对象标签</param>
        /// <typeparam name="T">对象类型</typeparam>
        /// <returns></returns>
        internal T Spawn <T>(ObjectTag objTag) where T : ObjectBase
        {
            lock (ObjectPoolDic)
            {
                Queue <GameObject> queue;

                if (!ObjectPoolDic.TryGetValue(objTag, out queue))
                {
                    queue = new Queue <GameObject>();
                    ObjectPoolDic.Add(objTag, queue);
                }

                T t;

                if (queue.Count > 0)
                {
                    GameObject go = queue.Dequeue();
                    t = go.GetComponent <T>();
                }
                else
                {
                    t = OnNeedCreateNewObject <T>(objTag);
                }

                t.gameObject.SetActive(true);
                //当出池
                t.OnSpawn();

                #if UNITY_EDITOR
                DequeueAndEnqueueCount(objTag, 1);
                #endif

                return(t);
            }
        }
Exemple #2
0
        private void CreateNodeClick(object sender, RoutedEventArgs e)
        {
            if (tvUISTree.SelectedItem is TreeViewItem tvi &&
                tvi.Header is UISObject obj &&
                obj is UISList lst)
            {
                Type listType = lst.GetListType();
                if (listType == typeof(UISObject))
                {
                    AllowTag = new ObjectTag[] { ObjectTag.AnimationDefine, ObjectTag.Comment, ObjectTag.Predefined, ObjectTag.Functional, ObjectTag.Custom, ObjectTag.List };
                }
                else if (listType == typeof(UISProperty))
                {
                    AllowTag = Enum.GetValues(typeof(Property));
                }
                else if (listType == typeof(UISAnimation))
                {
                    AllowTag = Enum.GetValues(typeof(AnimationName));
                }
                else if (listType == typeof(UISFunctionalElement))
                {
                    AllowTag = Enum.GetValues(typeof(FunctionElementType));
                }
                else
                {
                    ObjectTag tag = PropertyConstraint.GetPropertyConstraint <ObjectTag>(lst.GetListType());
                    AllowTag = new ObjectTag[] { tag };
                }

                ShowModalDialog(true);
                this.PopupContent.LoadDialog(Dialog.CreateNode);
            }
        }
Exemple #3
0
        public void Handle(SimpleProto data)
        {
            if (null != data)
            {
                int positionHandler = data.Ins[0];

                Contexts contexts = SingletonManager.Get <FreeUiManager>().Contexts1;

                if (positionHandler == (int)EPositionHandler.EPosition_Init)
                {
                    string type  = data.Ss[0];
                    int    mapId = contexts.session.commonSession.RoomInfo.MapId;

                    Clear();

                    TestPositionManager.IniTable(mapId, type);
                    List <TestPosition> testPositions = TestPositionManager.GetTestPositions();
                    for (int i = 0, maxi = (null == testPositions ? 0 : testPositions.Count); i < maxi; i++)
                    {
                        TestPosition testPosition = testPositions[i];
                        Vector3      position     = new Vector3(testPosition.x, testPosition.y, testPosition.z);
                        float        rotation     = testPosition.rotation;
                        string       timeStamp    = testPosition.time;
                        CreateGameObject(position, rotation, timeStamp);
                    }
                }
                else if (positionHandler == (int)EPositionHandler.EPosition_Add)
                {
                    Vector3    position  = contexts.player.flagSelfEntity.position.Value;
                    GameObject rootGo    = contexts.player.flagSelfEntity.RootGo();
                    string     timeStamp = TimeStamp();
                    CreateGameObject(position, rootGo.transform.eulerAngles.y, timeStamp);
                    TestPositionManager.Add(position, rootGo.transform.eulerAngles.y, timeStamp);
                }
                else if (positionHandler == (int)EPositionHandler.EPosition_Remove)
                {
                    Vector3    position = contexts.player.flagSelfEntity.position.Value;
                    GameObject rootGo   = contexts.player.flagSelfEntity.RootGo();

                    Bounds bounds = new Bounds(position, Vector3.one);

                    ObjectTag[] objectTags = GameObject.FindObjectsOfType <ObjectTag>();
                    for (int i = 0, maxi = (null == objectTags ? 0 : objectTags.Length); i < maxi; i++)
                    {
                        ObjectTag objectTag = objectTags[i];
                        if (null == objectTag)
                        {
                            continue;
                        }

                        if (bounds.Contains(objectTag.transform.position))
                        {
                            TestPositionManager.Delete(objectTag.gameObject.name);
                            GameObject.DestroyImmediate(objectTag.gameObject);
                            objectTags[i] = null;
                        }
                    }
                }
            }
        }
Exemple #4
0
 public void AddTag(ObjectTag tag)
 {
     if (!ObjectTagList.Contains(tag))
     {
         ObjectTagList.Add(tag);
     }
 }
Exemple #5
0
        /**
         * <summary>Deserialize an ObjectTag back into an object.</summary>
         * <param name="tag">The object tag.</param>
         * <typeparam name="T">The Class to deserialize into.</typeparam>
         * <returns>The deserialized object.</returns>
         */
        public static T Deserialize <T>(ObjectTag tag)
        {
            if (!tag.HasTag("ODS_TAG"))
            {
                throw new Exception("Cannot deserialze tag: This tag was not serialzed!");
            }

            string   classname = ((StringTag)tag.GetTag("ODS_TAG")).GetValue();
            Assembly asm       = Assembly.GetEntryAssembly();
            Type     mainType  = asm.GetType(classname);

            BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
            object       obj   = Activator.CreateInstance(mainType);

            foreach (FieldInfo field in mainType.GetFields(flags))
            {
                if (field.GetCustomAttribute(typeof(ODSSerializeable)) == null)
                {
                    continue;
                }
                ITag fTag = tag.GetTag(field.Name);
                field.SetValue(obj, unwrap(fTag));
            }

            return((T)obj);
        }
Exemple #6
0
        public void DeleteListObjectTagsBusinessAsync(List <Guid> listTags, Guid objectId, string objectType)
        {
            try
            {
                if (listTags.Count() > 0)
                {
                    List <ObjectTag> objectTags = new List <ObjectTag>();
                    foreach (Guid objectTagId in listTags)
                    {
                        ObjectTag objectTag = _uow.GetRepository <ObjectTag>().Get(objectTagId);
                        objectTags.Add(objectTag);
                    }

                    if (objectTags.Count() > 0)
                    {
                        _uow.GetRepository <ObjectTag>().DeleteRange(objectTags);
                        _uow.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
Exemple #7
0
        // Get tag list Many to Many
        public List <ObjectTag> GetObjectTagsManyToManyAsync(List <Guid> listTags, Guid objectId, string objectType)
        {
            try
            {
                _logger.LogWarning("Create Object Tag");
                List <ObjectTag> objectTags = new List <ObjectTag>();
                foreach (var tagId in listTags)
                {
                    ObjectTag objectTag = new ObjectTag
                    {
                        TagId      = tagId,
                        ObjectId   = objectId,
                        ObjectType = objectType
                    };
                    objectTags.Add(objectTag);
                }

                return(objectTags);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
Exemple #8
0
        public async Task <List <ObjectTag> > CreateObjectTagsAsync(List <Guid> listTags, Guid objectId, string objectType)
        {
            try
            {
                _logger.LogWarning("Create Object Tag");
                List <ObjectTag> objectTags = new List <ObjectTag>();
                foreach (var tagId in listTags)
                {
                    ObjectTag objectTag = new ObjectTag
                    {
                        TagId      = tagId,
                        ObjectId   = objectId,
                        ObjectType = objectType
                    };
                    objectTags.Add(objectTag);
                }

                _uow.GetRepository <ObjectTag>().AddAsync(objectTags);
                _uow.SaveChanges();
                return(await Task.FromResult(objectTags));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message.ToString());
                throw ex;
            }
        }
Exemple #9
0
        /// <summary>
        /// Find all the colliders that intersect the given sphere.
        /// </summary>
        /// <param name="position">Absolute position of the sphere-center.</param>
        /// <param name="radius">Radius of the sphere.</param>
        /// <param name="collisionTag">Only check for a specific tag.</param>
        /// <returns>List of all colliders which are contained in the given sphere.</returns>
        public static Collider[] OverlapSphere(Vector3 position, float radius, ObjectTag collisionTag = ObjectTag.Default)
        {
            SphereShape sphere   = new SphereShape(radius);
            Collider    rbSphere = new Collider(sphere)
            {
                Position     = Conversion.ToJitterVector(position),
                PureCollider = true,
                Tag          = BodyTag.TestObject
            };

            // Prepare the instance to handle the detected collisions correctly
            Instance._status    = CollisionState.SaveInList;
            Instance._colliders = new List <Collider>();

            foreach (RigidBody rb in Instance.World.RigidBodies)
            {
                Collider c = rb as Collider;
                if (c != null && ((collisionTag != ObjectTag.Default && c.GameObject.tag != collisionTag) || !c.GameObject.active))
                {
                    continue;
                }

                try {
                    Instance.World.CollisionSystem.Detect(rbSphere, rb);
                } catch (Exception ex) {
                    Debug.LogError(ex.Message);
                }
            }

            Instance._status = CollisionState.Propagate;

            return(Instance._colliders.ToArray());
        }
Exemple #10
0
 public static bool IsObjectCompatible(ObjectTag obj_tag, FurnitureTag furn_tag)
 {
     if (ObjectCompatibilityDict[obj_tag].Contains(furn_tag))
     {
         return(true);
     }
     return(false);
 }
Exemple #11
0
        /// <summary>
        /// 通过对象标签查找对象基础信息
        /// </summary>
        /// <param name="tag">要搜索的标记</param>
        /// <returns>返回一个 ObjectPoolBasicInfo 对象。如果没有找到ObjectPoolBasicInfo,返回null</returns>
        public ObjectPoolBasicInfo FindInfoWithObjectTag(ObjectTag tag)
        {
            ObjectPoolBasicInfo info;

            if (!ObjectInfoDic.TryGetValue(tag, out info))
            {
                Debug.LogError(string.Format("没有找到 {0:s} 对应的的数据, 请检查源数据", tag.ToString()));
                return(null);
            }
            return(info);
        }
        public ActionResult des(int id, int pageIndex = 1)
        {
            if (Common.UserInfo == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            //记录用户的浏览行为
            Common.PageView(id, 2, Common.UserInfo.User_ID);
            Common.ModifyPageView(id, 2);


            int pageNum = Convert.ToInt32(Math.Ceiling(ques.GetAnswerNum(id) / 10.0));

            ViewBag.pageNum = pageNum;
            if (pageNum <= 0)
            {
                ViewBag.AnswerList = null;
            }
            else if (pageIndex < 1)
            {
                //3、根据课程ID获取课程评论信息
                List <Answers> an_list = ques.GetAnswer_Page(id, 1, 10, 5);
                ViewBag.AnswerList       = an_list;
                ViewBag.CurrentPageIndex = 1;
            }
            else if (pageIndex > pageNum)
            {
                //3、根据课程ID获取课程评论信息
                List <Answers> an_list = ques.GetAnswer_Page(id, pageNum, 10, 5);
                ViewBag.AnswerList       = an_list;
                ViewBag.CurrentPageIndex = pageNum;
            }
            else
            {
                //3、根据课程ID获取课程评论信息
                List <Answers> an_list = ques.GetAnswer_Page(id, pageIndex, 10, 5);
                ViewBag.AnswerList       = an_list;
                ViewBag.CurrentPageIndex = pageIndex;
            }

            //获取问题的回答
            //List<Answers> answerList = ques.GetAnswer_Page(id);
            //ViewBag.AnswerList = answerList;

            //获取相关问题,先找到当前问题的标签,也就是问题来自哪儿,获取标签中含有这些标签的问题,根据热度排序,获取TopN5
            List <int>       tagids = Common.GetFrom_Question(id).Select(n => n.Nav_ID).ToList();
            List <Questions> list   = new ObjectTag().GetQuestionByTags_TopN(id, tagids, 5);

            Questions question = ques.GetList_Where(q => q.Q_ID == id).FirstOrDefault();

            ViewBag.RelevantQuestion = list;
            ViewBag.TagList          = Common.GetFrom_Question(id);
            return(View(question));
        }
Exemple #13
0
 /// <summary>
 /// 出池与回池计数
 /// </summary>
 /// <param name="objTag">对象标签</param>
 /// <param name="variable"></param>
 private void DequeueAndEnqueueCount(ObjectTag objTag, int variable)
 {
     if (ObjectPoolExternalNumDic.ContainsKey(objTag))
     {
         ObjectPoolExternalNumDic[objTag] += variable;
     }
     else
     {
         ObjectPoolExternalNumDic[objTag] = 1;
     }
 }
 protected ObjectModel(ObjectModel parent, string name, Type type, object value, ModelOptions options, ObjectTag tag = ObjectTag.Edit)
 {
     Parent     = parent;
     Name       = name;
     Value      = value;
     Type       = type;
     ObjectType = type.GetObjectType();
     Level      = Parent == null ? 0 : Parent.Level + 1;
     Options    = options;
     Tag        = Parent == null ? tag : Options.GetOperationFor(parent.Type, name, tag);
 }
Exemple #15
0
        /// <summary>
        /// 需要生成新的对象
        /// </summary>
        /// <param name="objTag">对象标签</param>
        /// <typeparam name="T">对象类型</typeparam>
        /// <returns></returns>
        private T OnNeedCreateNewObject <T>(ObjectTag objTag) where T : ObjectBase
        {
            GameObject go = m_ObjectPoolSource.FindInfoWithObjectTag(objTag).Prefab;

            go = GameObject.Instantiate(go);
            T t = go.AddComponent <T>();

            //需要初始化
            t.Init(objTag);

            return(t);
        }
 protected override bool CollsionEnter(float dt, ObjectTag tags)
 {
     if (dt >= 0.0f && dt <= 1.0f) {
         hp--;
         if (hp <= 0) {
             Break();
             EffectManager.getInstance.setEffect(px, py, 0.7f);
         }
         return true;
     }
     return false;
 }
        void Init()
        {
            tGD      = TouchGestureDetector.Instance;
            progress = Progress.Instance;
            ImportItems();
            galleryPanel.localPosition = new Vector3(0, 0, 0);
            galleryPanel.sizeDelta     = new Vector2(1080, 1920);


            ObjectTag  hitTag = ObjectTag.None;
            GameObject hitObj = null;

            //tGD.onGestureDetected.AddListener((gesture, touchInfo) =>
            //{
            //    if (gesture == TouchGestureDetector.Gesture.TouchBegin)
            //    {
            //        hitTag = ObjectTag.None;
            //        if (touchInfo.HitDetection(out hitObj, TouchObjects[ObjectTag.Return]))
            //        {
            //            hitTag = ObjectTag.Return;
            //        }
            //    }
            //    if (gesture == TouchGestureDetector.Gesture.Click)
            //    {
            //        //Debug.Log(hitObj.name);
            //        if (hitTag == ObjectTag.Return
            //        && touchInfo.HitDetection(out hitObj, TouchObjects[ObjectTag.Return]))
            //        {
            //            SceneFader.Instance.FadeOut(SceneFader.SceneTitle.Home);
            //            ////Debug.Log(hitObj.name);
            //            //switch (hitTag)
            //            //{
            //            //    case ObjectTag.Return:
            //            //        break;
            //            //    //case ObjectTag.LeftArrow:
            //            //    //    ToLeft();
            //            //    //    break;
            //            //    //case ObjectTag.RightArrow:
            //            //    //    ToRight();
            //            //    //    break;
            //            //    default:
            //            //        break;
            //            //}
            //        }

            //    }
            //});
            LeftArrow.onClick.AddListener(() => { ToLeft(); });
            RightArrow.onClick.AddListener(() => { ToRight(); });

            ListReset();
        }
Exemple #18
0
        public void TestObjectSpeed()
        {
            ObjectTag objectTag = Helpers.GenerateObjectTag();

            using (MemoryStream ms = new MemoryStream())
            {
                objectTag.WriteTo(ms);
                ms.Position = 0;
                Tag.ReadFrom(ms);

                this.TestTagSpeed(ms, objectTag);
            }
        }
Exemple #19
0
        public void Init(Item data, GalleryManager gM)
        {
            touchGestureDetector = TouchGestureDetector.Instance;
            galleryM             = gM;

            ObjectTag  touchTag    = ObjectTag.None;
            GameObject beginObject = null;

            if (!Reflect(data))
            {
                touchGestureDetector.onGestureDetected.AddListener((gesture, touchInfo) =>
                {
                    if (gesture == TouchGestureDetector.Gesture.TouchBegin)
                    {
                        touchTag    = ObjectTag.None;
                        beginObject = null;
                        if (touchInfo.HitDetection(out beginObject, charaObj[2]))
                        {
                            touchTag = ObjectTag.Character;
                        }
                        //if (touchInfo.HitDetection(out beginObject, returnObj))
                        //{
                        //    touchTag = ObjectTag.ReturnObj;
                        //}
                        if (touchInfo.HitDetection(out beginObject, soundIcon))
                        {
                            touchTag = ObjectTag.Sound;
                        }
                    }
                    if (gesture == TouchGestureDetector.Gesture.Click)
                    {
                        GameObject hit;
                        if (touchTag == ObjectTag.Character &&
                            touchInfo.HitDetection(out hit, charaObj[2]))
                        {
                            galleryM.CharacterSpeak(person.voice);
                        }
                        if (touchTag == ObjectTag.Sound &&
                            touchInfo.HitDetection(out hit, soundIcon))
                        {
                            galleryM.CharacterSpeak(person.voice);
                        }
                        //if (touchTag == ObjectTag.ReturnObj
                        //&& touchInfo.HitDetection(out hit, returnObj))
                        //{
                        //    galleryM.ContentClose();
                        //}
                    }
                });
            }
        }
Exemple #20
0
 /**
  * <summary>Unwrap a tag and turn it back into its original value. This method will not work for Lists or Dictionaries.</summary>
  * <param name="tag">The tag to unwrap.</param>
  * <typeparam name="T">The c# datatype represented by the tag.</typeparam>
  * <returns>The value of the tag.</returns>
  */
 public static T UnWrap <T>(Tag <T> tag)
 {
     if (tag.GetType() == typeof(ObjectTag))
     {
         ObjectTag objTag    = (ObjectTag)tag;
         StringTag clazzName = (StringTag)objTag.GetTag("ODS_TAG");
         if (clazzName == null)
         {
             throw new Exception("Cannot unwrap object: TagObject is not a serialized object");
         }
         return((T)Deserialize <object>(objTag));
     }
     return(tag.GetValue());
 }
Exemple #21
0
        private static void Clear()
        {
            ObjectTag[] objectTags = GameObject.FindObjectsOfType <ObjectTag>();
            for (int i = 0, maxi = (null == objectTags ? 0 : objectTags.Length); i < maxi; i++)
            {
                ObjectTag objectTag = objectTags[i];
                if (null == objectTag)
                {
                    continue;
                }

                GameObject.DestroyImmediate(objectTag.gameObject);
                objectTags[i] = null;
            }
        }
Exemple #22
0
 /**
  * <summary>This method is to unwrap tags manualy. Due to the limitations of C# I cannot use the UnWrap methods and generics cannot have wildcards.</summary>
  */
 private static object unwrap(ITag tag)
 {
     if (tag.GetType() == typeof(ObjectTag))
     {
         ObjectTag objTag    = (ObjectTag)tag;
         StringTag clazzName = (StringTag)objTag.GetTag("ODS_TAG");
         if (clazzName == null)
         {
             throw new Exception("Cannot unwrap object: TagObject is not a serialized object");
         }
         return(Deserialize <object>(objTag));
     }
     if (tag.GetType() == typeof(ByteTag))
     {
         return(((ByteTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(CharTag))
     {
         return(((CharTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(DoubleTag))
     {
         return(((DoubleTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(FloatTag))
     {
         return(((FloatTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(IntTag))
     {
         return(((IntTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(LongTag))
     {
         return(((LongTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(ShortTag))
     {
         return(((ShortTag)tag).GetValue());
     }
     if (tag.GetType() == typeof(StringTag))
     {
         return(((StringTag)tag).GetValue());
     }
     return(null);
 }
Exemple #23
0
        protected virtual void showProperties()
        {
            Debug.Assert(!(_grid.Selected.Rows.Count == 0), "Attempt to show snapshot properties with no selections");
            Debug.Assert(!(_grid.Selected.Rows.Count > 1), "Attempt to show snapshot properties for multiple selections");

            if (m_serverInstance != null && Sql.RegisteredServer.IsServerRegistered(m_serverInstance.ConnectionName))
            {
                int           snapshotId = (int)_grid.ActiveRow.Cells[colId].Value;
                Sql.ObjectTag tag        = new ObjectTag(snapshotId, Sql.ObjectType.TypeEnum.Snapshot);

                Forms.Form_SnapshotProperties.Process(tag);
            }
            else
            {
                Utility.MsgBox.ShowError(Utility.ErrorMsgs.SnapshotPropertiesCaption, Utility.ErrorMsgs.ServerNotRegistered);
                Program.gController.SignalRefreshServersEvent(false, null);
            }
        }
Exemple #24
0
        public async Task TestObjectSerialization()
        {
            ObjectTag objectTag = Helpers.GenerateObjectTag();

            using (MemoryStream ms = new MemoryStream())
                using (FileStream fs = File.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Object.nbt")))
                {
                    objectTag.WriteTo(ms);

                    ms.Position = 0;
                    await ms.CopyToAsync(fs);

                    Console.WriteLine("Finished object serialization.");

                    ms.Position = 0;
                    Assert.IsTrue(objectTag.Equals(Tag.ReadFrom <ObjectTag>(ms)));
                }
        }
Exemple #25
0
        private static void CreateGameObject(Vector3 position, float rotation, string timeStamp)
        {
            GameObject  testObj     = GameObject.CreatePrimitive(PrimitiveType.Cube);
            BoxCollider boxCollider = testObj.GetComponent <BoxCollider>();

            if (null != boxCollider)
            {
                boxCollider.enabled = false;
            }
            testObj.transform.position    = new Vector3(position.x, position.y, position.z);
            testObj.transform.eulerAngles = new Vector3(0, rotation, 0);
            testObj.transform.localScale  = new Vector3(0.5f, 2, 0.5f);

            ObjectTag objectTag = testObj.AddComponent <ObjectTag>();

            objectTag.tag = (int)EObjectTag.TestPosition;

            testObj.name = timeStamp;
        }
Exemple #26
0
        private void GetDetectableObjects()
        {
            List <VirtualObject> objectsInTheHouse = new List <VirtualObject>(m_enviromentManager.house.virtualObjects);

            foreach (string objectClass in m_ontologySystem.objectClassInOntology)
            {
                try
                {
                    var       match     = m_classMatching.Find(match => match.ClassInOntology.Equals(objectClass));
                    ObjectTag objectTag = (match.ClassInOntology == null) ? (ObjectTag)Enum.Parse(typeof(ObjectTag), objectClass) : match.ClassInVirtualEnvironment;
                    m_detectableObjects.AddRange(objectsInTheHouse.FindAll(o => o.tags.Contains(objectTag)));
                }
                catch (ArgumentException)
                {
                    Log(objectClass + " failed to convert to ObjectTag", LogLevel.Developer);
                }
            }
            m_detectableObjects = m_detectableObjects.Distinct().ToList();
        }
Exemple #27
0
    public GameObject SpawnFormPool(ObjectTag tag, Vector3 position, Quaternion rotation)
    {
        if (!poolDictionary.ContainsKey(tag))
        {
            Debug.LogWarning("Pool with tag " + tag + " doesn't exist!");
            return(null);
        }
        GameObject obj = poolDictionary[tag].Dequeue();

        obj.SetActive(true);
        obj.transform.GetChild(0).position = Vector3.zero;
        obj.transform.GetChild(0).rotation = Quaternion.Euler(Vector3.up * 180f);

        obj.transform.position = position;
        obj.transform.rotation = rotation;

        poolDictionary[tag].Enqueue(obj);

        return(obj);
    }
Exemple #28
0
        public static ObjectTagResponse ToApiModel(this ObjectTag model)
        {
            var temp = new ObjectTagResponse()
            {
                Id       = model.Id,
                Name     = model.Name,
                Category = new IdNamePair <long>()
                {
                    Id = model.CategoryId, Name = model.Category.Name
                },
                ObjectUri      = model.ObjectUri,
                OptionalUri    = model.OptionalUri,
                BookingEnabled = model.IsBookingEnabled,
                Description    = model.Description,
                ImageUri       = model.GetImageUri(),
                Place          = model.Place
            };

            return(temp);
        }
        public static ObjectTag ToDataModel(this ObjectTagRequest request, ObjectTag item = null)
        {
            if (item == null)
            {
                item = new ObjectTag()
                {
                    Id = Guid.NewGuid().ToString()
                };
            }
            else
            {
                item.Id = request.Id;
            }

            item.CategoryId       = request.Category;
            item.Description      = request.Description;
            item.IsBookingEnabled = request.BookingEnabled;
            item.Name             = request.Name;
            item.ObjectUri        = request.ObjectUri;
            item.OptionalUri      = request.OptionalUri;
            item.Place            = request.Place;
            return(item);
        }
Exemple #30
0
        /**
         * <summary>Serialize an object.</summary>
         * <param name="name">The name of the object.</param>
         * <param name="obj">The object to serialize.</param>
         * <returns>The serialized ObjectTag</returns>
         */
        public static ObjectTag Serialize(string name, object obj)
        {
            ObjectTag objectTag = new ObjectTag(name);
            Type      type      = obj.GetType();

            objectTag.AddTag(new StringTag("ODS_TAG", type.FullName));
            BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            foreach (FieldInfo field in type.GetFields(flags))
            {
                if (field.GetCustomAttribute(typeof(ODSSerializeable)) == null)
                {
                    continue;
                }
                objectTag.AddTag(Wrap(field.Name, field.GetValue(obj)));
            }

            if (objectTag.GetValue().Count < 2)
            {
                throw new Exception("Cannot serialize object: No serializable fields detected!");
            }
            return(objectTag);
        }
Exemple #31
0
        public async Task SeedObjectTag()
        {
            for (var i = 1; i < 20; i++)
            {
                if (!_context.ObjectTags.Any(c => c.Name == $"PRML {i}巻"))
                {
                    //var category = _context.Categories.FirstOrDefault(c => c.Id == 5);
                    var item = new ObjectTag()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        Name        = $"PRML {i}巻",
                        Description = $"PRML {i}巻",
                        //Category = category,
                        CategoryId       = 5,
                        ObjectUri        = $"object://sample-{i}-{i / 2}",
                        Place            = $"場所{i}のあたり",
                        IsBookingEnabled = i % 2 == 0
                    };
                    _context.ObjectTags.Add(item);
                }
            }

            await _context.SaveChangesAsync();
        }
 public override bool TagCheck(ObjectTag tags)
 {
     return (tags == ObjectTag.ENEMY);
 }
 public override bool TagCheck(ObjectTag tags)
 {
     return !(tags == ObjectTag.ENEMY || tags == ObjectTag.ENEMYS_SHOOT || tags == ObjectTag.PLAYER);
 }
 protected virtual bool CollsionEnter(float dt, ObjectTag tags)
 {
     if (dt >= 0.0f && dt <= 1.0f) {
         Break();
         return true;
     }
     return false;
 }
 public virtual bool TagCheck(ObjectTag tags)
 {
     return true;
 }
 protected override bool CollsionEnter(float dt, ObjectTag tags)
 {
     if (dt >= 0.0f && dt <= 1.0f) {
         if (tags == ObjectTag.ENEMY) return true;
         if (tags == ObjectTag.ENEMYS_SHOOT) hp--;
     }
     return false;
 }