Esempio n. 1
0
    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);
        }
    }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
    //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);
        }
    }
Esempio n. 4
0
    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>());
    }
Esempio n. 5
0
 /// <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);
     }
 }
Esempio n. 6
0
    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);
        }
    }
Esempio n. 7
0
 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();
         }
     }
 }
Esempio n. 8
0
 public void Subir()
 {
     Debug.Log("subir");
     CubeAnimations.AnimateMove(gameObject, Vector3.down, transform.position + Vector3.up);
 }
Esempio n. 9
0
 public virtual void MoveTo(Vector3 nextPosition)
 {
     Level.Singleton.Entities.Remove(transform.position);
     CubeAnimations.AnimateMove(gameObject, Vector3.down, nextPosition);
     Level.Singleton.Entities.Add(nextPosition, this);
 }
Esempio n. 10
0
 public void MagneticMoveTo(Vector3 nextPosition, Vector3 floorDirection)
 {
     Level.Singleton.RemoveEntity(transform.position);
     CubeAnimations.AnimateMove(gameObject, floorDirection, nextPosition);
     Level.Singleton.AddEntity(nextPosition, this);
 }