상속: MonoBehaviour
예제 #1
0
    public override Sprite Pick(int x, int y)
    {
        Color        c  = painter.Render(x, y);
        SpritePicker sp = map.ContainsKey(c)?map[c]:theme[0].spritePicker;

        return(sp.Pick(x, y));
    }
예제 #2
0
 void Start()
 {
     box            = this.GetComponent <BoxCollider2D>();
     circle         = this.GetComponent <CircleCollider2D>();
     picker         = this.GetComponent <SpritePicker>();
     animator       = this.GetComponent <Animator>();
     render         = this.GetComponent <SpriteRenderer>();
     player         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     player.OnDash += Change;
     if (box.enabled == false)
     {
         circle.enabled          = false;
         this.gameObject.layer   = 2;
         render.sortingLayerName = "HighBackground";
         isReal = false;
     }
     else
     {
         circle.enabled          = true;
         this.gameObject.layer   = 0;
         render.sortingLayerName = "Foreground";
         isReal = true;
     }
 }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        BetterStreamingAssets.Initialize();

        string[] paths2 = BetterStreamingAssets.GetFiles("new_trash", "*.png", SearchOption.AllDirectories);



        /*
         * DirectoryInfo dir = new DirectoryInfo(Application.streamingAssetsPath);
         * Debug.Log("Path do tergo to " + Application.streamingAssetsPath);
         *
         * FileInfo[] info = dir.GetFiles("*.*");
         *
         *
         *
         *
         * int counter = 0;
         * int amount = 0;
         *
         *
         *
         *
         * foreach (FileInfo f in info) {
         *  amount++;
         * }
         *
         *
         *
         * arr = new String[amount/2];
         *
         * foreach (FileInfo f in info)
         * {
         *
         *
         *  string nazwa = f.ToString();
         *  Debug.LogWarning("f.Tostring() = " + nazwa);
         *  char last = nazwa[nazwa.Length - 1];
         *
         *  if (nazwa.Contains("meta") == false)
         *  {
         *
         *      Debug.LogWarning("Przed Splitowaniem");
         *      string[] words = nazwa.Split('\\');
         *
         *      foreach (var word in words)
         *      {
         *          Debug.LogWarning("Przed sprawdzeniem czy zawiera człon PNG");
         *          if (word.Contains("png") == true)
         *          {
         *              string wordexact = word.Replace(".png", string.Empty);
         *
         *              arr[counter] = wordexact;
         *              counter = counter + 1;
         *              Debug.LogWarning("Slowo dodane do listy.");
         *
         *          }
         *
         *      }
         *
         *
         *  }
         *
         * }/// wszystkie nazwy w stringu arrs */



        gm = GameObject.FindGameObjectWithTag("GameController");
        sp = gm.GetComponent <SpritePicker>();



        int r = UnityEngine.Random.Range(0, paths2.Length);

        Debug.Log(r);

        string ok = paths2[r];

        ok = ok.Remove(0, 10);
        ok = ok.Replace(".png", string.Empty);

        Debug.Log(ok);


        this.name = ok;
        var sprite_res = Resources.Load <Sprite>("NewTrashToSpawn/" + ok);

        this.GetComponent <SpriteRenderer>().sprite = sprite_res;
    }