Example #1
0
 public void setPicture(GamePictureInfo gpi)
 {
     gamePictureInfo = gpi;
     id = gpi.Id;
     setPicture(gpi.Img);
     activate();
 }
Example #2
0
 public void setTrueColorTo(GamePictureInfo gpi)
 {
     foreach (GamePicture gp in gamePictures)
     {
         if (gp.GamePictureInfo == gpi)
         {
             gp.setTrueColor();
         }
     }
 }
Example #3
0
 public void setFrom(GamePictureInfo gpi)
 {
     setPicture(gpi.Img);
     setRotation(gpi.Angle);
     setSize(gpi.Size);
     setTargetPosition(gpi.Position);
     setFlipX(gpi.FlipX);
     setFlipY(gpi.FlipY);
     gamePictureInfo = gpi;
     activate();
 }
Example #4
0
    private void setPicture(GamePictureInfo pi, int index)
    {
        pictures [index].enabled = true;
        Sprite s = Sprite.Create(pi.Img, new Rect(0, 0, pi.Img.width, pi.Img.height), new Vector2(0.5f, 0.5f),
                                 (pi.Img.width / sizeUnitsPicture > pi.Img.height / sizeUnitsPicture ? pi.Img.width / sizeUnitsPicture : pi.Img.height / sizeUnitsPicture));

        pictures [index].overrideSprite          = s;
        pictures [index].transform.localPosition = new Vector3(pi.Position.x * sizeUnitsPicture / trueIconSize, pi.Position.y * sizeUnitsPicture / trueIconSize, 0);
        pictures [index].transform.localScale    = new Vector3(pi.Size * (pi.FlipX ? -1 : 1), pi.Size * (pi.FlipY ? -1 : 1), 1);       //В Image нет флипов, поэтому приходится импровизировать
        pictures [index].transform.localRotation = new Quaternion(0, 0, pi.Angle, 1);
    }
Example #5
0
 public bool addGamePicture(GamePictureInfo gpi)
 {
     for (int i = 0; i < PICTURES_SIZE; i++)
     {
         if (gamePictures [i] == null)
         {
             gamePictures [i] = gpi;
             return(true);
         }
     }
     return(false);
 }
Example #6
0
 public static GamePictureInfo[] loadPictures(IDbCommand dbcmd, int taskId)
 {
     dbcmd.CommandText = SELECT_PICTURES.Replace("{task_id}", "" + taskId);
     using (IDataReader reader = dbcmd.ExecuteReader()) {
         GamePictureInfo[] gpis = new GamePictureInfo[Task.PICTURES_SIZE];
         for (int i = 0; i < Task.PICTURES_SIZE && reader.Read(); i++)
         {
             byte[]    buf      = (byte[])reader ["img"];
             Texture2D tex      = loadImg(buf);
             Vector2   position = new Vector2((float)reader ["x"], (float)reader ["y"]);
             float     size     = (float)reader ["size"];
             float     angle    = (float)reader ["angle"];
             bool      flipX    = reader ["flip_x"].ToString() == "1";
             bool      flipY    = reader ["flip_y"].ToString() == "1";
             gpis [i] = new GamePictureInfo(int.Parse(reader.GetValue(0).ToString()), int.Parse(reader.GetValue(1).ToString()), tex, position, size, angle, flipX, flipY);
         }
         return(gpis);
     }
     return(null);
 }
Example #7
0
    /*
     * public GamePicture createPicture (string url, Vector3 position, float size, float angle, bool flipX = false, bool flipY = false, bool shadow = true) {
     *      GamePicture gp = Instantiate (gamePicturePrefab, position, transform.rotation, transform) as GamePicture;
     *      gamePictures.Add (gp);
     *      gp.setPicture (url);
     *      gp.setSize (size);
     *      gp.setRotation (angle);
     *      gp.setFlipX (flipX);
     *      gp.setFlipY (flipY);
     *      if (shadow)
     *              gp.setSpriteColor (pictureShadowColor);
     *      return gp;
     * }*/

    public GamePicture createPicture(GamePictureInfo gpi, int type = 2)
    {
        GamePicture gp = Instantiate(gamePicturePrefab, new Vector3(gpi.Position.x, gpi.Position.y, -1f), transform.rotation, transform) as GamePicture;

        gp.transform.localPosition = new Vector3(gpi.Position.x, gpi.Position.y, -1);
        gamePictures.Add(gp);
        gp.setPicture(gpi);
        gp.setSize(gpi.Size);
        gp.setRotation(gpi.Angle);
        gp.setFlipX(gpi.FlipX);
        gp.setFlipY(gpi.FlipY);
        if (type == 1)
        {
            gp.setSpriteColor(pictureShadowColor);
        }
        else if (type == 0)
        {
            gp.setSpriteColor(pictureHalfColor);
        }
        gp.activate(false);
        return(gp);
    }
Example #8
0
    /*
     * public void initiatePicture(string path){
     *      if (setPicture (path))
     *              activate ();
     * }*/

    /*
     * public bool setPicture (string path) {
     *      Texture2D newTex = FileWorker.readImage (path);
     *      if (newTex != null) {
     *              url = path;
     *              setPicture (newTex);
     *              return true;
     *      }
     *      return false;
     * }*/

    public void setPicture(ImageData imgData)
    {
        gamePictureInfo = new GamePictureInfo(-1, imgData.Id, imgData.Texture, new Vector2());
        setPicture(imgData.Texture);
        activate();
    }
 public bool equals(GamePictureInfo other)
 {
     return(pictureId == other.pictureId && size == other.size && angle == other.angle && flipX == other.flipX && flipY == other.flipY);
 }
Example #10
0
 private static void addPictureToTask(IDbCommand dbcmd, int taskId, GamePictureInfo gpi)
 {
     dbcmd.CommandText = INSERT_GAME_PICTURE.Replace("{picture_id}", "" + gpi.PictureId).Replace("{size}", "" + gpi.Size).Replace("{angle}", "" + gpi.Angle)
                         .Replace("{x}", "" + gpi.Position.x).Replace("{y}", "" + gpi.Position.y).Replace("{flip_x}", "" + gpi.FlipX_int).Replace("{flip_y}", "" + gpi.FlipY_int).Replace("{task_id}", "" + taskId);
     dbcmd.ExecuteNonQuery();
 }