示例#1
0
 public void PickupObject(GameObject objectToPickup)
 {
     heldGameObject = objectToPickup;
     if (heldGameObject.GetComponent <ObjectState>().currentState == ObjectState.ObjectStates.Holstered)
     {
         // begin reloading a new gun in holster
         heldGameObject.GetComponentInParent <g_HolsterScript>().BeginRefresh();
     }
     heldGameObject.GetComponent <ObjectState>().PickupObject();
     //make our object's gameobject a child of our hand's mesh
     heldGameObject.transform.parent = TransformDeepChildExtension.FindDeepChild(transform, "Mesh");
     for (int i = 0; i < Objects.Count; i++)
     {
         //go through our list of possible types of objects and find the one that
         //we currently have
         if (heldGameObject.GetComponent <ObjectState>().ID == Objects[i].ObjectID)
         {
             currentObject = Objects[i];
             PlaySound(currentObject.pickupSound);
         }
     }
     //make the rigidbody kinematic so the gun doesn't fall down
     heldGameObject.GetComponent <Rigidbody>().isKinematic = true;
     handState = HandStates.Wielding;
 }
示例#2
0
 public void DropObject()
 {
     //if we currently have something
     if (handState == HandStates.Wielding && heldGameObject != null)
     {
         heldGameObject.transform.parent = null;
         heldGameObject.GetComponent <Rigidbody>().isKinematic = false;
         currentObject.ObjectName = "";
         //throw the object based on our body and hand's current velocity
         Vector3 throwVector;
         throwVector = Quaternion.Euler(0, transform.eulerAngles.y, 0) * (GetComponent <MotionController>().GetVelocity() + transform.root.GetComponent <Rigidbody>().velocity);
         heldGameObject.GetComponent <G_ThrowObject>().Throw(throwVector);
         heldGameObject.GetComponent <ObjectState>().currentState = ObjectState.ObjectStates.Free;
         heldGameObject = null;
         handState      = HandStates.Empty;
     }
 }
示例#3
0
        public override void SelectHandState()
        {
            Console.WriteLine(this.name + "... Please type '" + HandStates[0] + "' , '" + HandStates[1] + "' , '" + HandStates[2] + "' , '" + HandStates[3] + "' , '" + HandStates[4] + "'");
            string choice = Console.ReadLine();

            choice = choice.ToLower();


            while (HandStates.Contains(choice) != true)
            {
                Console.WriteLine(choice + " is NOT a valid move!");
                Console.WriteLine(this.name + "... Please type '" + HandStates[0] + "' , '" + HandStates[1] + "' , '" + HandStates[2] + "' , '" + HandStates[3] + "' , '" + HandStates[4] + "'");
                choice = Console.ReadLine();
            }

            SetGesture(choice);
        }
    private void AttackCheck()
    {
        switch (currentAttackState)
        {
        case HandStates.Spoon:
            if (currentAttackState != lastAttackState)
            {
                lastAttackState = currentAttackState;
            }



            if (!refrences.ShoulderAnimator.GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
            {
                spoonCollider.enabled = false;
                if (Input.mouseScrollDelta.y != 0f)
                {
                    currentAttackState = HandStates.Transition;
                    nextAttackState    = HandStates.Flashlight;
                }
            }
            if (Input.GetMouseButtonDown(0))
            {
                refrences.ShoulderAnimator.SetTrigger("Attacking");
                spoonAnimator.SetTrigger("Attacking");
                spoonCollider.enabled = true;
            }


            break;


        case HandStates.Flashlight:
            if (currentAttackState != lastAttackState)
            {
                refrences.Flashlight.SetActive(true);


                lastAttackState = currentAttackState;
            }
            if (currentFlashlightChargeTime > 0f)
            {
                if (Input.GetMouseButton(0) && !flashlightOn)
                {
                    flashlightOn          = true;
                    timeSinceFlashlightOn = Time.timeSinceLevelLoad;
                }
                else if (Input.GetMouseButton(0))
                {
                    flashlightOn = true;
                }
                else if (flashlightOn && Time.timeSinceLevelLoad >= timeSinceFlashlightOn + minFlashlightOnTime)
                {
                    flashlightOn = false;
                }
            }
            else
            {
                flashlightOn = false;
            }
            if (flashlightOn)
            {
                currentFlashlightChargeTime = Mathf.Max(currentFlashlightChargeTime - Time.deltaTime, 0f);
            }
            refrences.lightconeSprite.material.SetFloat("BatteryLife", currentFlashlightChargeTime / maxFlashlightChargeTime);
            refrences.lightCone.SetActive(flashlightOn);
            shoulderDegree += Input.GetAxisRaw("Mouse Y") * MouseSensetivity * Time.deltaTime;
            shoulderDegree  = Mathf.Clamp(shoulderDegree, ShoulderMinDegree, ShoulderMaxDegree);
            refrences.ShoulderTransform.localRotation = Quaternion.Euler(refrences.ShoulderTransform.localRotation.eulerAngles.x, refrences.ShoulderTransform.localRotation.eulerAngles.y, shoulderDegree);


            if (Input.mouseScrollDelta.y != 0f)
            {
                currentAttackState = HandStates.Transition;
                nextAttackState    = HandStates.Spoon;
                flashlightOn       = false;
            }
            break;


        case HandStates.Transition:
            if (currentAttackState != lastAttackState)
            {
                if (lastAttackState == HandStates.Flashlight)
                {
                    refrences.Flashlight.SetActive(false);
                    refrences.ShoulderTransform.localRotation = Quaternion.Euler(0f, 0f, 14.114f);
                }

                lastAttackState = currentAttackState;
            }
            spoonEffectTime = Mathf.Clamp(spoonEffectTime + (nextAttackState == HandStates.Spoon ? Time.deltaTime / spoonTransitionTime : -Time.deltaTime / spoonTransitionTime), 0f, 1f);
            spoonRenderer.material.SetFloat("SpoonEffectTime", spoonEffectTime);

            if (spoonEffectTime == 1f || spoonEffectTime == 0f)
            {
                currentAttackState = nextAttackState;
            }
            break;

        case HandStates.None:
            break;
        }
    }