Esempio n. 1
0
 public RawSpriteTile(TRS positioning, Vector2i tile_index, bool flipu = false, bool flipv = false)
 {
     this.Quad        = positioning;
     this.TileIndex2D = tile_index;
     this.FlipU       = flipu;
     this.FlipV       = flipv;
 }
        protected void DrawTRS(TRS_SP trsSP, TRS type, string label)
        {
            const float RANGE_LABEL_WIDTH = 42;

            EditorGUILayout.LabelField(System.Enum.GetName(typeof(TRS), type) + ":", (GUIStyle)"BoldLabel");

            EditorGUILayout.BeginVertical("HelpBox");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(addVectorContent, GUILayout.MaxWidth(RANGE_LABEL_WIDTH));
            DrawAxes(trsSP.addVector, AxisMask.XYZ);
            EditorGUILayout.LabelField("/sec", GUILayout.MaxWidth(32));
            EditorGUILayout.EndHorizontal();

            /// Local
            EditorGUI.BeginDisabledGroup(type == TRS.Scale);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Local", GUILayout.MaxWidth(RANGE_LABEL_WIDTH));
            EditorGUILayout.GetControlRect(GUILayout.MaxWidth(AXIS_LAB_WID));
            EditorGUILayout.PropertyField(trsSP.local, GUIContent.none);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();
        }
Esempio n. 3
0
        protected override void InitializeTRS(TRSDefinition def, TRS type)
        {
            /// Absolute only applies to oscillate.. make sure its false if we aren't oscillating
            if (movement != Movement.Oscillate)
            {
                def.relation = MovementRelation.Relative;
            }

            if (def.relation == MovementRelation.Relative && movement == Movement.Oscillate || movement == Movement.Trigger)
            {
                Vector3 currentVector;

                switch (type)
                {
                case TRS.Position:
                    currentVector = def.local ? transform.localPosition : transform.position;
                    break;

                case TRS.Rotation:
                    currentVector = def.local ? transform.localEulerAngles : transform.eulerAngles;
                    break;

                default:
                    currentVector = def.local ? transform.localScale : transform.lossyScale;
                    break;
                }

                nodes[0].trs[(int)type] += currentVector;
                nodes[1].trs[(int)type] += currentVector;
            }
        }
Esempio n. 4
0
        public override void Draw()
        {
            base.Draw();
            TRS tRS    = new TRS(Director.Instance.CurrentScene.Camera.CalcBounds());
            TRS quad0_ = TRS.Quad0_1;

            Director.Instance.SpriteRenderer.DefaultShader.SetUVTransform(ref Math.UV_TransformIdentity);
            Director.Instance.GL.SetBlendMode(BlendMode.None);
            if (base.FadeCompletion < 0.5f)
            {
                float   num    = this.Tween(base.FadeCompletion / 0.5f);
                Vector4 vector = new Vector4(1f - num);
                Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref vector);
                Director.Instance.SpriteRenderer.BeginSprites(TransitionFadeBase.m_previous_scene_render, 1);
                Director.Instance.SpriteRenderer.AddSprite(ref tRS, ref quad0_);
                Director.Instance.SpriteRenderer.EndSprites();
            }
            else
            {
                float   num    = this.Tween((base.FadeCompletion - 0.5f) / 0.5f);
                Vector4 vector = new Vector4(num);
                Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref vector);
                Director.Instance.SpriteRenderer.BeginSprites(TransitionFadeBase.m_next_scene_render, 1);
                Director.Instance.SpriteRenderer.AddSprite(ref tRS, ref quad0_);
                Director.Instance.SpriteRenderer.EndSprites();
            }
        }
Esempio n. 5
0
        // draw the tiles that we are about to "put", with transparency
        void DrawBrush()
        {
            // for objects larger than one tile, you have to select the middle cell of the first, bottom row of the object

            Vector3i coord = m_world_edit_cell;

            if (!IsValidIndex(coord))
            {
                return;
            }

            TRS quad = TRS.Quad0_1;
            //each z level happens to corresponds to the iso tile neighbour at +(1,1), hence the +coord.Z below
            Vector2 p = X * (coord.X + coord.Z) + Y * (coord.Y + coord.Z);

            quad.T = (p + Y).ProjectOnLine(p, Math._10);
//			#if 0
            float d = (p - quad.T).Length() * 2.0f;               // d should be =1

            quad.S = new Vector2(d, d);
//			#endif
            var data = new RawSpriteTile(quad, m_selected_tile, false, false);

            m_blocks_list.Add(data);

            BlendMode = BlendMode.Normal;
            Color     = Math.SetAlpha(Colors.White, Input2.GamePad0.Circle.Down ? 1.0f : 0.6f);

            flush_draw_blocks_list();
        }
Esempio n. 6
0
 void Update()
 {
     if (useDelay)
     {
         if (useSetTarget)
         {
             trsQueue.Enqueue(targetTRS);
         }
         else
         {
             //  if (followTransform!=null)
             trsQueue.Enqueue(new TRS(followTransform));
         }
     }
     else
     {
         if (!useSetTarget)
         {
             thisTarget = new TRS(followTransform);
         }
     }
     if (useDelay)
     {
         while (trsQueue.Count > queueLength)
         {
             thisTarget = trsQueue.Dequeue();
             Chase();
         }
     }
     else
     {
         Chase();
     }
 }
Esempio n. 7
0
 void Chase()
 {
     if (useDamper)
     {
         damperPos.targetValue = thisTarget.position;
         thisTrs.position      = damperPos.UpdatedValue();
         if (useRotation)
         {
             damperAngle.targetValue = thisTarget.rotation.eulerAngles;
             thisTrs.rotation        = Quaternion.Euler(damperAngle.UpdatedValue());
         }
     }
     else
     {
         thisTrs = thisTarget;
     }
     if (useRotation)
     {
         Quaternion r = thisTrs.rotation;
         if (keepStartRotations)
         {
             r *= startRot;
         }
         transform.localRotation = r;
     }
     transform.localPosition = thisTrs.position - (keepposOffsetitions ? posOffset : Vector3.zero);
     if (useScale)
     {
         transform.localScale = thisTrs.scale;
     }
     // pending = false;
 }
Esempio n. 8
0
        void Setup(ComputeBuffer buffer)
        {
            GPUParticle[] particles = new GPUParticle[buffer.count];
            buffer.GetData(particles);

            var count = particles.Length;

            fromBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(TRS)));
            toBuffer   = new ComputeBuffer(count, Marshal.SizeOf(typeof(TRS)));

            var from = new TRS[count];
            var to   = new TRS[count];
            var q    = Quaternion.identity;
            var s    = Vector3.one;

            for (int i = 0; i < count; i++)
            {
                var p = particles[i];
                from[i] = new TRS(p.pos, p.rot, p.scale);
                to[i]   = new TRS(p.origin, q, s);
            }

            fromBuffer.SetData(from);
            toBuffer.SetData(to);

            shader.SetBuffer(0, "_From", fromBuffer);
            shader.SetBuffer(0, "_To", toBuffer);
        }
        public override void Draw()
        {
            base.Draw();
            float x      = this.Tween(base.FadeCompletion);
            TRS   tRS    = new TRS(Director.Instance.CurrentScene.Camera.CalcBounds());
            TRS   quad0_ = TRS.Quad0_1;

            TransitionDirectionalFade.m_shader.SetUVTransform(ref Math.UV_TransformIdentity);
            Director.Instance.GL.Context.SetTexture(1, TransitionFadeBase.m_next_scene_render.Texture);
            Director.Instance.GL.SetBlendMode(BlendMode.None);
            Vector2 vector  = -this.Direction.Normalize();
            Vector2 a       = new Vector2(0f, 0f);
            Vector2 vector2 = new Vector2(1f, 1f);

            if (vector.X > 0f)
            {
                a.X       = 1f;
                vector2.X = 0f;
            }
            if (vector.Y > 0f)
            {
                a.Y       = 1f;
                vector2.Y = 0f;
            }
            vector2 -= vector * this.Width;
            Vector4 vector3 = new Vector4(Math.Lerp(a, vector2, x), vector);

            TransitionDirectionalFade.m_shader.SetPlane(ref vector3);
            TransitionDirectionalFade.m_shader.SetOffsetRcp(1f / this.Width);
            Director.Instance.SpriteRenderer.BeginSprites(TransitionFadeBase.m_previous_scene_render, TransitionDirectionalFade.m_shader, 1);
            Director.Instance.SpriteRenderer.AddSprite(ref tRS, ref quad0_);
            Director.Instance.SpriteRenderer.EndSprites();
        }
Esempio n. 10
0
        protected void DrawHorizontalTRS(TRS_SP trsSP, TRS type, string label)
        {
            EditorGUILayout.BeginVertical("HelpBox");

            {
                /// Restrict
                EditorGUILayout.PropertyField(trsSP.includeAxes, new GUIContent(label + " Axes"));

                if (trsSP.includeAxes.intValue != 0)
                {
                    /// Relation
                    EditorGUILayout.PropertyField(trsSP.relation);

                    /// Local
                    EditorGUI.BeginDisabledGroup(type == TRS.Scale);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Local", GUILayout.MaxWidth(RANGE_LABEL_WIDTH));
                    EditorGUILayout.GetControlRect(GUILayout.MaxWidth(AXIS_LAB_WID));
                    EditorGUILayout.PropertyField(trsSP.local, GUIContent.none);
                    EditorGUILayout.EndHorizontal();
                    EditorGUI.EndDisabledGroup();
                }
            }
            EditorGUILayout.EndVertical();
        }
        public void TestRegistrationOptions()
        {
            var server  = new TRS();
            var options = new CrpcRegistrationOptions <TRS>();

            options.Register("test", "2020-04-26", server.TestEndpoint);

            var ex = Assert.Throws <ArgumentException>(
                () => options.Register("test", "2020-04-26", server.TestEndpoint)
                );

            Assert.StartsWith("Duplicate version found for 2020-04-26/test", ex.Message);
        }
Esempio n. 12
0
 public Quaternion GetOrientationFast(float tf)
 {
     if (UseWorldCoordinates)
     {
         return
             (TRS.GetRotation(Self.transform.localToWorldMatrix) *
              Self.GetOrientationFast(tf));
     }
     else
     {
         return(Self.GetOrientationFast(tf));
     }
 }
Esempio n. 13
0
        static void BuildMap(Transform t, Dictionary <string, TRS> map, Transform root = null)
        {
            if (root == null)
            {
                root = t;
            }

            map.Add(t.RelativePathFrom(root), TRS.From(t));

            foreach (Transform child in t)
            {
                BuildMap(child, map, root);
            }
        }
Esempio n. 14
0
 public override void Draw()
 {
     Director.Instance.GL.SetBlendMode(this.BlendMode);
     this.Shader.SetColor(ref this.Color);
     this.Shader.SetUVTransform(ref Math.UV_TransformFlipV);
     Director.Instance.SpriteRenderer.BeginSprites(this.TextureInfo, this.Shader, this.Sprites.Count);
     foreach (RawSpriteTile current in this.Sprites)
     {
         Director.Instance.SpriteRenderer.FlipU = current.FlipU;
         Director.Instance.SpriteRenderer.FlipV = current.FlipV;
         TRS quad = current.Quad;
         Director.Instance.SpriteRenderer.AddSprite(ref quad, current.TileIndex2D);
     }
     Director.Instance.SpriteRenderer.EndSprites();
 }
Esempio n. 15
0
        // draw all style and highlight the selected one
        // clicking in empty space triggers erase mode
        void DrawTilesForSelection()
        {
            m_tile_select_camera.Push();

            Director.Instance.GL.SetBlendMode(BlendMode.None);
            Vector4 col = Colors.White;

            Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref col);
            Director.Instance.SpriteRenderer.DefaultShader.SetUVTransform(ref Math.UV_TransformFlipV);
            Director.Instance.SpriteRenderer.BeginSprites(TileMap, TextureInfo.NumTiles.Product());

            for (int j = 0; j < TextureInfo.NumTiles.Y; ++j)
            {
                for (int i = 0; i < TextureInfo.NumTiles.X; ++i)
                {
                    Director.Instance.SpriteRenderer.FlipU = false;
                    Director.Instance.SpriteRenderer.FlipV = false;
                    TRS quad = TRS.Quad0_1;
                    quad.T = new Vector2((float)i, (float)j) * TextureInfo.TileSizeInPixelsf;
                    quad.S = TextureInfo.TileSizeInPixelsf;
                    Director.Instance.SpriteRenderer.AddSprite(ref quad, new Vector2i(i, j));
                }
            }

            Director.Instance.SpriteRenderer.EndSprites();

            if (!is_erase_mode())
            {
                // highlight selected tile
                TRS quad = TRS.Quad0_1;
                quad.T = m_selected_tile.Vector2() * TextureInfo.TileSizeInPixelsf;
                quad.S = TextureInfo.TileSizeInPixelsf;
                Director.Instance.DrawHelpers.SetColor(Colors.Pink);
                Director.Instance.DrawHelpers.DrawBounds2(quad.Bounds2());
            }

            {
                Director.Instance.GL.SetBlendMode(BlendMode.Normal);
                Director.Instance.DrawHelpers.DrawDefaultGrid(m_tile_select_camera.CalcBounds()
                                                              , TextureInfo.TileSizeInPixelsf, Math.SetAlpha(Colors.LightBlue, 0.2f), Colors.LightBlue);
            }

            m_tile_select_camera.Pop();
        }
Esempio n. 16
0
//		static Vector2 m_offset = new Vector2(0.066f,0.224f);

        // draw example source image underneath the editor to help positionning tiles
        void DrawExampleSourceImage()
        {
            Director.Instance.GL.SetBlendMode(BlendMode.Normal);
            Vector4 col = Math.SetAlpha(Colors.White, 0.5f);

            Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref col);
            Director.Instance.SpriteRenderer.DefaultShader.SetUVTransform(ref Math.UV_TransformFlipV);
            Director.Instance.SpriteRenderer.BeginSprites(ExampleImage, 1);
            Director.Instance.SpriteRenderer.FlipU = false;
            Director.Instance.SpriteRenderer.FlipV = false;
            TRS quad = TRS.Quad0_1;

            quad.S = ExampleImage.TextureSizef / 64.0f;
//			System.Console.WriteLine( m_offset );
//			m_offset += Input2.GamePad0.Dpad * 0.002f;
            quad.T = new Vector2(-5.0f, 3.0f) + m_offset;
            Director.Instance.SpriteRenderer.AddSprite(ref quad, new Vector2i(0, 0));
            Director.Instance.SpriteRenderer.EndSprites();
        }
Esempio n. 17
0
        public void SetBlock(Vector3i coord, Vector2i tile_index)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int cell_index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            if (m_cells[cell_index] == null)
            {
                m_cells[cell_index] = new Cell();
            }

            TRS trs = TRS.Quad0_1;

            trs.S = SpriteSize;
            trs.T = GetCellPos(coord.Vector3());

            m_z_count[coord.X + coord.Y * m_num_cells.Y]++;
            m_cells[cell_index].Data = new RawSpriteTile(trs, tile_index, false, false);
            update_top_most_flag(coord);
        }
Esempio n. 18
0
        public void SetBlock(Vector3i coord, Vector2i tile_index, bool second)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int cell_index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            if (m_cells[cell_index] == null)
            {
                m_cells[cell_index] = new Cell();
            }

            TRS quad = TRS.Quad0_1;
            //each z level happens to corresponds to the iso tile neighbour at +(1,1), hence the +coord.Z below
            Vector2 p = X * (coord.X + coord.Z) + Y * (coord.Y + coord.Z);

            quad.T = (p + Y).ProjectOnLine(p, Math._10);
//			#if 0
            float d = (p - quad.T).Length() * 2.0f;               // d should be =1

            quad.S = new Vector2(d, d);
//			#endif

            var data = new RawSpriteTile(quad, tile_index, false, false);

            if (second)
            {
                m_cells[cell_index].Data2    = data;
                m_cells[cell_index].Data1Set = true;
            }
            else
            {
                m_cells[cell_index].Data1    = data;
                m_cells[cell_index].Data2Set = true;
            }
        }
Esempio n. 19
0
        public override void Draw()
        {
            base.Draw();
            float num = this.Tween(base.FadeCompletion);
            //FIXME:added
//			Debug.WriteLine(">>>>>>TransitionCrossFade>>>>>>>>>>>> " + num);
            TRS tRS    = new TRS(Director.Instance.CurrentScene.Camera.CalcBounds());
            TRS quad0_ = TRS.Quad0_1;

            Director.Instance.SpriteRenderer.DefaultShader.SetUVTransform(ref Math.UV_TransformIdentity);
            Director.Instance.GL.SetBlendMode(BlendMode.None);
            Vector4 vector = new Vector4(1f - num);

            Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref vector);
            Director.Instance.SpriteRenderer.BeginSprites(TransitionFadeBase.m_previous_scene_render, 1);
            Director.Instance.SpriteRenderer.AddSprite(ref tRS, ref quad0_);
            Director.Instance.SpriteRenderer.EndSprites();
            Director.Instance.GL.SetBlendMode(BlendMode.Additive);
            vector = new Vector4(num);
            Director.Instance.SpriteRenderer.DefaultShader.SetColor(ref vector);
            Director.Instance.SpriteRenderer.BeginSprites(TransitionFadeBase.m_next_scene_render, 1);
            Director.Instance.SpriteRenderer.AddSprite(ref tRS, ref quad0_);
            Director.Instance.SpriteRenderer.EndSprites();
        }
Esempio n. 20
0
 public void MakeFullScreen()
 {
     this.Quad = new TRS(Director.Instance.CurrentScene.Camera.CalcBounds());
 }
Esempio n. 21
0
 protected abstract void InitializeTRS(TTRSDef def, TRS type);