void UpdateAnim() { if (currentPlayedAnim != null) { TileAnim.AnimFrame animFrame = currentPlayedAnim.frames[currentAnimIndex]; if (animFrame.duration > 0) { if ((Time.time - currentAnimIndexStartDate) >= animFrame.duration) { currentAnimIndex++; if (currentPlayedAnim.loop) { currentAnimIndex %= currentPlayedAnim.frames.Length; } if (currentPlayedAnim.frames.Length > currentAnimIndex) { ApplyAnimFrame(); } else { currentPlayedAnim = null; onCurrentAnimEnd?.Invoke(); } } } } }
private void chkAnimationMode_CheckedChanged(object sender, EventArgs e) { if (inAnimMode != chkAnimationMode.Checked) { inAnimMode = chkAnimationMode.Checked; if (inAnimMode) { chosenAnim = new TileAnim(chosenTile, chosenTileset); } else { if (chosenAnim.Frames.Count > 0) { chosenTile = chosenAnim.Frames[0].Texture; chosenTileset = chosenAnim.Frames[0].Sheet; } else { chosenTile = new Loc2D(); chosenTileset = 0; } currentTileset = chosenTileset; } } UpdateAnimFrames(); RefreshTileSelect(); RefreshAnimControls(); }
public static void PaintTile(Loc2D loc, TileAnim anim) { if (!Operations.IsInBound(Processor.CurrentMap.Width, Processor.CurrentMap.Height, loc.X, loc.Y)) { return; } switch (chosenEditLayer) { case EditLayer.Data: { break; } case EditLayer.Ground: case EditLayer.PropBack: case EditLayer.PropFront: case EditLayer.Fringe: { GetChosenEditLayer().Tiles[loc.X, loc.Y] = anim; break; } } Logic.Display.Screen.AddResult(new Logic.Results.SetTile(Processor.CurrentMap, loc)); }
static void GetTileTexFromTileAnim(TileAnim anim) { if (anim.Frames.Count == 1) { inAnimMode = false; chosenTileset = anim.Frames[0].Sheet; chosenTile = anim.Frames[0].Texture; currentTileset = chosenTileset; //refresh RefreshCallback refresh = new RefreshCallback(MainPanel.CurrentMapEditor.RefreshTileSelect); MainPanel.CurrentMapEditor.Invoke(refresh); } else if (anim.Frames.Count > 1) { inAnimMode = true; chosenAnim = new TileAnim(anim); //refresh RefreshCallback refresh = new RefreshCallback(MainPanel.CurrentMapEditor.RefreshTileSelect); MainPanel.CurrentMapEditor.Invoke(refresh); } }
public void PlayTileAnim(int frame) { if (animTile == null) { animTile = GameObject.Find("GUI_GrowFactor_2048").GetComponent <TileAnim>(); } animTile._currentFrame = frame; animTile.MESH_refresh(); }
public MapLayer(string name, int width, int height) { Name = name; Tiles = new TileAnim[width, height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Tiles[x, y] = new TileAnim(); } } }
// Use this for initialization void Start() { float scalar = transform.lossyScale.x;// Account for scale factor for this module being smaller, check KTANE official discord in #modding foreach (Light onelight in lights) { onelight.range *= scalar; } animLight.range *= scalar; TileAnim.SetActive(false); Generate4x4Puzzle(); for (int selidx = 0; selidx < tileSelectables.Length; selidx++) { int y = selidx; tileSelectables[selidx].OnInteract += delegate { tileSelectables[y].AddInteractionPunch(); kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform); if (!solved) { inputsOverall.Add(y); } return(false); }; } bombInfo.OnBombExploded += delegate { if (solved || isGenerating) { return; } string debugMoves = ""; foreach (int inIdx in inputsOverall) { debugMoves += debugCoordCol[inIdx % 4] + debugCoordRow[inIdx / 4 % 4] + " "; } debugMoves.Trim(); Debug.LogFormat("[15 Mystic Lights #{0}]: The following moves used on the given board when the bomb blew were {1}", curmodid, debugMoves); }; moduleSelf.OnActivate += delegate { if (TwitchPlaysActive) { StatusLight.SetActive(true); } else { StatusLight.SetActive(false); } }; //StatusLight.SetActive(false); }
public static TileAnim GetBrush() { TileAnim anim; if (inAnimMode) { anim = new TileAnim(chosenAnim); } else { anim = new TileAnim(chosenTile, chosenTileset); } return(anim); }
public MapEditor() { drawLock = new object(); inAnimMode = false; chosenTile = new Loc2D(); chosenTileset = 0; chosenAnim = new TileAnim(); SetupLayerVisibility(); InitializeComponent(); if (tiles == null) { tiles = new List <Image>(); for (int i = 0; i < 10; i++) { tiles.Add(new Bitmap(Paths.TilesPath + "Tiles" + i + ".png")); } } RefreshTitle(); if (!Directory.Exists(Paths.MapPath)) { Directory.CreateDirectory(Paths.MapPath); } openFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath; saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + Paths.MapPath; tbTileset.Value = 0; nudTimeLimit.Maximum = Int32.MaxValue; for (int i = 0; i < 12; i++) { cbWeather.Items.Add(((Enums.Weather)i).ToString()); } nudDarkness.Maximum = Int32.MaxValue; nudFrameLength.Maximum = Int32.MaxValue; RefreshTileset(); RefreshAnimControls(); ReloadMusic(); LoadMapProperties(); }
public void PlayAnim(TileAnim anim, System.Action onEndCallback = null) { if (anim.frames.Length > 0) { currentPlayedAnim = anim; currentAnimIndex = 0; ApplyAnimFrame(); } else { Debug.LogError("Trying to play empty anim " + anim, anim); currentPlayedAnim = null; } onCurrentAnimEnd = onEndCallback; }
public override void OnInspectorGUI() { TileAnim t = target as TileAnim; DrawDefaultInspector(); if (GUI.changed) { t._width = Mathf.Clamp(t._width, 0, 999); t._height = Mathf.Clamp(t._height, 0, 999); t._currentFrame = Mathf.Clamp(t._currentFrame, 0, t._lastFrame); t._lastFrame = Mathf.Clamp(t._lastFrame, 0, t._frameRects.Length - 1); t._frameTick = Mathf.Clamp(t._frameTick, 0, 20); t.MESH_refresh(); } }
IEnumerator PlaySolveAnim(int ycor, int xcor) { playingAnim = true; kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSequenceMechanism, transform); Vector3 pointTL = AnimPointTL.transform.localPosition; Vector3 pointBR = AnimPointBR.transform.localPosition; Vector3 pointD = AnimPointD.transform.localPosition; //Vector3 LastStatLightScale = new Vector3(StatusLight.transform.localScale.x, StatusLight.transform.localScale.y, StatusLight.transform.localScale.z); bool lgtSteSgl = (bool)GetFirstNonNullTileState(); for (int idx = 0; idx < textMeshes.Length; idx++) { textMeshes[idx].gameObject.SetActive(false); } float localX = pointBR.x * xcor / 3f + pointTL.x * (3 - xcor) / 3f; float localY = pointBR.y * ycor / 3f + pointTL.y * (3 - ycor) / 3f; for (float x = 1; x >= 0; x -= Time.deltaTime) { float localZ = pointD.z * x; TileAnim.SetActive(true); StatusLight.SetActive(true); TileAnim.transform.localPosition = new Vector3(localX, localY, localZ); StatusLight.transform.localPosition = new Vector3(localX, localY, localZ + .005f); AnimRenderer.material = lgtSteSgl ? materials[0] : materials[1]; animLight.color = lgtSteSgl ? Color.yellow : Color.blue; animLight.enabled = true; yield return(null); } StatusLight.transform.localPosition = new Vector3(localX, localY, .005f); TileAnim.SetActive(false); int tileIndex = xcor + 4 * ycor; tiles[tileIndex].SetActive(true); meshRenderers[tileIndex].material = lgtSteSgl ? materials[0] : materials[1]; lights[tileIndex].enabled = true; lights[tileIndex].color = lgtSteSgl ? Color.yellow : Color.blue; moduleSelf.HandlePass(); yield return(null); }
public static void FillTile(Loc2D loc, TileAnim anim) { if (!Operations.IsInBound(Processor.CurrentMap.Width, Processor.CurrentMap.Height, loc.X, loc.Y)) { return; } switch (chosenEditLayer) { case EditLayer.Data: { break; } case EditLayer.Ground: case EditLayer.PropBack: case EditLayer.PropFront: case EditLayer.Fringe: { TileAnim oldAnim = GetChosenEditLayer().Tiles[loc.X, loc.Y]; if (oldAnim != anim) { Operations.FillArray(GetChosenEditLayer().Tiles.GetLength(0), GetChosenEditLayer().Tiles.GetLength(1), (int x, int y) => { return(GetChosenEditLayer().Tiles[x, y] == oldAnim); }, (int x, int y) => { GetChosenEditLayer().Tiles[x, y] = new TileAnim(anim); Logic.Display.Screen.AddResult(new Logic.Results.SetTile(Processor.CurrentMap, new Loc2D(x, y))); }, loc); } break; } } }
public void PlayTileAnim(int frame) { if(animTile == null )animTile = GameObject.Find("GUI_GrowFactor_2048").GetComponent<TileAnim>(); animTile._currentFrame = frame; animTile.MESH_refresh(); }
IEnumerator PlaySlidingAnim(int direction) { playingAnim = true; TileAnim.SetActive(true); int[] emptyTile = GetFirstNullTile(); int xIdx = emptyTile[0]; int yIdx = emptyTile[1]; if (xIdx < lightStates.GetLength(0) && xIdx >= 0 && yIdx < lightStates.GetLength(1) && yIdx >= 0 && direction >= 0 && direction < 4) { if (!instantMysticLights) { float[] coordStart = new float[2] { 0, 0 }; float[] coordEnd = new float[2] { 0, 0 }; Vector3 pointTL = AnimPointTL.transform.localPosition; Vector3 pointBR = AnimPointBR.transform.localPosition; // The idea for this is to grab the specified point by using local coordinates to manipulate the position. for (int p = 0; p < 3; p++) { // Grab end points of the animation if (xIdx > p) { coordEnd[0] += pointBR.x; } else { coordEnd[0] += pointTL.x; } if (yIdx > p) { coordEnd[1] += pointBR.y; } else { coordEnd[1] += pointTL.y; } // Grab start points of the animation if (direction % 2 == 0) // If the direction involves the x-axis { if (direction / 2 <= 0) // If the direction is negative { if (p < xIdx - 1) { coordStart[0] += pointBR.x; } else { coordStart[0] += pointTL.x; } } else// If the direction is positive { if (p < xIdx + 1) { coordStart[0] += pointBR.x; } else { coordStart[0] += pointTL.x; } } if (p < yIdx) { coordStart[1] += pointBR.y; } else { coordStart[1] += pointTL.y; } } else// if the direction involves the y-axis { if (direction / 2 > 0)// If the direction is negative { if (p < yIdx + 1) { coordStart[1] += pointBR.y; } else { coordStart[1] += pointTL.y; } } else// If the direction is positive { if (p < yIdx - 1) { coordStart[1] += pointBR.y; } else { coordStart[1] += pointTL.y; } } if (p < xIdx) { coordStart[0] += pointBR.x; } else { coordStart[0] += pointTL.x; } } } coordEnd[0] /= 3f; coordEnd[1] /= 3f; coordStart[0] /= 3f; coordStart[1] /= 3f; int xIntIdx = direction == 0 ? xIdx - 1 : direction == 2 ? xIdx + 1 : xIdx; // X coordinate of where the module was interacted int yIntIdx = direction == 1 ? yIdx - 1 : direction == 3 ? yIdx + 1 : yIdx; // Y coordinate of where the module was interacted //print("Suggest last interaction was at (" + xIntIdx + "," + yIntIdx + ")"); // Update the light around the tile that was moved. if (yIdx + 1 < 4 && direction != 3) { UpdateSpecificLight(xIdx, yIdx + 1); } if (yIdx - 1 >= 0 && direction != 1) { UpdateSpecificLight(xIdx, yIdx - 1); } if (xIdx + 1 < 4 && direction != 2) { UpdateSpecificLight(xIdx + 1, yIdx); } if (xIdx - 1 >= 0 && direction != 0) { UpdateSpecificLight(xIdx - 1, yIdx); } for (float i = 0; i < 1f; i += Time.deltaTime * 4) { float finalposX = coordStart[0] * i + coordEnd[0] * (1f - i); float finalposY = coordStart[1] * i + coordEnd[1] * (1f - i); /* * for (int x = 0; x < animDelay/2; x++) * { * if (x < i) * { * finalposX += coordStart[0]; * finalposY += coordStart[1]; * } * else * { * finalposX += coordEnd[0]; * finalposY += coordEnd[1]; * } * * } * finalposX /= animDelay/2; * finalposY /= animDelay/2; */ TileAnim.transform.localPosition = new Vector3(finalposY, finalposX, 0.0f); bool lgtSteSgl = (bool)lightStates[xIntIdx, yIntIdx]; AnimRenderer.material = lgtSteSgl ? materials[0] : materials[1]; animLight.color = lgtSteSgl ? Color.yellow : Color.blue; animLight.enabled = true; UpdateSpecificLight(xIdx, yIdx); yield return(null); } } kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform); } TileAnim.SetActive(false); animLight.enabled = false; UpdateAllLights(); if (isAllCorrect()) { Debug.LogFormat("[15 Mystic Lights #{0}]: All the lights are in 1 color.", curmodid); if (hasExitedInitial) { int[] firstEmpty = GetFirstNullTile(); StartCoroutine(PlaySolveAnim(firstEmpty[0], firstEmpty[1])); solved = true; } else { StartCoroutine(PlayTransitionAnim()); hasExitedInitial = true; } } playingAnim = false; yield return(null); }
IEnumerator PlaySolveAnim(int ycor, int xcor) { playingAnim = true; kMAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSequenceMechanism, transform); Vector3 pointTL = AnimPointTL.transform.localPosition; Vector3 pointBR = AnimPointBR.transform.localPosition; Vector3 pointD = AnimPointD.transform.localPosition; //Vector3 LastStatLightScale = new Vector3(StatusLight.transform.localScale.x, StatusLight.transform.localScale.y, StatusLight.transform.localScale.z); bool lgtSteSgl = (bool)GetFirstNonNullTileState(); for (int idx = 0; idx < textMeshes.Length; idx++) { textMeshes[idx].gameObject.SetActive(false); } for (int x = animDelay * 2; x >= 0; x--) { float localX = 0; float localY = 0; float localZ = 0; for (int p = 0; p < 3; p++) { // Grab end points of the animation if (xcor > p) { localX += pointBR.x; } else { localX += pointTL.x; } if (ycor > p) { localY += pointBR.y; } else { localY += pointTL.y; } } for (int y = 0; y < x; y++) { localZ += pointD.z; } localZ /= animDelay * 2; localX /= 3; localY /= 3; TileAnim.SetActive(true); StatusLight.SetActive(true); TileAnim.transform.localPosition = new Vector3(localX, localY, localZ); StatusLight.transform.localPosition = new Vector3(localX, localY, localZ + .005f); AnimRenderer.material = lgtSteSgl ? materials[0] : materials[1]; animLight.color = lgtSteSgl ? Color.yellow : Color.blue; animLight.enabled = true; yield return(new WaitForSeconds(0)); } TileAnim.SetActive(false); int tileIndex = xcor + 4 * ycor; tiles[tileIndex].SetActive(true); meshRenderers[tileIndex].material = lgtSteSgl ? materials[0] : materials[1]; lights[tileIndex].enabled = true; lights[tileIndex].color = lgtSteSgl ? Color.yellow : Color.blue; moduleSelf.HandlePass(); yield return(null); }