Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / Puzzles / BoxScript.cs
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BoxScript : MonoBehaviour
  5. {
  6. public Vector3 originalPos;
  7. public float timer;
  8. private Rigidbody rb;
  9. public bool condition;
  10. private PlayerController playerController;
  11. private BoxCollider bc;
  12. public Color color;
  13. public int boxNumber;
  14. public bool useColor;
  15. private Material mat;
  16. void Start()
  17. {
  18. originalPos = transform.position;
  19. rb = GetComponent<Rigidbody>();
  20. playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
  21. bc = GetComponent<BoxCollider>();
  22. mat = GetComponent<Renderer>().material;
  23. }
  24. public void CheckPos()
  25. {
  26. originalPos = transform.position;
  27. }
  28. private void Update()
  29. {
  30. /*if (timer > 0) { timer -= Time.deltaTime; rb.useGravity = false; }
  31. else rb.useGravity = true;*/
  32. }
  33. public void Manipulation (bool condition)
  34. {
  35. this.condition = condition;
  36. if (this.condition)
  37. {
  38. rb.useGravity = false;
  39. transform.position = new Vector3(transform.position.x, originalPos.y + 0.5f, transform.position.z);
  40. mat.SetFloat("_Intensity",0.45f);
  41. }
  42. else
  43. {
  44. rb.useGravity = true;
  45. mat.SetFloat("_Intensity", 0f);
  46. }
  47. }
  48. }