Example #1
0
    public override void MoveToNext(float timetomove)
    {
        //Debug.Log(GetHashCode() + " is MoveToNext " + AttachedSnakePart.GetHashCode());
        tile.Remove(this);
        Tile newtile = AttachedSnakePart.tile;

        RotateObject(Quaternion.LookRotation(newtile.position - transform.position), 90.0f);
        //MoveObject(transform.position, newtile.position,timetomove);
        MoveObject(tile.position, newtile.position, timetomove);

        //MoveObject(transform.position, AttachedSnakePart.transform.position,timetomove);
        //newtile.interract(this);

        newtile.AddObject(this, false);
        newtile.interractOneToMany(this);
        //MoveObject(tile.position, AttachedSnakePart.transform.position,timetomove);

        //transform.rotation = Quaternion.LookRotation(newtile.position - transform.position);
        AttachedSnakePart.MoveToNext(timetomove);
    }
Example #2
0
    public void Move()
    {
        if (!direction.Equals(Direction.idle) && !IsDead)
        {
            //Debug.Log("move");
            MoveTimer = 0;
            //LastSnakePart.MoveToNext();
            Tile newtile = tile.GetTile(direction);
            //RotateObject(Quaternion.LookRotation(newtile.position - tile.position),150.0f);
            if (newtile != null)
            {
                tile.Remove(this);
                newtile.interractOneToMany(this);
                newtile.InterractManyToOne(this);

                /*
                 * foreach (var ob in newtile.objectsOnTile)
                 * {
                 *      Interract(ob);
                 * }
                 */

                MoveObject(tile.position, newtile.position, TimeToMove);

                //OnMoved?.Invoke(TimeToMove);
                LastSnakePart.MoveToNext(TimeToMove);
                newtile.AddObject(this, false);

                newtile.level.SetColoredTile(newtile.cord.column, newtile.cord.row);

                GameManager.instanse.Iteration?.Invoke();
            }
            else
            {
                Debug.Log("level does not contain tile " + tile.level.GetHashCode());
            }
        }
    }