Example #1
0
    private void SetThoughSprite(GameObject item, EThought thought)
    {
        Sprite thoughtSprite = Resources.Load(thought.ToString("f"), typeof(Sprite)) as Sprite;

        Debug.Log(thoughtSprite);
        SpriteRenderer sprite = item.GetComponent <SpriteRenderer>();

        sprite.sprite = thoughtSprite;
    }
 private void CheckDesiredThoughtMatch(EThought thought)
 {
     if (requiredThoughts.Contains(thought))
     {
         gm.GetComponent <BudgetManager>().AddFunds(100);
         points += 100;
         Debug.Log("löyty!");
     }
     else
     {
         gm.GetComponent <BudgetManager>().AddFunds(-200);
         points -= 100;
         Debug.Log("ei löytyny!");
     }
 }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     type = (EThought)Random.Range(1, 6);
     SetThoughSprite(gameObject, type);
     thoughtControlEnabled = false;
     velx         = Random.Range(-5.0f, 5.0f);
     vely         = Random.Range(-5.0f, 5.0f);
     screenBounds = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
     screenOrigo  = Camera.main.ScreenToWorldPoint(Vector2.zero);
     col2D        = GetComponent <BoxCollider2D>();
     gmToolScript = GameObject.FindGameObjectWithTag("GameManager")?.GetComponent <ToolSelection>();;
     if (gmToolScript)
     {
         gmToolScript.AnnounceToolChanged += GmToolScript_AnnounceToolChanged;;
     }
     else
     {
         Debug.LogWarning("ThoughtController could not find GameManager's ToolSelection script!");
     }
 }
    void Start()
    {
        gm = GameObject.FindWithTag("GameManager");
        int thoughtCount = UnityEngine.Random.Range(1, 4);
        int i            = 0;

        while (i < thoughtCount)
        {
            t = (EThought)UnityEngine.Random.Range(1, Enum.GetValues(typeof(EThought)).Length);
            if (!requiredThoughts.Contains(t))
            {
                requiredThoughts.Add(t);
            }
            else
            {
                continue;
            }
            item = transform.Find("Item" + i).gameObject;
            SetDesiredThoughSprite(item, t);
            i++;
        }
    }