Esempio n. 1
0
    void dropObject()
    {
        if (gameManager.gameObject.GetComponent <UIFloatingItem> ().FloatingIcons.Contains(objectHeld))
        {
            gameManager.gameObject.GetComponent <UIFloatingItem> ().SetItemVisible(objectHeld, true);
        }
        distance = 0;

        if (objectHeld.transform.childCount > 0)
        {
            objectHeld.layer = LayerMask.NameToLayer("Interact");
            foreach (Transform child in objectHeld.transform)
            {
                if (child.GetComponent <MeshFilter> ())
                {
                    child.gameObject.layer = LayerMask.NameToLayer("Interact");
                }
            }
        }
        else
        {
            objectHeld.layer = LayerMask.NameToLayer("Interact");
        }

        playerCam.cullingMask = DefaultMainCamMask;
        ArmsCam.cullingMask   = DefaultArmsCamMask;

        pfunc.enabled = true;
        gameManager.UIPreventOverlap(false);
        gameManager.HideSprites(spriteType.Examine);
        examinedItem = null;
        examineName  = null;
        isObjectHeld = false;
        isExaminig   = false;
        rotSet       = false;
        isReading    = false;
        paperUI.SetActive(false);
        interact.CrosshairVisible(true);
        gameManager.LockStates(false, true, true, false, 1);
        objectHeld.transform.position = objectPosition;
        objectHeld.transform.rotation = objectRotation;
        if (!isPaper)
        {
            objectHeld.GetComponent <Collider> ().isTrigger    = false;
            objectHeld.GetComponent <Rigidbody> ().isKinematic = false;
            objectHeld.GetComponent <Rigidbody> ().useGravity  = true;
        }
        else
        {
            objectHeld.GetComponent <Rigidbody> ().isKinematic = true;
            objectHeld.GetComponent <Rigidbody> ().useGravity  = false;
        }
        tryExamine      = false;
        objectRaycast   = null;
        objectHeld      = null;
        delay.isEnabled = true;
        GetComponent <ScriptManager>().SetScriptEnabledGlobal = true;
        StartCoroutine(AntiSpam());
    }
Esempio n. 2
0
        public int Add(ExamineItem item)
        {
            var maxId  = repository.GetMaxId("HR_EXAMINEITEMS", "ITEMID");
            var entity = ModelToEntity(item);

            entity.ITEMID     = maxId;
            entity.CREATEDATE = DateTime.Now;
            //entity.CreatorUserId
            repository.Insert(entity);
            return(maxId);
        }
Esempio n. 3
0
 private ExamineItem EntityToModel(HR_EXAMINEITEMS entity)
 {
     if (entity != null)
     {
         var model = new ExamineItem()
         {
             ItemId      = entity.ITEMID,
             ItemCode    = entity.ITEMNO,
             ItemName    = entity.ITEMNAME,
             CodeValue   = entity.CODEVALUE,
             Description = entity.DESCRIPTION,
             ValueType   = entity.VALUETYPE
         };
         return(model);
     }
     return(null);
 }
Esempio n. 4
0
 private HR_EXAMINEITEMS ModelToEntity(ExamineItem model)
 {
     if (model != null)
     {
         var entity = new HR_EXAMINEITEMS()
         {
             ITEMID      = model.ItemId,
             ITEMNO      = model.ItemCode,
             ITEMNAME    = model.ItemName,
             CODEVALUE   = model.CodeValue,
             DESCRIPTION = model.Description,
             VALUETYPE   = model.ValueType
         };
         return(entity);
     }
     return(null);
 }
Esempio n. 5
0
    void Update()
    {
        if (inputManager.HasInputs())
        {
            grabKey    = inputManager.GetInput("Pickup");
            rotateKey  = inputManager.GetInput("Fire");
            examineKey = inputManager.GetInput("Examine");
        }

        //Prevent Interact Dynamic Object when player is holding other object
        otherHeld = GetComponent <DragRigidbody> ().CheckHold();

        if (gameManager.isPaused)
        {
            return;
        }

        if (objectRaycast && !antiSpam && examinedItem)
        {
            if (Input.GetKeyDown(grabKey) && !isPressed && !otherHeld)
            {
                isPressed  = true;
                isExaminig = !isExaminig;
            }
            else if (isPressed)
            {
                isPressed = false;
            }
        }

        if (isExaminig)
        {
            if (!isObjectHeld)
            {
                firstGrab();
                tryExamine = true;
            }
            else
            {
                holdObject();
            }
        }
        else if (isObjectHeld)
        {
            dropObject();
        }

        RaycastHit hit;

        playerAim = playerCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

        if (Physics.Raycast(playerAim, out hit, PickupRange, CullLayers))
        {
            if (hit.collider.gameObject.layer == LayerMask.NameToLayer(InteractLayer))
            {
                if (hit.collider.tag == TagExamine || hit.collider.tag == TagExaminePaper)
                {
                    objectRaycast = hit.collider.gameObject;
                    if (objectRaycast.GetComponent <ExamineItem> ())
                    {
                        examinedItem = objectRaycast.GetComponent <ExamineItem> ();
                    }
                }
                else
                {
                    if (!tryExamine)
                    {
                        objectRaycast = null;
                        examinedItem  = null;
                    }
                }
            }
            else
            {
                if (!tryExamine)
                {
                    objectRaycast = null;
                    examinedItem  = null;
                }
            }
        }
        else
        {
            if (!tryExamine)
            {
                objectRaycast = null;
                examinedItem  = null;
            }
        }

        float rotationInputX = 0.0f;
        float rotationInputY = 0.0f;

        float x = Input.GetAxis("Mouse X");
        float y = Input.GetAxis("Mouse Y");

        if (Mathf.Abs(x) > rotationDeadzone)
        {
            rotationInputX = -(x * rotateSpeed);
        }

        if (Mathf.Abs(y) > rotationDeadzone)
        {
            rotationInputY = (y * rotateSpeed);
        }

        if (objectHeld && isObjectHeld)
        {
            if (Input.GetKey(rotateKey) && !isReading)
            {
                objectHeld.transform.Rotate(playerCam.transform.up, rotationInputX, Space.World);
                objectHeld.transform.Rotate(playerCam.transform.right, rotationInputY, Space.World);
            }

            if (Input.GetKey(examineKey) && !isPaper)
            {
                gameManager.ShowHint(examineName);
            }

            if (isPaper)
            {
                if (Input.GetKeyDown(examineKey) && !isPressedRead)
                {
                    isPressedRead = true;
                    isReading     = !isReading;
                }
                else if (isPressedRead)
                {
                    isPressedRead = false;
                }

                if (isReading)
                {
                    ExamineItem examine = objectRaycast.GetComponent <ExamineItem>();
                    paperText.text     = examine.paperReadText;
                    paperText.fontSize = examine.textSize;
                    paperUI.SetActive(true);
                }
                else
                {
                    paperUI.SetActive(false);
                }
            }
        }
    }
Esempio n. 6
0
    void firstGrab()
    {
        if (objectRaycast.tag == TagExamine || objectRaycast.tag == TagExaminePaper)
        {
            StartCoroutine(AntiSpam());
            objectHeld = objectRaycast.gameObject;
            if (objectRaycast.tag == TagExaminePaper)
            {
                isPaper = true;
            }
            else
            {
                isPaper = false;
            }

            if (!(objectHeld.GetComponent <Rigidbody>()))
            {
                Debug.LogError(objectHeld.name + " need Rigidbody Component to pickup");
                return;
            }

            if (objectHeld.GetComponent <ExamineItem> ())
            {
                examinedItem = objectHeld.GetComponent <ExamineItem> ();
                distance     = examinedItem.examineDistance;
                examineName  = examinedItem.examineObjectName;
                if (examinedItem.examineSound)
                {
                    AudioSource.PlayClipAtPoint(examinedItem.examineSound, objectRaycast.transform.position, 0.75f);
                }
            }

            if (!isObjectHeld)
            {
                objectPosition = objectHeld.transform.position;
                objectRotation = objectHeld.transform.rotation;
                objectHeld.GetComponent <Collider> ().isTrigger = true;
            }

            if (gameManager.gameObject.GetComponent <UIFloatingItem> ().FloatingIcons.Contains(objectHeld))
            {
                gameManager.gameObject.GetComponent <UIFloatingItem> ().SetItemVisible(objectHeld, false);
            }

            if (objectHeld.transform.childCount > 0)
            {
                objectHeld.layer = LayerMask.NameToLayer("Examine");
                foreach (Transform child in objectHeld.transform)
                {
                    if (child.GetComponent <MeshFilter> ())
                    {
                        child.gameObject.layer = LayerMask.NameToLayer("Examine");
                    }
                }
            }
            else
            {
                objectHeld.layer = LayerMask.NameToLayer("Examine");
            }

            playerCam.cullingMask = ExamineMainCamMask;
            ArmsCam.cullingMask   = ExamineArmsCamMask;

            delay.isEnabled = false;
            pfunc.enabled   = false;
            gameManager.UIPreventOverlap(true);
            gameManager.ShowExamineSprites(grabKey.ToString(), examineKey.ToString());
            gameManager.HideSprites(spriteType.Interact);
            GetComponent <ScriptManager>().SetScriptEnabledGlobal = false;

            Physics.IgnoreCollision(objectRaycast.GetComponent <Collider>(), transform.root.GetComponent <Collider>(), true);

            isObjectHeld = true;
        }
    }
Esempio n. 7
0
 void Awake()
 {
     me = this;
 }
Esempio n. 8
0
        public bool Edit(ExamineItem item)
        {
            var entity = ModelToEntity(item);

            return(entity != null && repository.Update(entity));
        }