示例#1
0
 public CCQuad3 this[CCGridSize pos]
 {
     get { return this[pos.X, pos.Y]; }
     set {
         this[pos.X, pos.Y] = value;
     }
 }
示例#2
0
        public void TurnOffTile(CCGridSize pos)
        {
            var coords = new CCQuad3();

            //memset(&coords, 0, sizeof(ccQuad3));
            SetTile(pos, ref coords);
        }
示例#3
0
 public CCLens3D(float duration, CCGridSize gridSize, CCPoint position, float radius) : base(duration, gridSize)
 {
     Position  = position;
     Radius    = radius;
     LensScale = 0.7f;
     Concave   = false;
 }
示例#4
0
        public override void UpdateAtlasValues()
        {
            if (PositionToAtlasIndex.Count > 0)
            {
                return;
            }

            Debug.Assert(TGAInfo != null, "tgaInfo must be non-nil");

            int total = 0;

            for (int x = 0; x < TGAInfo.Width; x++)
            {
                for (int y = 0; y < TGAInfo.Height; y++)
                {
                    if (total < NumOfItemsToRender)
                    {
                        Color value = TGAInfo.ImageData[x + y * TGAInfo.Width];

                        if (value.R != 0)
                        {
                            var pos = new CCGridSize(x, y);
                            UpdateAtlasValueAt(x, y, value, total);
                            PositionToAtlasIndex.Add(pos, total);

                            total++;
                        }
                    }
                }
            }
        }
示例#5
0
 public CCRipple3D(float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude)
     : base(duration, gridSize, amplitude)
 {
     Position = position;
     Radius   = radius;
     Waves    = waves;
 }
示例#6
0
 public CCQuad3 this[CCGridSize pos]
 {
     get { return(this[pos.X, pos.Y]); }
     set {
         this[pos.X, pos.Y] = value;
     }
 }
示例#7
0
 public CCLens3D (float duration, CCGridSize gridSize, CCPoint position, float radius) : base (duration, gridSize)
 {
     Position = position;
     Radius = radius;
     LensScale = 0.7f;
     Concave = false;
 }
示例#8
0
 public CCRipple3D (float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude)
     : base (duration, gridSize, amplitude)
 {
     Position = position;
     Radius = radius;
     Waves = waves;
 }
示例#9
0
 public CCFlipX3D(float duration, CCGridSize gridSize) : base(duration, gridSize)
 {
     if (gridSize.X != 1 || gridSize.Y != 1)
     {
         // Grid size must be (1,1)
         Debug.Assert(false);
     }
 }
示例#10
0
        public CCColor4B TileAt(CCGridSize position)
        {
            Debug.Assert(TGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(position.X < TGAInfo.Width, "Invalid position.x");
            Debug.Assert(position.Y < TGAInfo.Height, "Invalid position.y");

            return new CCColor4B(TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width]);
        }
示例#11
0
        public CCColor4B TileAt(CCGridSize position)
        {
            Debug.Assert(TGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(position.X < TGAInfo.Width, "Invalid position.x");
            Debug.Assert(position.Y < TGAInfo.Height, "Invalid position.y");

            return(new CCColor4B(TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width]));
        }
示例#12
0
 protected CCGridBase(CCGridSize gridSize, CCTexture2D texture, bool flipped=false)
 {
     GridSize = gridSize;
     Texture = texture;
     textureFlipped = flipped;
     CCSize texSize = texture.ContentSizeInPixels;
     Step = new CCPoint ((float)Math.Ceiling(texSize.Width / GridSize.X), (float)Math.Ceiling(texSize.Height / GridSize.Y));
 }
示例#13
0
 public CCFlipX3D (float duration, CCGridSize gridSize) : base (duration, gridSize)
 {
     if (gridSize.X != 1 || gridSize.Y != 1)
     {
         // Grid size must be (1,1)
         Debug.Assert (false);
     }
 }
示例#14
0
        protected CCGridBase(CCGridSize gridSize, CCRenderTexture renderTexture, bool flipped = false)
        {
            GridSize       = gridSize;
            RenderTexture  = renderTexture;
            textureFlipped = flipped;
            CCSize texSize = renderTexture.Texture.ContentSizeInPixels;

            Step = new CCPoint((float)Math.Ceiling(texSize.Width / GridSize.X), (float)Math.Ceiling(texSize.Height / GridSize.Y));
        }
示例#15
0
//
//        public CCSize ContentSize
//        {
//            get { return contentSize; }
//            set
//            {
//                if (contentSize != value)
//                {
//                    contentSize = value;
//                    Step = new CCPoint (contentSize.Width / GridSize.X, contentSize.Height / GridSize.Y);
//                }
//            }
//        }

        #endregion Properties


        #region Constructors

        protected CCGridBase(CCGridSize gridSize, CCTexture2D texture, bool flipped = false)
        {
            GridSize       = gridSize;
            Texture        = texture;
            textureFlipped = flipped;
            CCSize texSize = texture.ContentSizeInPixels;

            Step = new CCPoint(texSize.Width / GridSize.X, texSize.Height / GridSize.Y);
        }
 public override float TestFunc (CCGridSize pos, float time)
 {
     float fy = GridSize.Y * time;
     if (fy == 0f)
     {
         return (1f);
     }
     return (float)Math.Pow (pos.Y / fy, 6);
 }
示例#17
0
        public override float TestFunc(CCGridSize pos, float time)
        {
            float fy = GridSize.Y * time;

            if (fy == 0f)
            {
                return(1f);
            }
            return((float)Math.Pow(pos.Y / fy, 6));
        }
示例#18
0
        public override float TestFunc (CCGridSize pos, float time)
        {
            var n = new CCPoint ((GridSize.X * (1.0f - time)), (GridSize.Y * (1.0f - time)));
            if ((pos.X + pos.Y) == 0)
            {
                return 1.0f;
            }

            return (float)Math.Pow ((n.X + n.Y) / (pos.X + pos.Y), 6);
        }
示例#19
0
        public override float TestFunc(CCGridSize pos, float time)
        {
            var n = new CCPoint((GridSize.X * (1.0f - time)), (GridSize.Y * (1.0f - time)));

            if ((pos.X + pos.Y) == 0)
            {
                return(1.0f);
            }

            return((float)Math.Pow((n.X + n.Y) / (pos.X + pos.Y), 6));
        }
示例#20
0
        public virtual float TestFunc(CCGridSize pos, float time)
        {
            float px = GridSize.X * time;
            float py = GridSize.Y * time;

            if ((px + py) == 0.0f)
            {
                return(1.0f);
            }

            return((float)Math.Pow((pos.X + pos.Y) / (px + py), 6));
        }
示例#21
0
        public override void TransformTile (CCGridSize pos, float distance)
        {
            CCQuad3 coords = OriginalTile (pos);
            CCPoint step = Target.Grid.Step;

            float dy = (step.Y / 2) * (1.0f - distance);

            coords.BottomLeft.Y += dy; // (step.Y / 2) * (1.0f - distance);
            coords.BottomRight.Y += dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopLeft.Y -= dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopRight.Y -= dy; // (step.Y / 2) * (1.0f - distance);

            SetTile (pos, ref coords);
        }
示例#22
0
        public override void TransformTile(CCGridSize pos, float distance)
        {
            CCQuad3 coords = OriginalTile(pos);
            CCPoint step   = Target.Grid.Step;

            float dy = (step.Y / 2) * (1.0f - distance);

            coords.BottomLeft.Y  += dy; // (step.Y / 2) * (1.0f - distance);
            coords.BottomRight.Y += dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopLeft.Y     -= dy; //  (step.Y / 2) * (1.0f - distance);
            coords.TopRight.Y    -= dy; // (step.Y / 2) * (1.0f - distance);

            SetTile(pos, ref coords);
        }
示例#23
0
        public virtual void TransformTile(CCGridSize pos, float distance)
        {
            CCQuad3 coords = OriginalTile(pos);

            var step = (Target is CCNodeGrid) ?  ((CCNodeGrid)Target).Grid.Step : Target.Grid.Step;

            float dx = (step.X / 2) * (1.0f - distance);
            float dy = (step.Y / 2) * (1.0f - distance);

            coords.BottomLeft.X += dx;
            coords.BottomLeft.Y += dy;

            coords.BottomRight.X -= dx;
            coords.BottomRight.Y += dy;

            coords.TopLeft.X += dx;
            coords.TopLeft.Y -= dy;

            coords.TopRight.X -= dx;
            coords.TopRight.Y -= dy;

            SetTile(pos, ref coords);
        }
示例#24
0
        public void SetTile(CCColor4B tile, CCGridSize position)
        {
            Debug.Assert(TGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(PositionToAtlasIndex != null, "posToAtlasIndex must not be nil");
            Debug.Assert(position.X < TGAInfo.Width, "Invalid position.x");
            Debug.Assert(position.Y < TGAInfo.Height, "Invalid position.x");
            Debug.Assert(tile.R != 0, "R component must be non 0");

            Color value = TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width];

            if (value.R == 0)
            {
                CCLog.Log("CocosSharp: Value.r must be non 0.");
            }
            else
            {
                TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width] = new Color(tile.R, tile.G, tile.B, tile.A);

                // XXX: this method consumes a lot of memory
                // XXX: a tree of something like that shall be implemented
                int num = PositionToAtlasIndex[position];
                UpdateAtlasValueAt(position, tile.ToColor(), num);
            }
        }
示例#25
0
 /// <summary>
 /// returns the original (non-transformed) vertex at a given position
 /// </summary>
 public CCVertex3F OriginalVertex (CCGridSize pos)
 {
     return grid3D.OriginalVertex (pos);
 }
示例#26
0
 public CCTwirl (float duration, CCGridSize gridSize, CCPoint position, int twirls = 0, float amplitude = 0)
     : base (duration, gridSize, amplitude)
 {
     Position = position;
     Twirls = twirls;
 }
示例#27
0
 /// <summary>
 /// returns the vertex at a given position
 /// </summary>
 public CCVertex3F Vertex (CCGridSize pos)
 {
     return grid3D [pos];
 }
示例#28
0
 public CCLens3D (float duration, CCGridSize gridSize)
     : this (duration, gridSize, CCPoint.Zero, 0)
 {
 }
示例#29
0
 public CCRipple3D (float duration, CCGridSize gridSize)
     : this (duration, gridSize, CCPoint.Zero, 0, 0, 0)
 {
 }
 protected CCTiledGrid3DAction(float duration, CCGridSize gridSize, float amplitude)
     : base(duration, gridSize, amplitude)
 {
 }
 /// <summary>
 /// returns the original (non-transformed) tile quad at a given position
 /// </summary>
 public CCQuad3 OriginalTile(CCGridSize pos)
 {
     return(tiledGrid3D.OriginalTile(pos));
 }
示例#32
0
 /// <summary>
 /// returns the original (non-transformed) vertex at a given position
 /// </summary>
 public CCVertex3F OriginalVertex(CCGridSize pos)
 {
     return(grid3D.OriginalVertex(pos));
 }
示例#33
0
 protected CCGrid3DAction(float duration, CCGridSize gridSize) : this(duration, gridSize, 0)
 {
 }
示例#34
0
 public CCVertex3F this[CCGridSize pos]
 {
     get { return this[pos.X, pos.Y]; }
     set { this[pos.X, pos.Y] = value; }
 }
 public CCFadeOutUpTiles (float duration, CCGridSize gridSize) : base (duration, gridSize)
 {
 }
示例#36
0
        public override void Update (float time)
        {
            float angle = (float)Math.PI * time; // 180 degrees
            var mz = (float)Math.Sin (angle);
            angle = angle / 2.0f; // x calculates degrees from 0 to 90
            var mx = (float)Math.Cos (angle);

            CCVertex3F v0, v1, v;
            var diff = new CCVertex3F ();

            v0 = OriginalVertex (1, 1);
            v1 = OriginalVertex (0, 0);

            float x0 = v0.X;
            float x1 = v1.X;
            float x;
            CCGridSize a, b, c, d;

            if (x0 > x1)
            {
                // Normal Grid
                a = new CCGridSize (0, 0);
                b = new CCGridSize (0, 1);
                c = new CCGridSize (1, 0);
                d = new CCGridSize (1, 1);
                x = x0;
            }
            else
            {
                // Reversed Grid
                c = new CCGridSize (0, 0);
                d = new CCGridSize (0, 1);
                a = new CCGridSize (1, 0);
                b = new CCGridSize (1, 1);
                x = x1;
            }

            diff.X = (x - x * mx);
            diff.Z = Math.Abs ((float)Math.Floor ((x * mz) / 4.0f));

            // bottom-left
            v = OriginalVertex (a);
            v.X = diff.X;
            v.Z += diff.Z;
            SetVertex (a, ref v);

            // upper-left
            v = OriginalVertex (b);
            v.X = diff.X;
            v.Z += diff.Z;
            SetVertex (b, ref v);

            // bottom-right
            v = OriginalVertex (c);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex (c, ref v);

            // upper-right
            v = OriginalVertex (d);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex (d, ref v);
        }
示例#37
0
 public void TurnOffTile (CCGridSize pos)
 {
     var coords = new CCQuad3 ();
     //memset(&coords, 0, sizeof(ccQuad3));
     SetTile (pos, ref coords);
 }
示例#38
0
 public CCWaves(float duration, CCGridSize gridSize, int waves = 0, float amplitude = 0, bool horizontal = true, bool vertical = true)
     : base(duration, gridSize, waves, amplitude)
 {
     Horizontal = horizontal;
     Vertical   = vertical;
 }
示例#39
0
 public void TurnOnTile (CCGridSize pos)
 {
     CCQuad3 orig = OriginalTile (pos);
     SetTile (pos, ref orig);
 }
示例#40
0
        public void TurnOnTile(CCGridSize pos)
        {
            CCQuad3 orig = OriginalTile(pos);

            SetTile(pos, ref orig);
        }
示例#41
0
        public override void Update(float time)
        {
            float angle = (float)Math.PI * time; // 180 degrees
            var   mz    = (float)Math.Sin(angle);

            angle = angle / 2.0f; // x calculates degrees from 0 to 90
            var mx = (float)Math.Cos(angle);

            CCVertex3F v0, v1, v;
            var        diff = new CCVertex3F();

            v0 = OriginalVertex(1, 1);
            v1 = OriginalVertex(0, 0);

            float      x0 = v0.X;
            float      x1 = v1.X;
            float      x;
            CCGridSize a, b, c, d;

            if (x0 > x1)
            {
                // Normal Grid
                a = new CCGridSize(0, 0);
                b = new CCGridSize(0, 1);
                c = new CCGridSize(1, 0);
                d = new CCGridSize(1, 1);
                x = x0;
            }
            else
            {
                // Reversed Grid
                c = new CCGridSize(0, 0);
                d = new CCGridSize(0, 1);
                a = new CCGridSize(1, 0);
                b = new CCGridSize(1, 1);
                x = x1;
            }

            diff.X = (x - x * mx);
            diff.Z = Math.Abs((float)Math.Floor((x * mz) / 4.0f));

            // bottom-left
            v    = OriginalVertex(a);
            v.X  = diff.X;
            v.Z += diff.Z;
            SetVertex(a, ref v);

            // upper-left
            v    = OriginalVertex(b);
            v.X  = diff.X;
            v.Z += diff.Z;
            SetVertex(b, ref v);

            // bottom-right
            v    = OriginalVertex(c);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex(c, ref v);

            // upper-right
            v    = OriginalVertex(d);
            v.X -= diff.X;
            v.Z -= diff.Z;
            SetVertex(d, ref v);
        }
示例#42
0
        public override void Update (float time)
        {

            if (Target == null)
                return; 
            
            float angle = (float)Math.PI * time; // 180 degrees
            var mz = (float)Math.Sin (angle);
            angle = angle / 2.0f; // x calculates degrees from 0 to 90
            var my = (float)Math.Cos (angle);

            CCVertex3F v0, v1, v;
            var diff = new CCVertex3F ();

            v0 = OriginalVertex (1, 1);
            v1 = OriginalVertex (0, 0);

            float y0 = v0.Y;
            float y1 = v1.Y;
            float y;
            CCGridSize a, b, c, d;

            if (y0 > y1)
            {
                // Normal Grid
                a = new CCGridSize (0, 0);
                b = new CCGridSize (0, 1);
                c = new CCGridSize (1, 0);
                d = new CCGridSize (1, 1);
                y = y0;
            }
            else
            {
                // Reversed Grid
                b = new CCGridSize (0, 0);
                a = new CCGridSize (0, 1);
                d = new CCGridSize (1, 0);
                c = new CCGridSize (1, 1);
                y = y1;
            }

            diff.Y = y - y * my;
            diff.Z = Math.Abs ((float)Math.Floor ((y * mz) / 4.0f));

            // bottom-left
            v = OriginalVertex (a);
            v.Y = diff.Y;
            v.Z += diff.Z;
            SetVertex (a, ref v);

            // upper-left
            v = OriginalVertex (b);
            v.Y -= diff.Y;
            v.Z -= diff.Z;
            SetVertex (b, ref v);

            // bottom-right
            v = OriginalVertex (c);
            v.Y = diff.Y;
            v.Z += diff.Z;
            SetVertex (c, ref v);

            // upper-right
            v = OriginalVertex (d);
            v.Y -= diff.Y;
            v.Z -= diff.Z;
            SetVertex (d, ref v);
        }
示例#43
0
 /// <summary>
 /// sets a new vertex at a given position
 /// </summary>
 public void SetVertex(CCGridSize pos, ref CCVertex3F vertex)
 {
     grid3D [pos] = vertex;
 }
示例#44
0
 public CCFadeOutBLTiles(float duration, CCGridSize gridSize) : base(duration, gridSize)
 {
 }
示例#45
0
 /// <summary>
 /// returns the vertex at a given position
 /// </summary>
 public CCVertex3F Vertex(CCGridSize pos)
 {
     return(grid3D [pos]);
 }
示例#46
0
 /// <summary>
 /// creates the action with a number of waves, the waves amplitude, the grid size and the duration
 /// </summary>
 public CCWavesTiles3D (float duration, CCGridSize gridSize, int waves = 0, float amplitude = 0)
     : base (duration, gridSize, amplitude)
 {
     Waves = waves;
 }
 /// <summary>
 /// returns the tile quad at a given position
 /// </summary>
 public CCQuad3 Tile(CCGridSize pos)
 {
     return(tiledGrid3D [pos]);
 }
示例#48
0
 protected CCGridAction(float duration, CCGridSize gridSize, float amplitude) : base(duration, amplitude)
 {
     GridSize = gridSize;
 }
 /// <summary>
 /// sets a new tile quad at a given position
 /// </summary>
 public void SetTile(CCGridSize pos, ref CCQuad3 coords)
 {
     tiledGrid3D [pos] = coords;
 }
示例#50
0
        public virtual float TestFunc (CCGridSize pos, float time)
        {
            float px = GridSize.X * time;
            float py = GridSize.Y * time;
            if ((px + py) == 0.0f)
            {
                return 1.0f;
            }

            return (float)Math.Pow ((pos.X + pos.Y) / (px + py), 6);
        }
示例#51
0
 // returns the original tile (untransformed) at the given position
 public CCQuad3 OriginalTile(CCGridSize pos)
 {
     return OriginalTile(pos.X, pos.Y);
 }
示例#52
0
 protected CCGrid3DAction (float duration, CCGridSize gridSize, float amplitude)
     : base (duration, gridSize, amplitude)
 {
 }
示例#53
0
 /// <summary>
 /// sets a new vertex at a given position
 /// </summary>
 public void SetVertex (CCGridSize pos, ref CCVertex3F vertex)
 {
     grid3D [pos] = vertex;
 }
示例#54
0
 public CCTwirl (float duration, CCGridSize gridSize)
     : this (duration, gridSize, CCPoint.Zero)
 {
 }
示例#55
0
 public CCGridAction(float duration, CCGridSize gridSize) : this(duration, gridSize, 0)
 {
 }
示例#56
0
 protected CCGrid3DAction (float duration, CCGridSize gridSize) : this (duration, gridSize, 0)
 {
 }
示例#57
0
 public CCGrid3D(CCGridSize gridSize, CCTexture2D texture, bool flipped=false) : base(gridSize, texture, flipped)
 {
 }
示例#58
0
 public CCJumpTiles3D (float duration, CCGridSize gridSize, int numberOfJumps = 0, float amplitude = 0)
     : base (duration, gridSize, amplitude)
 {
     NumberOfJumps = numberOfJumps;
 }
示例#59
0
 // returns the original (non-transformed) vertex at a given position
 public CCVertex3F OriginalVertex(CCGridSize pos)
 {
     return OriginalVertices[pos.X * (GridSize.Y + 1) + pos.Y];
 }
示例#60
0
 public CCLens3D(float duration, CCGridSize gridSize)
     : this(duration, gridSize, CCPoint.Zero, 0)
 {
 }