void Awake() { _physics = GetComponent <PhysicsController2D>(); _stats = GetComponent <ControllableStats>(); _canTakeInput = GetComponent <CanTakeInput>(); _energy = GetComponent <HasEnergy>(); _followText = GetComponent <FollowText>(); _gun = GetComponent <UnconventionalGun>(); }
private void SpawnACube(Choice c, TMP_Text label) { // Instantiate cube GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); // Adds a label and makes it follow it if (label != null) { Debug.Log("GOOD: Cube is valid"); FollowText followText = cube.AddComponent <FollowText>(); followText.SetLabel(label); followText.SetText(c.title); } else { Debug.Log("FATAL: No good/bad label prefab!"); } cube.AddComponent <ChoiceContainer>().choice = c; cube.GetComponent <ChoiceContainer>().parent = cube; cube.AddComponent <Rigidbody>(); cube.AddComponent <MettalicThudCollisionSound>(); // Set texture cube.GetComponent <Renderer>().material.mainTexture = c.image; // Make it draggable Draggable d = cube.AddComponent <Draggable>(); // Set title info d.onClick = () => { if (infoText != null) { //infoText.text = c.title; } }; // Rotate it Quaternion q = cube.transform.rotation; //shows the image properly q.z = 180; cube.transform.rotation = q; // Set to position cube.transform.position = GetRandomSpawnPoint(); // Scales the cube to be a little bit smaller cube.transform.localScale = new Vector3(0.90f, 0.90f, 0.90f); }