Ejemplo n.º 1
0
        public void OnPickup()
        {
            SeamothArmManager control      = ThisSeamoth.GetComponent <SeamothArmManager>();
            GameObject        activeTarget = control.GetActiveTarget();

            if (activeTarget)
            {
                Pickupable pickupable = activeTarget.GetComponent <Pickupable>();
                PickPrefab component  = activeTarget.GetComponent <PickPrefab>();

                ItemsContainer container = control.GetRoomForItem(pickupable);

                if (pickupable != null && pickupable.isPickupable && container != null)
                {
                    pickupable = pickupable.Initialize();
                    InventoryItem item = new InventoryItem(pickupable);
                    container.UnsafeAdd(item);
                    Utils.PlayFMODAsset(pickupSound, front, 5f);
                }
                else if (component != null && component.AddToContainer(container))
                {
                    component.SetPickedUp();
                }
            }
        }
Ejemplo n.º 2
0
        private bool TryUse(out float cooldownDuration)
        {
            if (Time.time - timeUsed >= cooldownTime)
            {
                SeamothArmManager control = ThisSeamoth.GetComponent <SeamothArmManager>();

                Pickupable pickupable = null;
                PickPrefab x          = null;

                GameObject activeTarget = control.GetActiveTarget();

                if (activeTarget)
                {
                    pickupable = activeTarget.GetComponent <Pickupable>();
                    x          = activeTarget.GetComponent <PickPrefab>();
                }
                if (pickupable != null && pickupable.isPickupable)
                {
                    if (control.GetRoomForItem(pickupable) != null)
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime            = (cooldownDuration = cooldownPickup);
                        shownNoRoomNotification = false;
                        return(true);
                    }
                    if (!shownNoRoomNotification)
                    {
                        ErrorMessage.AddMessage(Language.main.Get("ContainerCantFit"));
                        shownNoRoomNotification = true;
                    }
                }
                else
                {
                    if (x != null)
                    {
                        animator.SetTrigger("use_tool");
                        cooldownTime = (cooldownDuration = cooldownPickup);
                        return(true);
                    }
                    animator.SetTrigger("bash");
                    cooldownTime = (cooldownDuration = cooldownPunch);
                    fxControl.Play(0);
                    return(true);
                }
            }
            cooldownDuration = 0f;
            return(false);
        }
Ejemplo n.º 3
0
        public void FixedUpdate()
        {
            if (hook.attached)
            {
                grapplingLoopSound.Play();

                Vector3 value     = hook.transform.position - front.position;
                Vector3 a         = Vector3.Normalize(value);
                float   magnitude = value.magnitude;

                if (magnitude > 1f)
                {
                    if (!IsUnderwater() && ThisSeamoth.transform.position.y + 0.2f >= grapplingStartPos.y)
                    {
                        a.y = Mathf.Min(a.y, 0f);
                    }

                    ThisSeamoth.GetComponent <Rigidbody>().AddForce(a * seamothGrapplingAccel, ForceMode.Acceleration);
                    hook.GetComponent <Rigidbody>().AddForce(-a * 400f, ForceMode.Force);
                }

                rope.SetIsHooked();
            }
            else if (hook.flying)
            {
                if ((hook.transform.position - front.position).magnitude > maxDistance)
                {
                    ResetHook();
                }
                grapplingLoopSound.Play();
            }
            else
            {
                grapplingLoopSound.Stop();
            }
        }
Ejemplo n.º 4
0
 private void Start()
 {
     worldForces = ThisSeamoth.GetComponent <WorldForces>();
 }