public CCQuad3 this[CCGridSize pos] { get { return this[pos.X, pos.Y]; } set { this[pos.X, pos.Y] = value; } }
public void TurnOffTile(CCGridSize pos) { var coords = new CCQuad3(); //memset(&coords, 0, sizeof(ccQuad3)); SetTile(pos, ref coords); }
public CCLens3D(float duration, CCGridSize gridSize, CCPoint position, float radius) : base(duration, gridSize) { Position = position; Radius = radius; LensScale = 0.7f; Concave = false; }
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++; } } } } }
public CCRipple3D(float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude) : base(duration, gridSize, amplitude) { Position = position; Radius = radius; Waves = waves; }
public CCQuad3 this[CCGridSize pos] { get { return(this[pos.X, pos.Y]); } set { this[pos.X, pos.Y] = value; } }
public CCLens3D (float duration, CCGridSize gridSize, CCPoint position, float radius) : base (duration, gridSize) { Position = position; Radius = radius; LensScale = 0.7f; Concave = false; }
public CCRipple3D (float duration, CCGridSize gridSize, CCPoint position, float radius, int waves, float amplitude) : base (duration, gridSize, amplitude) { Position = position; Radius = radius; Waves = waves; }
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); } }
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]); }
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])); }
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)); }
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); } }
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)); }
// // 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); }
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)); }
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); }
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)); }
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)); }
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); }
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); }
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); }
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); } }
/// <summary> /// returns the original (non-transformed) vertex at a given position /// </summary> public CCVertex3F OriginalVertex (CCGridSize pos) { return grid3D.OriginalVertex (pos); }
public CCTwirl (float duration, CCGridSize gridSize, CCPoint position, int twirls = 0, float amplitude = 0) : base (duration, gridSize, amplitude) { Position = position; Twirls = twirls; }
/// <summary> /// returns the vertex at a given position /// </summary> public CCVertex3F Vertex (CCGridSize pos) { return grid3D [pos]; }
public CCLens3D (float duration, CCGridSize gridSize) : this (duration, gridSize, CCPoint.Zero, 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)); }
/// <summary> /// returns the original (non-transformed) vertex at a given position /// </summary> public CCVertex3F OriginalVertex(CCGridSize pos) { return(grid3D.OriginalVertex(pos)); }
protected CCGrid3DAction(float duration, CCGridSize gridSize) : this(duration, gridSize, 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) { }
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); }
public void TurnOffTile (CCGridSize pos) { var coords = new CCQuad3 (); //memset(&coords, 0, sizeof(ccQuad3)); SetTile (pos, ref coords); }
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; }
public void TurnOnTile (CCGridSize pos) { CCQuad3 orig = OriginalTile (pos); SetTile (pos, ref orig); }
public void TurnOnTile(CCGridSize pos) { CCQuad3 orig = OriginalTile(pos); SetTile(pos, ref orig); }
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); }
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); }
/// <summary> /// sets a new vertex at a given position /// </summary> public void SetVertex(CCGridSize pos, ref CCVertex3F vertex) { grid3D [pos] = vertex; }
public CCFadeOutBLTiles(float duration, CCGridSize gridSize) : base(duration, gridSize) { }
/// <summary> /// returns the vertex at a given position /// </summary> public CCVertex3F Vertex(CCGridSize pos) { return(grid3D [pos]); }
/// <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]); }
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; }
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); }
// returns the original tile (untransformed) at the given position public CCQuad3 OriginalTile(CCGridSize pos) { return OriginalTile(pos.X, pos.Y); }
protected CCGrid3DAction (float duration, CCGridSize gridSize, float amplitude) : base (duration, gridSize, amplitude) { }
/// <summary> /// sets a new vertex at a given position /// </summary> public void SetVertex (CCGridSize pos, ref CCVertex3F vertex) { grid3D [pos] = vertex; }
public CCTwirl (float duration, CCGridSize gridSize) : this (duration, gridSize, CCPoint.Zero) { }
public CCGridAction(float duration, CCGridSize gridSize) : this(duration, gridSize, 0) { }
protected CCGrid3DAction (float duration, CCGridSize gridSize) : this (duration, gridSize, 0) { }
public CCGrid3D(CCGridSize gridSize, CCTexture2D texture, bool flipped=false) : base(gridSize, texture, flipped) { }
public CCJumpTiles3D (float duration, CCGridSize gridSize, int numberOfJumps = 0, float amplitude = 0) : base (duration, gridSize, amplitude) { NumberOfJumps = numberOfJumps; }
// returns the original (non-transformed) vertex at a given position public CCVertex3F OriginalVertex(CCGridSize pos) { return OriginalVertices[pos.X * (GridSize.Y + 1) + pos.Y]; }
public CCLens3D(float duration, CCGridSize gridSize) : this(duration, gridSize, CCPoint.Zero, 0) { }