private void CheckIfHoldingUpKey()
    {
        float verticalInput = 0f;
        float holdDur       = 1.2f;

        verticalInput = Input.GetAxisRaw("Vertical");
        if (verticalInput > 0)
        {
            if (!hasTimerStarted)
            {
                timer           = Time.time;
                hasTimerStarted = !hasTimerStarted;
                physicalObject.GetComponent <PlayerState>().IsLookingUp = true;
            }
            else
            {
                if (Time.time - timer > holdDur)
                {
                    timer = float.PositiveInfinity;
                    MoveCameraUp();
                }
            }
        }
        if (verticalInput == 0 && hasTimerStarted)
        {
            hasTimerStarted         = !hasTimerStarted;
            timer                   = float.PositiveInfinity;
            cameraController.target = physicalObject.GetComponent <PhysicalObject>().body.transform;
            physicalObject.GetComponent <PlayerState>().IsLookingUp = false;
        }
    }
    public void EatHeldObject()
    {
        if (heldObject == null)
        {
            return;
        }

        Food heldFood = heldObject.GetComponent <Food>();

        if (heldFood == null)
        {
            return;
        }

        if (heldFood.thisFoodType == food_type.meat && state.eaterType == Eater_type.herbivore)
        {
            return;
        }

        if (heldFood.thisFoodType == food_type.plant && state.eaterType == Eater_type.carnivore)
        {
            return;
        }

        state.fed += (float)heldFood.thisFoodType * 0.1f; // TODO: scale with foodtype and transform scale or other quantity

        Destroy(heldObject.gameObject);
        heldObject = null;
        target     = null;
    }
Beispiel #3
0
 private void Start()
 {
     if (hasStartingObject)
     {
         PhysicalObject newStoredObject = Instantiate(storedObject, transform.position, transform.rotation);
         storedObject.MyRigidbody = storedObject.GetComponent <Rigidbody>();
         newStoredObject.saveVariables.SaveProperty(storedObject.MyRigidbody);
         StoreObject(newStoredObject);
     }
 }
    // Update is called once per frame
    void FixedUpdate()
    {
        // ALL of this is debug
        // TODO: remove
        if (doMoveTowards)
        {
            actionSet.MoveTowards(target.position, moveSpeed);
        }
        if (doJump)
        {
            actionSet.Jump(jumpHeight);
            doJump = false;
        }
        if (doPickupRight)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), rightPickupTarget.GetComponent <Collider>());
            actionSet.PickupObject(rightPickupTarget, rightHand, rightHand.Find("WeaponPos"));
            doPickupRight = false;
        }
        if (doPickupLeft)
        {
            Physics.IgnoreCollision(GetComponent <CapsuleCollider>(), leftPickupTarget.GetComponent <Collider>());
            actionSet.PickupObject(leftPickupTarget, leftHand, leftHand.Find("WeaponPos"));
            doPickupLeft = false;
        }

        /*if (doDrop)
         * {
         *  Vector3 velocity = hand.GetComponent<Rigidbody>().velocity;
         *  actionSet.DropObject(pickupTarget, hand.transform, velocity);
         *  doDrop = false;
         * }*/
        if (doActivateRight)
        {
            actionSet.ActivateObject(rightPickupTarget, rightHand.Find("WeaponPos"));
        }
        if (doActivateLeft)
        {
            actionSet.ActivateObject(leftPickupTarget, leftHand.Find("WeaponPos"));
        }
        if (doAimAtRight)
        {
            rightSlerpPos += 0.2f;
            actionSet.AimAt(rightHand, target.position, rightSlerpPos);
            if (rightSlerpPos > 1)
            {
                rightSlerpPos = 0;
            }
            //doAimAtRight = false;
        }
        if (doAimAtLeft)
        {
            leftSlerpPos += 0.2f;
            actionSet.AimAt(leftHand, target.position, leftSlerpPos);
            if (leftSlerpPos > 1)
            {
                leftSlerpPos = 0;
            }
        }
        if (doCrouch)
        {
            actionSet.Crouch(leg, originalHeight, 0.3f);
            doCrouch = false;
        }
        if (doStandup)
        {
            actionSet.StandUp(leg, originalHeight);
            doStandup = false;
        }
        if (doReload)
        {
            actionSet.ReloadWeapon(rightPickupTarget);
            actionSet.ReloadWeapon(leftPickupTarget);
            doReload = false;
        }
        if (doOrientate)
        {
            actionSet.TurnTowards(target, 1.0f, 2.0f, 7f);
        }
        if (setDestinationWithStrafe)
        {
            setDestinationWithoutStrafe = false;
            setDestinationWithStrafe    = activitySet.GoTowardsDestination(destination.position);
            actionSet.TurnTowards(destination, 1.0f, 2.0f, 7f);
        }
        if (setDestinationWithoutStrafe)
        {
            setDestinationWithStrafe    = false;
            setDestinationWithoutStrafe = activitySet.GoTowardsDestination(destination.position, false);
            //actionSet.TurnTowards(destination, 1.0f, 2.0f, 7f);
        }
        //animator.SetInteger("RoutineStatus", routineStatus);
    }