Exemplo n.º 1
0
        private void StartTween()
        {
            from = Position;
            to   = nodes[targetIdx];
            float duration = Vector2.Distance(from, to) / 12f;

            if (selfData.Get <bool>("fastMoving"))
            {
                duration /= 3f;
            }
            Tween tween = Tween.Create(Tween.TweenMode.Looping, Ease.SineInOut, duration, start: true);

            tween.OnUpdate = delegate(Tween t) {
                if (Collidable)
                {
                    MoveTo(Vector2.Lerp(from, to, t.Eased));
                }
                else
                {
                    MoveToNaive(Vector2.Lerp(from, to, t.Eased));
                }
            };
            tween.OnComplete = delegate(Tween t) {
                targetIdx++;
                if (targetIdx >= nodes.Length)
                {
                    targetIdx = 0;
                }
                from = Position;
                to   = nodes[targetIdx];
                selfData.Invoke("set_Duration", Vector2.Distance(from, to) / (selfData.Get <bool>("fastMoving") ?  36f : 12f));
            };
            Add(tween);
        }
Exemplo n.º 2
0
 protected override string GetCommandText(DynamicData param)
 {
     if (_template != null)
     {
         var pageIndex = (int)param.Get("pageIndex");
         var pageSize  = (int)param.Get("pageSize");
         return(_template.GetCode(pageIndex, pageSize));
     }
     return(null);
 }
Exemplo n.º 3
0
        private object GetObjectFromConstruct(DynamicData data)
        {
            var id = data.Get(EntityObject.IdPropertyName);

            if (this.Type == DataTableType.AggregateRoot)
            {
                return(GetObjectFromConstruct(id));
            }
            var rootId = data.Get(this.Root.TableIdName);

            return(GetObjectFromConstruct(rootId, id));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 执行查询对象集合的sql
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql"></param>
        /// <param name="fillArg"></param>
        /// <returns></returns>
        //private IEnumerable<T> ExecuteQueryObjects<T>(IQueryBuilder query, Action<DynamicData> fillArg)
        //{
        //    using (var paraTemp = SqlHelper.BorrowData())
        //    {
        //        var param = paraTemp.Item;
        //        fillArg(param);
        //        var sql = query.Build(param);

        //        using (var temp = SqlHelper.BorrowDatas())
        //        {
        //            var datas = temp.Item;
        //            SqlHelper.Query(this.ConnectionName, sql, param, datas);

        //            var tempList = ListPool<T>.Borrow();
        //            Symbiosis.Current.Mark(tempList);
        //            var list = tempList.Item;

        //            var elementType = typeof(T);
        //            foreach (var data in datas)
        //            {
        //                var item = (T)CreateObject(elementType, data);
        //                list.Add(item);
        //            }
        //            return list;
        //        }
        //    }
        //}

        #endregion

        #region 得到对象版本号


        /// <summary>
        /// 根据对象原始数据获取版本号
        /// </summary>
        internal int GetDataVersion(DynamicData originalData)
        {
            if (this.Type == DataTableType.AggregateRoot)
            {
                var id = originalData.Get(EntityObject.IdPropertyName);
                return(GetDataVersion(id));
            }
            else
            {
                var rootId = originalData.Get(this.Root.TableIdName);
                var id     = originalData.Get(EntityObject.IdPropertyName);
                return(GetDataVersion(rootId, id));
            }
        }
Exemplo n.º 5
0
        private void AddToConstructContext(DomainObject obj, DynamicData data)
        {
            object id = data.Get(EntityObject.IdPropertyName);

            if (this.Type == DataTableType.AggregateRoot)
            {
                ConstructContext.Add(id, obj);
            }
            else
            {
                object rootId = data.Get(this.Root.TableIdName);
                ConstructContext.Add(rootId, id, obj);
            }
        }
        protected IEnumerator ActivateSwitchCoroutine(TouchSwitch ts)
        {
            DynamicData switchData = new DynamicData(ts);

            switchData.Get <SoundSource>("touchSfx").Play("event:/game/general/touchswitch_any");
            switchData.Get <Sprite>("icon").Rate = 4;
            float ease = 1;

            while (ease > 0)
            {
                yield return(null);

                switchData.Get <Sprite>("icon").Rate = 1 + 3 * ease;
                ease -= Engine.DeltaTime;
            }
            switchData.Get <Sprite>("icon").Rate = 1;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 从条目数据中获取对象
        /// <para>如果加载的对象是聚合根,那么如果存在缓冲区中,那么使用缓冲区的对象,如果不存在,则在数据库中查询并更新缓冲区</para>
        /// <para>如果加载的是成员对象,那么始终从数据库中查询</para>
        /// <para>不论是什么类型的对象都可以识别继承类型</para>
        /// </summary>
        /// <returns></returns>
        private object GetObjectFromEntry(DynamicData entry, QueryLevel level)
        {
            if (this.Type == DataTableType.AggregateRoot)
            {
                object id          = entry.Get(EntityObject.IdPropertyName);
                int    dataVersion = (int)entry.Get(GeneratedField.DataVersionName);
                string typeKey     = (string)entry.Get(GeneratedField.TypeKeyName);
                var    table       = string.IsNullOrEmpty(typeKey) ? this : GetDataTable(typeKey);

                if (level.Code == QueryLevel.MirroringCode)
                {
                    //镜像查询会绕过缓冲区
                    return(table.LoadObject(id, QueryLevel.None));
                }

                return(DomainBuffer.GetOrCreate(table.ObjectTip.ObjectType, id, dataVersion, () =>
                {
                    return (IAggregateRoot)table.LoadObject(id, QueryLevel.None); //由于查询条目的时候已经锁了数据,所以此处不用再锁定
                }));
            }
            else
            {
                object rootId      = entry.Get(this.Root.TableIdName);
                object id          = entry.Get(EntityObject.IdPropertyName);
                int    dataVersion = (int)entry.Get(GeneratedField.DataVersionName);
                string typeKey     = (string)entry.Get(GeneratedField.TypeKeyName);
                var    table       = string.IsNullOrEmpty(typeKey) ? this : GetDataTable(typeKey);

                //非聚合根是不能被加入到缓冲区的
                return(table.LoadObject(rootId, id));
            }
        }
Exemplo n.º 8
0
        private object ReadMemberFromData(PropertyRepositoryAttribute tip, DynamicData data)
        {
            var name = _getNameWithSeparated(tip.PropertyName);

            using (var temp = SqlHelper.BorrowData())
            {
                var subData = temp.Item;
                foreach (var p in data)
                {
                    var dataName = p.Key;
                    if (dataName.StartsWith(name))
                    {
                        var subName = _getNextName(dataName);
                        subData.Add(subName, p.Value);
                    }
                }

                if (subData.IsEmpty())
                {
                    if (tip.DomainPropertyType == DomainPropertyType.AggregateRoot)
                    {
                        var idName = _getIdName(tip.PropertyName);
                        var id     = data.Get(idName);
                        return(ReadSnapshot(tip, id));
                    }
                    return(DomainObject.GetEmpty(tip.PropertyType));
                }


                var  typeKey    = (string)subData.Get(GeneratedField.TypeKeyName);
                Type objectType = null;
                if (this.IsDynamic)
                {
                    objectType = tip.PropertyType;
                }
                else
                {
                    objectType = string.IsNullOrEmpty(typeKey) ? tip.PropertyType : DerivedClassAttribute.GetDerivedType(typeKey);
                }


                var child = GetRuntimeTable(this, tip.PropertyName, objectType);
                //先尝试中构造上下文中得到
                return(child.GetObjectFromConstruct(subData) ?? child.CreateObject(objectType, subData, QueryLevel.None)); //成员始终是QueryLevel.None的方式加载
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 从条目数据中获取对象
        /// <para>如果加载的对象是聚合根,那么如果存在缓冲区中,那么使用缓冲区的对象,如果不存在,则在数据库中查询并更新缓冲区</para>
        /// <para>如果加载的是成员对象,那么始终从数据库中查询</para>
        /// <para>不论是什么类型的对象都可以识别继承类型</para>
        /// </summary>
        /// <returns></returns>
        private object GetObjectFromEntry(DynamicData entry, QueryLevel level)
        {
            if (this.Type == DataTableType.AggregateRoot)
            {
                object id          = entry.Get(EntityObject.IdPropertyName);
                int    dataVersion = (int)entry.Get(GeneratedField.DataVersionName);
                string typeKey     = (string)entry.Get(GeneratedField.TypeKeyName);
                var    table       = string.IsNullOrEmpty(typeKey) ? this : GetDataTable(typeKey);

                if (level.Code == QueryLevel.MirroringCode)
                {
                    //镜像查询会在加入到当前会话中的对象缓冲区,不同的会话有各自的镜像对象,同一个会话的同一个对象的镜像只有一个
                    var obj = DomainBuffer.Mirror.GetOrCreate(table.ObjectTip.ObjectType, id, dataVersion, () =>
                    {
                        return((IAggregateRoot)table.LoadObject(id, QueryLevel.Mirroring)); //由于查询条目的时候已经锁了数据,所以此处不用再锁定
                    });
                    DataContext.Current.AddMirror(obj);                                     //加入镜像
                    return(obj);
                }


                {
                    var obj = DomainBuffer.Public.GetOrCreate(table.ObjectTip.ObjectType, id, dataVersion, () =>
                    {
                        return((IAggregateRoot)table.LoadObject(id, QueryLevel.None)); //由于查询条目的时候已经锁了数据,所以此处不用再锁定
                    });
                    DataContext.Current.AddBuffer(obj);                                //加入数据上下文缓冲区
                    return(obj);
                }
            }
            else
            {
                object rootId      = entry.Get(GeneratedField.RootIdName);
                object id          = entry.Get(EntityObject.IdPropertyName);
                int    dataVersion = (int)entry.Get(GeneratedField.DataVersionName);
                string typeKey     = (string)entry.Get(GeneratedField.TypeKeyName);
                var    table       = string.IsNullOrEmpty(typeKey) ? this : GetDataTable(typeKey);

                //非聚合根是不能被加入到缓冲区的
                return(table.LoadObject(rootId, id));
            }
        }
Exemplo n.º 10
0
        public override void Render()
        {
            float ease = selfData.Get <float>("ease");

            if (ease <= 0f)
            {
                return;
            }
            Level level = Scene as Level;

            if (!level.FrozenOrPaused && level.RetryPlayerCorpse == null && !level.SkippingCutscene)
            {
                MTexture       box           = selfData.Get <MTexture>("box");
                Sprite         portrait      = selfData.Get <Sprite>("portrait");
                FancyText.Text text          = selfData.Get <FancyText.Text>("text");
                float          portraitScale = selfData.Get <float>("portraitScale");
                float          portraitSize  = selfData.Get <float>("portraitSize");
                int            index         = selfData.Get <int>("index");

                Vector2 vector = new Vector2(Engine.Width / 2, 72f + (Engine.Width - 1688f) / 4f);
                if (anchor == FancyText.Anchors.Bottom)
                {
                    vector.Y = Engine.Height - vector.Y;
                }
                else if (anchor == FancyText.Anchors.Middle)
                {
                    vector.Y = Engine.Height / 2;
                }
                Vector2 value = vector + new Vector2(-828f, -56f);

                box.DrawCentered(vector, Color.White, new Vector2(1f, ease));
                if (portrait != null)
                {
                    portrait.Scale          = new Vector2(1f, ease) * portraitScale;
                    portrait.RenderPosition = value + new Vector2(portraitSize / 2f, portraitSize / 2f);
                    portrait.Render();
                }
                text.Draw(new Vector2(value.X + portraitSize + 32f, vector.Y), new Vector2(0f, 0.5f), new Vector2(1f, ease) * 0.75f, 1f, 0, index);
            }
        }
Exemplo n.º 11
0
    protected void Update()
    {
        if (resetRegion)
        {
            m_RegionBackup.Copy(_parameters);
            feedKillData.Set("regionRadius", feedKillData.Get("regionRadiusBackup").value);
            ABRatesData.Set("regionRadius", ABRatesData.Get("regionRadiusBackup").value);

            resetRegion  = false;
            updateRegion = true;
        }

        if (updateRegion)
        {
            if (m_PresetUnique == false)
            {
                Parameters = Instantiate <RDPreset> (_parameters);
            }

            float feedKillRadius = feedKillData.Get("regionRadius").value;
            feedKillData.Set("regionRadiusBackup", feedKillRadius);

            float ABRatesRadius = ABRatesData.Get("regionRadius").value;
            ABRatesData.Set("regionRadiusBackup", ABRatesRadius);

            randomizer.InitAroundBase(Parameters, new PV[] {
                new PV("feedRate", feedKillRadius),
                new PV("killRate", feedKillRadius),
                new PV("aRate", ABRatesRadius),
                new PV("bRate", ABRatesRadius)
            });

            updateRegion = false;

            Vector2 feedKillUV = new Vector2(randomizer.Unlerp("feedRate", _parameters.feedRate), randomizer.Unlerp("killRate", _parameters.killRate));
            UVParameters(feedKillUV, 4);

            Vector2 ABUV = new Vector2(randomizer.Unlerp("aRate", _parameters.aRate), randomizer.Unlerp("bRate", _parameters.bRate));
            UVParameters(ABUV, 2);

            Parameters.Copy(m_RegionBackup);
        }

        if (feedKillValue == null)
        {
            feedKillValue            = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform;
            feedKillValue.name       = "feedKill";
            feedKillValue.localScale = Vector3.one * .01f;
            feedKillValue.GetComponent <Renderer> ().material.color = Color.blue;

            Vector2 feedKillUV = new Vector2(randomizer.Unlerp("feedRate", _parameters.feedRate), randomizer.Unlerp("killRate", _parameters.killRate));
            Debug.Log(feedKillUV);
            feedKillValue.position = GetComponent <MeshFilter> ().UVToWorldPos(feedKillUV, new int[] { 4, 5 });



            ABRatesValue            = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform;
            ABRatesValue.name       = "ABRates";
            ABRatesValue.localScale = Vector3.one * .01f;
            ABRatesValue.GetComponent <Renderer> ().material.color = Color.green;

            Vector2 ABUV = new Vector2(randomizer.Unlerp("aRate", _parameters.aRate), randomizer.Unlerp("bRate", _parameters.bRate));
            ABRatesValue.position = GetComponent <MeshFilter> ().UVToWorldPos(ABUV, new int[] { 2, 3 });
        }

        if (Input.GetMouseButton(0))
        {
            if (m_PresetUnique == false)
            {
                Parameters = Instantiate <RDPreset> (_parameters);
            }

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit) && hit.transform == transform)
            {
                Vector2 uv     = hit.textureCoord;
                int     tIndex = hit.triangleIndex;

                Debug.LogFormat("Triangle index = {0}", tIndex);

                UVParameters(uv, tIndex);
            }
        }
    }
Exemplo n.º 12
0
        internal string Process(string commandText, DynamicData param)
        {
            if (this.IsEmpty())
            {
                return(commandText);
            }

            //先处理any
            foreach (var any in _anys)
            {
                if (param.ContainsKey(any.ParamName))
                {
                    commandText = commandText.Replace(any.Placeholder, any.Content);
                }
                else
                {
                    commandText = commandText.Replace(any.Placeholder, "0=0"); //没有参数表示永远为真,这里不能替换为空文本,因为会出现where 没有条件的BUG,所以为 where 0=0
                }
            }


            foreach (var like in _likes)
            {
                var name  = like.ParamName;
                var value = param.Get(name) as string;
                if (value == null)
                {
                    continue;                //因为有any语法,所以没有传递参数也正常
                }
                if (like.After && like.Before)
                {
                    param.Set(name, string.Format("%{0}%", value));
                }
                else if (like.After)
                {
                    param.Set(name, string.Format("{0}%", value));
                }
                else if (like.Before)
                {
                    param.Set(name, string.Format("%{0}", value));
                }
            }

            foreach (var sin in _ins)
            {
                var name   = sin.ParamName;
                var values = param.Get(name) as IEnumerable;
                if (values == null)
                {
                    continue;                  //因为有any语法,所以没有传递参数也正常
                }
                param.Remove(name);

                if (values.Exists())
                {
                    using (var temp = StringPool.Borrow())
                    {
                        var code  = temp.Item;
                        int index = 0;
                        code.AppendFormat("{0} in (", sin.Field);
                        foreach (var value in values)
                        {
                            var valueName = string.Format("{0}{1}", name, index);
                            param.Add(valueName, value);
                            code.AppendFormat("@{0},", valueName);
                            index++;
                        }
                        if (code.Length > 1)
                        {
                            code.Length--;
                        }
                        code.Append(")");

                        commandText = commandText.Replace(sin.Placeholder, code.ToString());
                    }
                }
                else
                {
                    commandText = commandText.Replace(sin.Placeholder, "0=1"); //在in语句中,如果 id in (),没有任何匹配的数值条件,那么就是无匹配结果,所以0=1
                }
            }

            return(commandText);
        }
        private void Teleport(Player player, float dx)
        {
            Vector2 asVector = new Vector2(dx, 0);
            Level   level    = SceneAs <Level>();

            foreach (TrailManager.Snapshot snapshot in level.Tracker.GetEntities <TrailManager.Snapshot>())
            {
                snapshot.X += dx;
            }
            foreach (SlashFx slash in level.Tracker.GetEntities <SlashFx>())
            {
                slash.X += dx;
            }
            foreach (SpeedRing ring in level.Tracker.GetEntities <SpeedRing>())
            {
                ring.X += dx;
            }
            player.X += dx;
            player.Hair.MoveHairBy(asVector);
            level.Camera.Position += asVector;
            foreach (Backdrop backdrop in level.Background.Backdrops)
            {
                backdrop.Position += new Vector2(dx * backdrop.Scroll.X, 0);
            }
            foreach (Backdrop backdrop in level.Foreground.Backdrops)
            {
                backdrop.Position += new Vector2(dx * backdrop.Scroll.X, 0);
            }

            DynData <ParticleSystem> fgParticles = new DynData <ParticleSystem>(level.ParticlesFG);

            Particle[] particles = fgParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }
            DynData <ParticleSystem> bgParticles = new DynData <ParticleSystem>(level.ParticlesBG);

            particles = bgParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }
            DynData <ParticleSystem> particlesParticles = new DynData <ParticleSystem>(level.Particles);

            particles = particlesParticles.Get <Particle[]>("particles");
            for (int i = 0; i < particles.Length; i++)
            {
                particles[i].Position += asVector;
            }

            foreach (DreamBlock db in level.Tracker.GetEntities <DreamBlock>())
            {
                DynamicData dbData        = new DynamicData(db);
                DynamicData particlesData = new DynamicData(dbData.Get("particles"));
                for (int i = 0; i < particlesData.Get <int>("Length"); i++)
                {
                    DreamParticle particleProxy = new DreamParticle(db, i);
                    //Console.WriteLine(db.Position + " " + (particleProxy.Position + (level.Camera.Position - asVector) * (0.3f + 0.25f * particleProxy.Layer)) + " " +
                    //(particleProxy.Position + (level.Camera.Position) * (0.3f + 0.25f * particleProxy.Layer)) + " " + asVector * (0.3f + 0.25f * particleProxy.Layer));
                    particleProxy.Position -= (asVector) * .5f * (0.3f + 0.25f * particleProxy.Layer);
                }
            }
        }