GamePiece.cs 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. namespace Oculus.Platform.Samples.VrBoardGame
  2. {
  3. using UnityEngine;
  4. using System.Collections;
  5. public class GamePiece : MonoBehaviour
  6. {
  7. [SerializeField] private Piece m_type = Piece.A;
  8. // Prefab for the game pieces
  9. [SerializeField] private GameObject m_prefabA = null;
  10. [SerializeField] private GameObject m_prefabB = null;
  11. [SerializeField] private GameObject m_prefabPower = null;
  12. public enum Piece { A, B, PowerBall }
  13. private BoardPosition m_position;
  14. public Piece Type
  15. {
  16. get { return m_type; }
  17. }
  18. public BoardPosition Position
  19. {
  20. get { return m_position; }
  21. set { m_position = value; }
  22. }
  23. public GameObject Prefab
  24. {
  25. get
  26. {
  27. switch (m_type)
  28. {
  29. case Piece.A: return m_prefabA;
  30. case Piece.B: return m_prefabB;
  31. default: return m_prefabPower;
  32. }
  33. }
  34. }
  35. public GameObject PrefabFor(Piece p)
  36. {
  37. switch (p)
  38. {
  39. case Piece.A: return m_prefabA;
  40. case Piece.B: return m_prefabB;
  41. default: return m_prefabPower;
  42. }
  43. }
  44. }
  45. }