Ejemplo n.º 1
0
        public async Task <ActionResult> SearchByTags(TypeObj typeObj)
        {
            // make another games API call
            // call for Games, with a title of 'titleToSearchBy'
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://api.rawg.io/api/tags");

            HttpResponseMessage response = await client.GetAsync("?search=" + typeObj.TypeTitle);

            List <Item> itemsToChooseFrom = new List <Item>();

            if (response.IsSuccessStatusCode)
            {
                string data = await response.Content.ReadAsStringAsync();

                JObject jsonResults = JsonConvert.DeserializeObject <JObject>(data);


                for (int i = 0; i < 10; i++)
                {
                    JToken name = jsonResults["results"][i]["name"];

                    Item randomItem = new Item();
                    randomItem.Name = name.ToString();


                    itemsToChooseFrom.Add(randomItem);
                }
            }

            return(View("GamesIndex", itemsToChooseFrom));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将指定值装入ValueObject
        /// </summary>
        /// <typeparam name="T">值类型</typeparam>
        /// <param name="value">要装入的值</param>
        /// <returns></returns>
        static public ValueObject Get <T>(T value)
        {
#if UNITY_EDITOR
            if (!typeof(T).IsValueType)
            {
                throw new InvalidOperationException(
                          string.Format("Only value type supported! type = <{0}>", typeof(T)));
            }
#endif

            // 装箱
            TypeObj <T> typeObj = ObjPool <TypeObj <T> > .Get();

            typeObj.value = value;

            ValueObject betterObj = null;
            lock (mValueObjPool)
            {
#if UNITY_EDITOR
                detecter.IncreseInstance();
#endif
                betterObj = mValueObjPool.Count > 0 ? mValueObjPool.Dequeue() : new ValueObject();
            }
            betterObj.mObjType       = typeof(T);
            betterObj.mTypeObj       = typeObj;
            betterObj.mTypeObjHolder = ObjPool <TypeObj <T> > .instance;
            return(betterObj);
        }
Ejemplo n.º 3
0
    public ReadObject(string text, TypeObj t)
    {
        this.t = t;

        TypedObject = new GameObject();
        TypedObject.transform.SetParent(ReadEvent.Instance.goForm.transform);
        RectTran      = TypedObject.AddComponent <RectTransform>();
        TextParametrs = TypedObject.AddComponent <TextMeshProUGUI>();

        TextParametrs.font = ReadEvent.Instance.Font;
        if (t == TypeObj.Text)
        {
            TextParametrs.fontSize = 28;
            TextParametrs.text     = text;
        }
        else if (t == TypeObj.Title)
        {
            TextParametrs.fontSize  = 42;
            TextParametrs.text      = text;
            TextParametrs.alignment = TextAlignmentOptions.Center;
        }
        TextParametrs.raycastTarget      = false;
        TextParametrs.enableWordWrapping = true;
        TextParametrs.color = Color.black;

        RectTran.sizeDelta     = new Vector2(ReadEvent.width - ReadEvent.SpaceFortext, 0f);
        RectTran.localPosition = new Vector3(100f, 100f, 100f); //Делается для красивого появления
    }
Ejemplo n.º 4
0
		public string getValue(string name, TypeObj typeObj)
		{
			if (typeObj == null || typeObj.field == null || typeObj.field == "" || typeObj.field.Length == 0)
			{
				return getValueByName(name);
			}
			JToken t = Value.SelectToken(typeObj.field);
			if (t == null)
				return null;
			return t.ToString();
		}
Ejemplo n.º 5
0
        /// <summary>
        /// 拆箱为所指定的类型数据,不释放缓存
        /// </summary>
        /// <typeparam name="T">要拆箱的数据类型</typeparam>
        /// <returns></returns>
        public T Value <T>()
        {
#if UNITY_EDITOR
            if (!typeof(T).IsValueType)
            {
                throw new InvalidOperationException(
                          string.Format("Only value type supported! type = <{0}>", typeof(T)));
            }
#endif
            // 拆箱
            if (typeof(T) != mObjType)
            {
                throw new InvalidCastException(string.Format("ExceptedType = <{0}>, TryGetType = <{1}>",
                                                             mObjType, typeof(T)));
            }
            TypeObj <T> target = mTypeObj as TypeObj <T>;
            return(target.value);
        }
Ejemplo n.º 6
0
 public static LLVMTypeRef ToLLVM(this TypeObj obj)
 {
     if (obj == BuiltIns.Int)
     {
         return(LLVM.Int32Type());
     }
     else if (obj == BuiltIns.Float)
     {
         return(LLVM.FloatType());
     }
     else if (obj == BuiltIns.Bool)
     {
         return(LLVM.Int1Type());
     }
     else
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 7
0
 public void Visit(TypeObj typeObj)
 {
     throw new InvalidOperationException();
 }
Ejemplo n.º 8
0
        public ActionResult SearchByTags()
        {
            TypeObj input = new TypeObj();

            return(View(input));
        }
Ejemplo n.º 9
0
        private void CreateFace(Vector3 a, Vector3 b, Face face, bool even, bool hasDoor = false, List <bool> windowsLits = null)
        {
            #region Setup

            Vector2 _a;
            Vector2 _b;
            float   missingAxis;
            Vector3 normal;

            bool isRoof = face == Face.Up;

            if (face == Face.Up || face == Face.Down)
            {
                //removing y
                _a          = new Vector2(a.x, a.z);
                _b          = new Vector2(b.x, b.z);
                missingAxis = a.y;
                normal      = face == Face.Up ? Vector3.up : Vector3.down;
            }
            else if (face == Face.Right || face == Face.Left)
            {
                //removing x
                _a          = new Vector2(a.z, a.y);
                _b          = new Vector2(b.z, b.y);
                missingAxis = a.x;
                normal      = face == Face.Right ? Vector3.right : Vector3.left;
            }
            else if (face == Face.Forward || face == Face.Back)
            {
                //removing z
                _a          = new Vector2(a.x, a.y);
                _b          = new Vector2(b.x, b.y);
                missingAxis = a.z;
                normal      = face == Face.Forward ? Vector3.forward : Vector3.back;
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(face), face, null);
            }

            #endregion

            //Set ProceduralFace Value

            float doorIndex = Random.Range(((int)0), ((int)(_b.x - _a.x)) - 2) + _a.x + 1;

            for (float y = _a.y; y < _b.y; y++)
            {
                for (float x = _a.x; x < _b.x; x++)
                {
                    #region Get Matrix

                    Vector3    position;
                    Quaternion rotation;
                    var        realX = x + .5f;
                    var        realY = y + .5f;
                    if (face == Face.Up || face == Face.Down)
                    {
                        position = new Vector3(realX, missingAxis, realY);
                        rotation = Quaternion.LookRotation(-normal, face == Face.Up ? Vector3.forward : Vector3.back);
                    }
                    else if (face == Face.Right || face == Face.Left)
                    {
                        position = new Vector3(missingAxis, realY, realX);
                        rotation = Quaternion.LookRotation(-normal, Vector3.up);
                    }
                    else if (face == Face.Forward || face == Face.Back)
                    {
                        position = new Vector3(realX, realY, missingAxis);
                        rotation = Quaternion.LookRotation(-normal, Vector3.up);
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException(nameof(face), face, null);
                    }

                    //var quadName = "Quad - " + face + " - ( " + x.ToString("F1") + " : " + y.ToString("F1") + " )";

                    ObjData obj = new ObjData(position, rotation, Vector3.one);
                    #endregion

                    #region Load Obj in GPULoader

                    Material mat = towerMaterialsAssembly.BackGroundMat;
                    if (!isRoof)
                    {
                        if (y < 2) //Ground
                        {
                            if (hasDoor && Math.Abs(doorIndex - x) < 0.1f)
                            {
                                mat = towerMaterialsAssembly.DoorMat;
                            }
                        }
                        else if (y < _b.y)
                        {
                            bool isEven = Mathf.RoundToInt(y - _a.y) % 2 == 0;
                            if ((isEven && even) || (!isEven && !even))
                            {
                                bool windowsLit = windowsLits?[Mathf.RoundToInt(y - _a.y)] ?? RandomBool;
                                if (windowsLit)
                                {
                                    mat = towerMaterialsAssembly.WindowsLitMat;
                                }
                                else
                                {
                                    mat = towerMaterialsAssembly.WindowsUnlitMat;
                                }
                            }
                        }
                    }

                    //Set the matrix4x4 in the matrix corresponding to it's material and mesh
                    var tpObj = new TypeObj(_mesh, mat);
                    if (!_gpuLoader.DicBatches.ContainsKey(tpObj))
                    {
                        _gpuLoader.DicBatches.Add(tpObj, new List <List <ObjData> >());
                    }

                    if (_gpuLoader.DicBatches[tpObj].Count == 0 || _gpuLoader.DicBatches[tpObj][_gpuLoader.DicBatches[tpObj].Count - 1].Count >= 1000)
                    {
                        _gpuLoader.DicBatches[tpObj].Add(new List <ObjData>());
                    }
                    _gpuLoader.DicBatches[tpObj][_gpuLoader.DicBatches[tpObj].Count - 1].Add(obj);

                    #endregion
                }
            }
        }
Ejemplo n.º 10
0
 public void Visit(TypeObj typeObj)
 {
     throw new Exception("Not implemented");
 }
Ejemplo n.º 11
0
 public Parameter(int index, TypeObj type)
 {
     Name = ((char)('a' + index)).ToString();
     Type = type;
 }