Exemplo n.º 1
0
   void Start()
   {
      _poManagerState = PoManagerState.Normal;
      _shakingTimeLeft = PoBehaviour.PreRocketWarmUpTime;

      // Listen to global approve reject events, which we'll filter to make sure it's only the
      // one that applies to this PO
      GameManager.Instance.OnSinglePOApproved += OnSinglePOApproved;
      GameManager.Instance.OnSinglePORejected += OnSinglePORejected;

      // Highlighting - start stop movement when highlighted
      _scriptIsHighlightable = GetComponent<Highlight_IsHighlightable>();
      if (_scriptIsHighlightable != null)
      {
         _scriptIsHighlightable.OnHighlighted += OnHighlighted;
         _scriptIsHighlightable.OnUnhighlighted += OnUnhighlighted;
      }

      // Po GUI to display PO details
      _poGui = GetComponent<PoGui>();
      _poGui.enabled = false; // always start switched off

      // Game Gui, to tell it when we approve/reject
      GameObject go = GameObject.Find("GameGui");
      if (go != null)
      {
         _gameGui = go.GetComponent<GameGui>();
      }

      // Movement - get reference
      _poMover = GetComponent<PoMover>();

      // Delete mover for static POs
      if (_poMover != null && PoBehaviour.movementType == EpmPoMovementType.Static)
      {
         Component.Destroy(_poMover);
      }
   }
Exemplo n.º 2
0
   private void OnSinglePORejected(object sender, PoApprovedEventArgs e)
   {
      if (e.PurchaseOrderId == this.PoBusinessDataWithItems.PurchaseOrderId)
      {
         // It's us! 
         _poManagerState = PoManagerState.BusyChangingStateRejected;
         // Visuals and audio are done in PoSfx, which listens to this event
         OnThisPORejected(null, null);

         // Hide self
         GetComponent<Renderer>().enabled = false;
         GetComponent<Collider>().enabled = false;

         // Self destruct
         Destroy(this.gameObject, 5f); // delay needed to allow audio and explosion particles to finish

         // Create smoke gameobject as separate gameobject in the PO bucket folder
         // This gameobject PoToDisplayWhenDead prefab could have some models too
         GameObject gParent = GameObject.FindWithTag("PoBucket");
         Vector3 spawnPosition = this.transform.position; 
         Quaternion spawnRotation = this.transform.rotation; 
         GameObject g = (GameObject)Instantiate(PoToDisplayWhenDead, spawnPosition, spawnRotation);
         g.transform.parent = gParent.transform;
      
         // Tell Gui
         if (_gameGui != null)
         {
            _gameGui.PoRejected();
         }
      }
   }
Exemplo n.º 3
0
   // Update is called once per frame
   void Update()
   {
      switch (_poManagerState)
      {
         case PoManagerState.Normal:
            if (_poGui.enabled)
            {
               if (Input.GetButtonUp("Approve"))
               {
                  GameManager.Instance.GetEpmData_ApprovePO(PoBusinessDataWithItems.PurchaseOrderId);
                  _poManagerState = PoManagerState.BusyRequestingApproved;
               }
               
               if (Input.GetButtonUp("Reject"))
               {
                  GameManager.Instance.GetEpmData_RejectPO(PoBusinessDataWithItems.PurchaseOrderId);
                  _poManagerState = PoManagerState.BusyRequestingRejected;                  
               }
            }
            break;

         default:
            break;
      }
   }
Exemplo n.º 4
0
   private void OnSinglePOApproved(object sender, PoApprovedEventArgs e)
   {
      if (e.PurchaseOrderId == this.PoBusinessDataWithItems.PurchaseOrderId)
      {
         // It's us!  Changing this state triggers the shaking effect, which itself is applied in FixedUpdate()
         _poManagerState = PoManagerState.BusyChangingStateApproved;
         // Visuals and audio for the immediate act of approval are done in PoSfx, which listens to this event
         OnThisPOApproved(null, null);
      
         // Stop any other movement
         if (_poMover != null)
         {
            Component.Destroy(_poMover);
         }

         // Set rocket attachment
         Invoke("AttachRocket", PoBehaviour.PreRocketWarmUpTime);
         Invoke("UpdateApprovedPoScore", 4);

         // Self destruct
         // TODO add a destructor if object outside game world box
         Destroy(this.gameObject, 10f);
      }
   }