public void Duplicate(Vector3 newPosition) { GameObject newClone = (GameObject)Instantiate(clone, newPosition, transform.rotation); CubeAnimations.AnimateDuplication(newClone); duplicateTimes--; }
private void Awake() { OnMovementDone += () => { currentMovementCount++; if (currentMovementCount >= movementCount) { isMovementDone = true; OnMovementTotalyDone?.Invoke(); } }; startPos = transform.position; cubeLooper = GetComponent <CubeLooper>(); cubeCloner = GetComponent <CubeCloner>(); cubeAnimations = GetComponent <CubeAnimations>(); cubeTargetFinder = GetComponent <CubeTargetFinder>(); Material material = GetComponent <MeshRenderer>().material; foreach (MeshRenderer clonable in clonableIndicator) { clonable.material = material; } }
public override void OnEndExecution() { if (breakIce && endPosition.ToVector3 == new Vector3Int(transform.position).ToVector3) { Level.Singleton.RemoveEntity(endPosition); Destroy(this.gameObject); } else if (endPosition.z != transform.position.z || endPosition.x != transform.position.x) { CubeAnimations.AnimateSlide(gameObject, new Vector3Int(endPosition.x, Mathf.RoundToInt(transform.position.y), endPosition.z).ToVector3); } else if (endPosition.y < transform.position.y) { CubeAnimations.AnimateMove(gameObject, Vector3.down, endPosition.ToVector3); } Vector3Int next = new Vector3Int(transform.position); if (!breakIce && next.x > 10 || next.x < 0 || next.z > 10 || next.z < 0) { Level.Singleton.RemoveEntity(new Vector3Int(transform.position)); Destroy(gameObject); } if (transform.forward == Vector3.down && SpriteSheet.CurrentSequence != (int)Mood.EyesClosed) { setMood(Mood.EyesClosed); } }
public override void MoveTo(Vector3Int endPosition) { setMood(Cube.Mood.EyesClosed); this.endPosition = endPosition; Level.Singleton.RemoveEntity(new Vector3Int(transform.position)); Level.Singleton.AddEntity(this, endPosition); CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition.ToVector3); }
//private bool justSelected = false; #endregion #region Command Management /// <summary> /// Moves Cube to the direction . /// </summary> /// <param name='nextPosition'> /// Next position. /// </param> public virtual void MoveTo(Vector3Int nextPosition) { if (!Level.Singleton.ContainsElement(nextPosition)) { Level.Singleton.RemoveEntity(new Vector3Int(transform.position)); Level.Singleton.AddEntity(this, nextPosition); Level.Singleton.MoveCube(transform.position, nextPosition.ToVector3); CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition.ToVector3); } }
public void Duplicate(Vector3 newPosition) { if (duplicateTimes > 0 && CubeHelper.IsFree(transform.position + Vector3.up)) { GameObject newClone = (GameObject)Instantiate(clone, newPosition, transform.rotation); CubeAnimations.AnimateDuplication(newClone); EndExecution(); duplicateTimes--; } }
public void Mimic(Vector3 nextPosition, Vector3 direction) { Level.Singleton.Entities.Remove(transform.position); CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition); Level.Singleton.Entities.Add(transform.position, this); Vector3 NextTwinPosition = twin.GetComponent <TwinCube>().FindNextTwinPosition(direction); Level.Singleton.Entities.Remove(twin.transform.position); CubeAnimations.AnimateMove(twin, Vector3.down, NextTwinPosition); Level.Singleton.Entities.Add(NextTwinPosition, twin.GetComponent <TwinCube>()); }
public void Bounce(Vector3 endPosition, List <Vector3> bouncePositions) { Level.Singleton.RemoveEntity(transform.position); bouncePositions.Add(endPosition); Vector3[] positions = new Vector3[bouncePositions.Count]; for (int i = 0; i < bouncePositions.Count; i++) { print(bouncePositions[i]); positions[i] = bouncePositions[i]; } CubeAnimations.AnimateBounce(gameObject, Vector3.down, positions); Level.Singleton.AddEntity(endPosition, this); }
/// <summary> /// Make the cube, with position currentPosition, fall. /// </summary> /// <param name='currentPosition'> /// Last. /// </param> public virtual void Gravity(Vector3Int currentPosition) { Level.Singleton.RemoveEntity(currentPosition); if (CubeHelper.IsFree(new Vector3Int(currentPosition.ToVector3 + Vector3.down)) && currentPosition.y > 1) { currentPosition.y = currentPosition.y - 1; Level.Singleton.AddEntity(this, currentPosition); Gravity(currentPosition); } else { Level.Singleton.AddEntity(this, currentPosition); CubeAnimations.AnimateMove(gameObject, Vector3.down, currentPosition.ToVector3); } }
public void Mimic(Vector3 nextPosition, Vector3 direction) { Level.Singleton.RemoveEntity(transform.position); CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition); Level.Singleton.AddEntity(nextPosition, this); Vector3 NextTwinPosition = twin.GetComponent <TwinCube>().FindNextTwinPosition(direction); Level.Singleton.RemoveEntity(twin.transform.position); CubeAnimations.AnimateMove(twin, Vector3.down, NextTwinPosition); Level.Singleton.AddEntity(NextTwinPosition, twin.GetComponent <TwinCube>()); if (NextTwinPosition.x >= Level.Dimension || NextTwinPosition.x < 0 || NextTwinPosition.z >= Level.Dimension || NextTwinPosition.z < 0) { twin.GetComponent <TwinCube>().FallOutOfBounds(NextTwinPosition); } }
public void CloudFall() { if (transform.position.y > 1 && Level.Singleton.getEntity(transform.position + Vector3.down) is CloudCube) { CloudCube cl = (CloudCube)Level.Singleton.getEntity(transform.position + Vector3.down); if (!CubeHelper.IsFree(new Vector3Int(cl.transform.position + Vector3.down)) || cl.transform.position.y == 1) { Level.Singleton.RemoveEntity(cl.transform.position); Level.Singleton.RemoveEntity(cl.transform.position + Vector3.up); Level.Singleton.AddEntity(cl, cl.transform.position + Vector3.up); Level.Singleton.AddEntity(this, cl.transform.position); Vector3 aux = cl.transform.position; this.cl = cl; CubeAnimations.AnimateMove(gameObject, Vector3.down, aux); cl.renderer.enabled = false; //CubeControllerInput cc = cl.gameObject.GetComponent<CubeControllerInput> (); //cc.NotifyMoveTO (new Move (cl, new Vector3Int( cl.transform.position + Vector3.up))); //TODO cambiar transform por animacion //CubeAnimations.AnimateMove (cl.gameObject, Vector3.down, aux + Vector3.up); //this.transform.position = aux; cl.transform.position = aux + Vector3.up; } else if (CubeHelper.IsFree(new Vector3Int(cl.transform.position + Vector3.down))) { Level.Singleton.RemoveEntity(transform.position); this.cl = cl; cl.renderer.enabled = false; Debug.Log(transform.position + Vector3.down + Vector3.down); //transform.position = cl.transform.position + Vector3.down; Level.Singleton.AddEntity(this, transform.position + Vector3.down + Vector3.down); //CubeAnimations.AnimateMove (gameObject, Vector3.down, cl.transform.position + Vector3.down); Gravity(new Vector3Int(transform.position + Vector3.down + Vector3.down)); //CloudFall(); } } }
public void MagneticMoveTo(Vector3 nextPosition, Vector3 floorDirection) { Level.Singleton.RemoveEntity(transform.position); CubeAnimations.AnimateMove(gameObject, floorDirection, nextPosition); Level.Singleton.AddEntity(nextPosition, this); }
public void Slide(Vector3 endPosition, Vector3 direction) { Level.Singleton.RemoveEntity(transform.position); CubeAnimations.AnimateSlide(gameObject, endPosition);//"SlideEndExecution", new float[] { direction.x, direction.y, direction.z } Level.Singleton.AddEntity(endPosition, this); }
public void FallOutOfBounds(Vector3 outOfBouncePosition) { CubeAnimations.AnimateSlide(gameObject, outOfBouncePosition + new Vector3(0, -10, 0), "KillCube", null); }
public void Subir() { Debug.Log("subir"); CubeAnimations.AnimateMove(gameObject, Vector3.down, transform.position + Vector3.up); }
public virtual void MoveTo(Vector3 nextPosition) { Level.Singleton.Entities.Remove(transform.position); CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition); Level.Singleton.Entities.Add(nextPosition, this); }
private void Awake() { cubeAnimations = GetComponent <CubeAnimations>(); cubeTargetFinder = GetComponent <CubeTargetFinder>(); }