private void setSpritesheet(IsoDecoration isoDec) { if (this.dec.IsoDec != isoDec) { this.dec.IsoDec = isoDec; this.dec.updateTextures(); } }
void Awake() { if (Application.isEditor) { this.normalSprite = this.GetComponent <Decoration>().IsoDec; this.jumpingSprite = this.GetComponent <Decoration>().IsoDec; } }
private void SetFrame(IsoDecoration sheet, int column) { this.Entity.decoration.IsoDec = sheet; var tileToSet = column; if (sheet.nRows == 4) { tileToSet += (sheet.nCols * Mover.getDirectionIndex(this.Entity.mover.direction)); } this.Entity.decoration.Tile = tileToSet; this.Entity.decoration.updateTextures(false); //this.Entity.decoration.adaptate(); }
public abstract void update(IsoDecoration Decoration);
public override void deleteTexture(IsoDecoration texture) { //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(texture)); }
public GameObject addDecoration(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec) { GameObject newdecoration = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; newdecoration.name = "Decoration (clone)"; newdecoration.GetComponent <Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); newdecoration.GetComponent <Decoration>().Father = this; Decoration der = newdecoration.GetComponent <Decoration>(); der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); return(newdecoration); }
public abstract void deleteTexture(IsoDecoration Decoration);
public override void update(IsoDecoration it) { regenerate(it.getTexture()); }
public GameObject addGhost(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { if (this.ghost == null) { ghost = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; ghost.name = "GhostDer"; ghost.hideFlags = HideFlags.HideAndDontSave; Material ghostMaterial = new Material(Shader.Find("Transparent/Diffuse")); ghostMaterial.color = new Color(ghostMaterial.color.r, ghostMaterial.color.g, ghostMaterial.color.b, intensity); ghost.GetComponent <Renderer>().sharedMaterial = ghostMaterial; } Decoration der = ghost.GetComponent <Decoration>(); der.Father = this; der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); return(this.ghost); }
public abstract void deleteTexture(IsoDecoration Decoration);
public override void Update() { var timeLeft = Time.deltaTime; var desiredFrame = currentFrame; var desiredAnimation = currentAnimation; var lastValidAnimation = currentAnimation; var lastValidFrame = currentFrame; if (run.Count == 0 && (desiredAnimation != null || playQueue.Count > 0)) { // While there's time left to reproduce while (timeLeft > 0 && !animationLocked) { // Look for the next playable animation while (desiredAnimation == null && playQueue.Count > 0) { var animationToPlay = playQueue.Dequeue(); var foundAnimation = isoAnimations.Find(n => n.name.Equals(animationToPlay, StringComparison.InvariantCultureIgnoreCase)); if (foundAnimation == null || foundAnimation.isoAnimation == null || foundAnimation.isoAnimation.frames.Count == 0) { continue; } currentSheet = foundAnimation.isoAnimation.overrideSheet; if (currentSheet == null) { var foundSheet = sheets.Find(n => n.name.Equals(foundAnimation.isoAnimation.sheet, StringComparison.InvariantCultureIgnoreCase)); if (foundSheet != null) { currentSheet = foundSheet.isoDecoration; } } if (currentSheet == null) { continue; } lastValidAnimation = desiredAnimation = foundAnimation.isoAnimation; lastValidFrame = desiredFrame = 0; timeInCurrentFrame = 0f; } // And if we have animation we play it if (desiredAnimation != null) { var looped = false; var previousLoopedTimeLeft = 0f; // We move through the frames untill we run out of time or frames while (desiredAnimation != null && timeLeft > 0 && desiredFrame < desiredAnimation.frames.Count) { timeInCurrentFrame += timeLeft; if (timeInCurrentFrame > desiredAnimation.frames[desiredFrame].duration) { timeLeft = timeInCurrentFrame - desiredAnimation.frames[desiredFrame].duration; lastValidFrame = desiredFrame++; timeInCurrentFrame = 0f; } else { timeLeft = 0; } if (desiredFrame == desiredAnimation.frames.Count) { desiredFrame = 0; // In case of loop if (desiredAnimation.loop) { lastValidFrame = 0; // In case we already looped and time didn't decrease, this is an infinite loop if (looped && previousLoopedTimeLeft == timeLeft) { animationLocked = true; break; } previousLoopedTimeLeft = timeLeft; looped = true; } else { desiredAnimation = null; } } } } // But otherwise we exit else { break; } } } if (currentAnimation != desiredAnimation || currentAnimation != lastValidAnimation || currentFrame != desiredFrame || currentFrame != lastValidFrame) { currentAnimation = desiredAnimation; currentFrame = desiredFrame; if (lastValidAnimation != null && lastValidFrame < lastValidAnimation.frames.Count) { SetFrame(currentSheet, lastValidAnimation.frames[lastValidFrame].column); } } }
public GameObject addGhost(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { if (this.ghost == null) { ghost = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; ghost.name = "GhostDer"; ghost.hideFlags = HideFlags.HideAndDontSave; Material ghostMaterial = new Material(Shader.Find("Transparent/Diffuse")); ghostMaterial.color = new Color(ghostMaterial.color.r,ghostMaterial.color.g,ghostMaterial.color.b,intensity); ghost.GetComponent<Renderer>().sharedMaterial = ghostMaterial; } Decoration der = ghost.GetComponent<Decoration>(); der.Father = this; der.IsoDec = dec; der.setParameters (position,angle,parallel,centered); return this.ghost; }
public void ghostDecoration(Cell cs, Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { checkTransform(); if(ghost == null || ghostType != 2){ removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); }else{ if (ghost.GetComponent<Decoration> ().Father != cs) { removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); } } Decoration der = ghost.GetComponent<Decoration>(); der.IsoDec = dec; der.setParameters(position,angle,parallel,centered); }
public GameObject addDecoration(Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec) { GameObject newdecoration = GameObject.Instantiate(IsoSettingsManager.getInstance().getIsoSettings().defaultDecorationPrefab) as GameObject; newdecoration.name = "Decoration (clone)"; newdecoration.GetComponent<Renderer>().sharedMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse")); newdecoration.GetComponent<Decoration>().Father = this; Decoration der = newdecoration.GetComponent<Decoration>(); der.IsoDec = dec; der.setParameters(position,angle,parallel,centered); return newdecoration; }
public void OnInspectorGUI() { GUIStyle style = new GUIStyle(); EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None); EditorGUILayout.Space(); parallelDecoration = EditorGUILayout.Toggle("Draw Parallel", parallelDecoration); EditorGUILayout.Space(); autoanimate = EditorGUILayout.Toggle("Auto Animate", autoanimate); if (autoanimate) { FrameRate = float.Parse(EditorGUILayout.TextField("Frame Rate:", FrameRate.ToString())); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Frame Secuence:", GUIStyle.none, titleStyle); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("Let the frame secuence list empty if you want to use the default frame loop.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUIContent btt = new GUIContent("Add Frame"); Rect btr = GUILayoutUtility.GetRect(btt, style); if (GUI.Button(btr, btt)) { if (FrameSecuence == null) { FrameSecuence = new int[0]; } int[] tmpFrameSecuence = new int[FrameSecuence.Length + 1]; for (int i = 0; i < FrameSecuence.Length; i++) { tmpFrameSecuence[i] = FrameSecuence[i]; } tmpFrameSecuence[tmpFrameSecuence.Length - 1] = 0; FrameSecuence = tmpFrameSecuence; } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); btt = new GUIContent("Remove Frame"); btr = GUILayoutUtility.GetRect(btt, style); if (GUI.Button(btr, btt)) { if (FrameSecuence.Length > 0) { if (FrameSecuence == null) { FrameSecuence = new int[0]; } int[] tmpFrameSecuence = new int[FrameSecuence.Length - 1]; for (int i = 0; i < FrameSecuence.Length - 1; i++) { tmpFrameSecuence[i] = FrameSecuence[i]; } FrameSecuence = tmpFrameSecuence; } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); if (FrameSecuence != null) { for (int i = 0; i < FrameSecuence.Length; i++) { FrameSecuence[i] = int.Parse(EditorGUILayout.TextField(i.ToString(), FrameSecuence[i].ToString())); } } } EditorGUILayout.Space(); EditorGUILayout.PrefixLabel("Decoration Objects", GUIStyle.none, titleStyle); GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f); EditorGUILayout.BeginVertical("Box"); IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList(); int maxTextures = 8; float anchoTextura = (Screen.width - 30) / maxTextures; if (isoDecorations.Length > maxTextures * LTSS) { scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura * LTSS)); } Event e = Event.current; int currentTexture = 0; foreach (IsoDecoration it in isoDecorations) { if (it.getTexture() == null) { continue; } if (currentTexture == 0) { EditorGUILayout.BeginHorizontal(); } Rect auxRect = GUILayoutUtility.GetRect(anchoTextura, anchoTextura); Rect border = new Rect(auxRect); auxRect.x += 2; auxRect.y += 2; auxRect.width -= 4; auxRect.height -= 4; if (e.isMouse && border.Contains(e.mousePosition)) { if (e.type == EventType.mouseDown) { paintingIsoDecoration = it; this.Repaint = true; } } if (it == paintingIsoDecoration) { EditorGUI.DrawRect(border, Color.yellow); } GUI.DrawTexture(auxRect, it.getTexture()); currentTexture++; if (currentTexture == maxTextures) { EditorGUILayout.EndHorizontal(); currentTexture = 0; } } if (currentTexture != 0) { GUILayoutUtility.GetRect((maxTextures - currentTexture) * anchoTextura, anchoTextura); EditorGUILayout.EndHorizontal(); } if (isoDecorations.Length > maxTextures * LTSS) { EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
public override void deleteTexture(IsoDecoration texture) { //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(texture)); }
public override void update(IsoDecoration it) { regenerate (it.getTexture ()); }
public IEnumerator AnimateEntity(string animation, string then = null) { // Clear the current animation animationLocked = false; currentAnimation = null; playQueue.Clear(); // Find the animation var isoAnimation = isoAnimations.Find(n => n.name.Equals(animation, StringComparison.InvariantCultureIgnoreCase)); if (isoAnimation == null || isoAnimation.isoAnimation == null) { yield return(null); } // Find a sheet IsoDecoration sheet = isoAnimation.isoAnimation.overrideSheet; if (sheet == null) { NameIsoDecoration namedSheet = sheets.Find(s => { return(s.name.Equals(isoAnimation.isoAnimation.sheet, StringComparison.InvariantCultureIgnoreCase)); }); if (namedSheet != null) { sheet = namedSheet.isoDecoration; } } if (sheet == null) { yield return(null); } var ge = Current; // Stop all other animations foreach (var kv in run) { run[kv.Key] = false; } // Add the new one run.Add(ge, true); // Perform the animation foreach (var frame in isoAnimation.isoAnimation.frames) { SetFrame(sheet, frame.column); yield return(new WaitForSeconds(frame.duration)); if (!run[ge]) { break; } } var desiredRun = run[ge]; run.Remove(ge); if (desiredRun && !string.IsNullOrEmpty(then)) { Play(then); } }
public void OnInspectorGUI() { GUIStyle style = new GUIStyle(); EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None); EditorGUILayout.Space(); parallelDecoration = EditorGUILayout.Toggle("Draw Parallel",parallelDecoration); EditorGUILayout.Space(); autoanimate = EditorGUILayout.Toggle ("Auto Animate", autoanimate); if (autoanimate) { FrameRate = float.Parse(EditorGUILayout.TextField("Frame Rate:", FrameRate.ToString())); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Frame Secuence:",GUIStyle.none, titleStyle); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("Let the frame secuence list empty if you want to use the default frame loop.", MessageType.None); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUIContent btt = new GUIContent("Add Frame"); Rect btr = GUILayoutUtility.GetRect(btt, style); if(GUI.Button(btr,btt)){ if(FrameSecuence==null) FrameSecuence = new int[0]; int [] tmpFrameSecuence = new int[FrameSecuence.Length+1]; for(int i=0; i<FrameSecuence.Length; i++) tmpFrameSecuence[i] = FrameSecuence[i]; tmpFrameSecuence[tmpFrameSecuence.Length-1] = 0; FrameSecuence=tmpFrameSecuence; } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); btt = new GUIContent("Remove Frame"); btr = GUILayoutUtility.GetRect(btt, style); if(GUI.Button(btr,btt)){ if(FrameSecuence.Length>0){ if(FrameSecuence==null) FrameSecuence = new int[0]; int [] tmpFrameSecuence = new int[FrameSecuence.Length-1]; for(int i=0; i<FrameSecuence.Length-1; i++) tmpFrameSecuence[i] = FrameSecuence[i]; FrameSecuence=tmpFrameSecuence; } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); if(FrameSecuence!=null) for(int i=0; i<FrameSecuence.Length; i++) FrameSecuence[i] = int.Parse(EditorGUILayout.TextField(i.ToString(), FrameSecuence[i].ToString())); } EditorGUILayout.Space(); EditorGUILayout.PrefixLabel("Decoration Objects",GUIStyle.none, titleStyle); GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f); EditorGUILayout.BeginVertical("Box"); IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList(); int maxTextures = 8; float anchoTextura = (Screen.width - 30) / maxTextures; if(isoDecorations.Length > maxTextures*LTSS) scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura*LTSS)); Event e = Event.current; int currentTexture = 0; foreach(IsoDecoration it in isoDecorations){ if(it.getTexture() == null) continue; if(currentTexture == 0) EditorGUILayout.BeginHorizontal(); Rect auxRect = GUILayoutUtility.GetRect(anchoTextura,anchoTextura); Rect border = new Rect(auxRect); auxRect.x+=2;auxRect.y+=2;auxRect.width-=4;auxRect.height-=4; if (e.isMouse && border.Contains(e.mousePosition)) { if(e.type == EventType.mouseDown){ paintingIsoDecoration = it; this.Repaint = true; } } if(it == paintingIsoDecoration) EditorGUI.DrawRect(border,Color.yellow); GUI.DrawTexture(auxRect,it.getTexture()); currentTexture++; if(currentTexture == maxTextures){EditorGUILayout.EndHorizontal(); currentTexture = 0;} } if(currentTexture != 0){ GUILayoutUtility.GetRect((maxTextures - currentTexture)*anchoTextura,anchoTextura); EditorGUILayout.EndHorizontal(); } if(isoDecorations.Length > maxTextures*LTSS) EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
private void setSpritesheet(IsoDecoration isoDec) { if (this.dec.IsoDec != isoDec) { this.dec.IsoDec = isoDec; this.dec.updateTextures(); } }
/******************** * Movement factory * ***************/ public static Movement createMovement(MovementType type, Entity entity, Mover mover, Decoration dec, IsoDecoration sheet, Vector3 from, Vector3 to, Cell origin, Cell destination, Dictionary <string, object> mParams) { Movement movement = null; switch (type) { case MovementType.Lineal: movement = new LinealMovement(); break; case MovementType.Parabolic: movement = new ParabolicMovement(); break; case MovementType.Instant: movement = new InstantMovement(); break; case MovementType.Turn: movement = new TurnMovement(); break; default: movement = new LinealMovement(); break; } movement.setParams(mParams); movement.origin = origin; movement.destination = destination; movement.from = from; movement.to = to; movement.entity = entity; movement.dec = dec; movement.sheet = sheet; movement.mover = mover; return(movement); }
public abstract void update(IsoDecoration Decoration);
public void ghostDecoration(Cell cs, Vector3 position, int angle, bool parallel, bool centered, IsoDecoration dec, float intensity) { checkTransform(); if (ghost == null || ghostType != 2) { removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); } else { if (ghost.GetComponent <Decoration> ().Father != cs) { removeGhost(); ghostType = 2; ghost = cs.addGhost(position, angle, parallel, centered, dec, intensity); } } Decoration der = ghost.GetComponent <Decoration>(); der.IsoDec = dec; der.setParameters(position, angle, parallel, centered); }
/******************** * Movement factory * ***************/ public static Movement createMovement(MovementType type, Entity entity, Mover mover, Decoration dec, IsoDecoration sheet, Vector3 from, Vector3 to, Cell origin, Cell destination, Dictionary<string, object> mParams) { Movement movement = null; switch(type){ case MovementType.Lineal: movement = new LinealMovement(); break; case MovementType.Parabolic: movement = new ParabolicMovement(); break; case MovementType.Instant: movement = new InstantMovement(); break; case MovementType.Turn: movement = new TurnMovement(); break; default: movement = new LinealMovement(); break; } movement.setParams(mParams); movement.origin = origin; movement.destination = destination; movement.from = from; movement.to = to; movement.entity = entity; movement.dec = dec; movement.sheet = sheet; movement.mover = mover; return movement; }