Example #1
0
    // Use this for initialization
    void Start()
    {
        holdTimer = holdDelay;


        currentHoldState = HoldState.notHoldingItem;
    }
Example #2
0
    void FixedUpdate()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        CharacterController controller = player.GetComponent<CharacterController>();

        if(holdState == HoldState.Free)
        {

            if(Input.GetButton("Fire1"))
            {
                RaycastHit hit;
                Vector3 p1 = transform.position + controller.center;

                if (Physics.SphereCast (p1, controller.height / 2, transform.forward, out hit, 20)) {
                    //var distanceToObstacle = hit.distance;

                    // if(Physics.SphereCast(transform.position, transform.forward, hit, catchRange, layerMask))
                    //{

                    if(hit.rigidbody)
                    {
                        rigid = hit.rigidbody;
                        rigid.useGravity = false;
                        rigid.isKinematic = false;
                        holdState = HoldState.Catch;
                    }
                }
            }
        }

        else if(holdState == HoldState.Catch)
        {
            rigid.MovePosition(transform.position + transform.forward * holdDistance);
            if(!Input.GetButton("Fire1"))
                holdState = HoldState.Occupied;
        }

        else if(holdState == HoldState.Occupied)
        {
            rigid.MovePosition(transform.position + transform.forward * holdDistance);
            rigid.isKinematic = true;
            if(Input.GetButton("Fire1"))
                holdState = HoldState.Charge;
        }

        else if(holdState == HoldState.Charge)
        {
            rigid.MovePosition(transform.position + transform.forward * holdDistance);

            if(!Input.GetButton("Fire1"))
                holdState = HoldState.Release;
        }

        else if(holdState == HoldState.Release)
        {
            rigid.useGravity = true;
            rigid.isKinematic = false;
            holdState = HoldState.Free;
        }
    }
 public void setItem(string item)
 {
     if (item == "w")
     {
         heldItem      = HoldState.WATER;
         weapon.sprite = sprites[0];
         weapon.GetComponent <Weapon>().weapon = 1;
     }
     if (item == "e")
     {
         heldItem = HoldState.EMPTY;
     }
     if (item == "k")
     {
         heldItem      = HoldState.KNIFE;
         weapon.sprite = sprites[1];
         weapon.GetComponent <Weapon>().weapon = 2;
     }
     if (item == "s")
     {
         heldItem      = HoldState.STAKE;
         weapon.sprite = sprites[2];
         weapon.GetComponent <Weapon>().weapon = 3;
     }
 }
Example #4
0
    public virtual void Shoot()
    {
        holdState   = HoldState.CanHold;
        playerState = PlayerState.None;

        holdMovableTransform.gameObject.tag = "ThrownMovable";

        MovableScript movableScript = holdMovableTransform.gameObject.GetComponent <MovableScript>();

        movableScript.slowMoTrigger.triggerEnabled = true;

        movableScript.hold = false;
        holdMovableTransform.transform.SetParent(null);
        holdMovableTransform.transform.SetParent(movableParent);
        movableScript.playerThatThrew = gameObject;
        movableScript.AddRigidbody();
        holdMovableRB = movableScript.rigidbodyMovable;
        movableScript.OnRelease();


        movableScript.currentVelocity = 250;
        holdMovableRB.AddForce(transform.forward * shootForce, ForceMode.VelocityChange);

        playerRigidbody.AddForce(transform.forward * -holdMovableRB.mass * 5, ForceMode.VelocityChange);

        if (OnShoot != null)
        {
            OnShoot();
        }
    }
Example #5
0
        public void Deserialize(string state)
        {
            List <string> tokens = StringConverter.DeserializeTokens(state);

            this.State    = (HoldState)int.Parse(tokens[0]);
            this.Duration = int.Parse(tokens[1]);
        }
Example #6
0
    /// <summary>
    /// 触れている剛体オブジェクトを掴む.
    /// オブジェクトを掴むことに成功した場合はtrueを返す.
    /// 触れているオブジェクトがない場合や,すでにオブジェクトを掴んでいる場合はなにもせずにfalseを返す.
    /// </summary>
    /// <returns>
    /// true: 成功
    /// false: 失敗
    /// </returns>
    public bool HoldObject()
    {
        if (holdingObject != null || collidingObject == null)
        {
            return(false);
        }

        holdingObject = collidingObject;

        HoldState hs = GetHoldState();

        hs.OnHoldObject();

        model.Clear();
        model.SpringK         = UnitySpringK;
        model.DamperB         = UnityDamperB;
        model.pointerOrigin   = pose;
        model.rigidbodyOrigin = (Pose)holdingObject;

        meshRenderer.material = HoldingMaterial;
        meshFilter.mesh       = HoldingMesh;

        TransmitObject(holdingObject, TransmitOnHold);

        holdingObject.GetComponent <CutFriction>().holding = true;

        return(true);
    }
Example #7
0
 /// <summary>
 /// 字符串
 /// </summary>
 /// <returns></returns>
 public override String ToString()
 {
     return(Code + "," + StageName + "," +
            EnterLowDateStr + "," + EnterlowFundMainStr + "," +
            SetupTradeMode + "," + SetupDateStr + "," + SetupFundMainStr + "," + SetupPrevFundMainStr + "," + SetupPriceStr + "," + SetupAmount.ToString() + "," +
            HoldState.ToString() + "," +
            CloseTradeMode + "," + closeReason + "," + CloseDateStr + "," + ClosePriceStr + "," + CloseAmountStr + "," + TradeBoutStr);
 }
 private void StartRotation()
 {
     holdState = HoldState.Rotating;
     rigidbodyHeld.constraints = RigidbodyConstraints.FreezePositionX |
                                 RigidbodyConstraints.FreezePositionY |
                                 RigidbodyConstraints.FreezePositionZ;
     rigidbodyHeld.gameObject.tag = "Sticky";
     Cursor.lockState             = CursorLockMode.Locked;
 }
Example #9
0
    void SetSpidarForce()
    {
        if (spidar == null)
        {
            return;
        }

        spidar.SetHaptics(Haptics);
        spidar.SetCascadeGain(CascadeGain);

        if (holdingObject == null || !clutchEngaged)
        {
            return;
        }

        HoldState hs = GetHoldState();

        Vector3 g = Vector3.zero;

        if (Gravity)
        {
            g = Vector3.down * holdingObject.mass * 9.81f;
            g = Quaternion.Inverse(RotationOffset) * g;
        }

        if (!hs.Collision && !curMultiHold)
        {
            if (Gravity)
            {
                spidar.SetForce(Converter.Convert(g), 0, 0, Converter.Convert(Vector3.zero), 0, 0, true, false);
            }
            else
            {
                spidar.ClearForce(true);
            }
            return;
        }

        float deviceR2 = spidar.GetGripRadius() * spidar.GetGripRadius();

        float forceScale  = DeviceSpringK / (UnitySpringK * PositionScale);
        float torqueScale = DeviceSpringK / (UnitySpringK * RotationScale);

        Vector3 f = -model.CalcForce(pose, holdingObject) * forceScale;
        Vector3 t = -model.CalcTorque(pose, holdingObject) * torqueScale * deviceR2;

        f = Quaternion.Inverse(RotationOffset) * f;
        t = Quaternion.Inverse(RotationOffset) * t;

        float forceK = DeviceSpringK;
        float forceB = DeviceDamperB;

        float torqueK = DeviceSpringK * deviceR2;
        float torqueB = DeviceDamperB * deviceR2;

        spidar.SetForce(Converter.Convert(f + g), forceK, forceB, Converter.Convert(t), torqueK, torqueB, false, CascadeControl);
    }
Example #10
0
 public void PutDown()
 {
     heldObject.gameObject.layer = LayerMask.NameToLayer("Item");
     heldObject.parent           = null;
     heldObject.GetComponent <Collider>().isTrigger = false;
     heldItemData     = null;
     canPutBack       = false;
     heldObject       = null;
     holdingObject    = false;
     currentHoldState = HoldState.notHoldingItem;
 }
Example #11
0
 public void LetGoOfObject()
 {
     if (rigidbodyHeld)
     {
         rigidbodyHeld.useGravity  = true;
         rigidbodyHeld.constraints = RigidbodyConstraints.FreezeAll;
     }
     rigidbodyHeld    = null;
     holdState        = HoldState.NotHolding;
     Cursor.lockState = CursorLockMode.None;
 }
Example #12
0
 private void GrabObject(Rigidbody rigidbody)
 {
     mouseOffset               = Vector3.zero;
     rigidbodyHeld             = rigidbody;
     rigidbodyHeld.useGravity  = false;
     rigidbodyHeld.constraints = RigidbodyConstraints.FreezeRotationX |
                                 RigidbodyConstraints.FreezeRotationY |
                                 RigidbodyConstraints.FreezeRotationZ;
     holdState = HoldState.Moving;
     SoundUtils.PlaySoundNonrepeating(audioSource, grabSounds);
 }
Example #13
0
    protected virtual IEnumerator Stun(bool cubeHit)
    {
        playerState = PlayerState.Stunned;

        stunnedRotationTemp = stunnedRotation;

        DOTween.To(() => stunnedRotationTemp, x => stunnedRotationTemp = x, stunnedRotationTemp * 0.3f, stunnedDuration * 0.5f).SetEase(Ease.OutQuint).SetDelay(stunnedDuration * 0.5f).SetUpdate(false);

        if (gettingMovable || holdState == HoldState.Holding)
        {
            holdState = HoldState.CannotHold;

            yield return(new WaitWhile(() => gettingMovable == true));

            Shoot();
        }

        holdState = HoldState.CannotHold;

        GlobalVariables.Instance.screenShakeCamera.CameraShaking(FeedbackType.Stun);
        GlobalVariables.Instance.zoomCamera.Zoom(FeedbackType.Stun);

        if (OnStun != null)
        {
            OnStun();
        }

        if (cubeHit && OnCubeHit != null)
        {
            OnCubeHit();
        }

        if (!cubeHit && OnDashHit != null)
        {
            OnDashHit();
        }

        yield return(new WaitForSeconds(stunnedDuration));

        playerRigidbody.velocity = Vector3.zero;

        playerThatHit = null;

        if (playerState == PlayerState.Stunned)
        {
            playerState = PlayerState.None;
        }

        if (holdState == HoldState.CannotHold)
        {
            holdState = HoldState.CanHold;
        }
    }
Example #14
0
 void NextStep()
 {
     if (view.isTextScrolling)
     {
         view.EndScroll();
     }
     else if (hold == HoldState.Held)
     {
         step++;
         hold = HoldState.Clear;
     }
 }
Example #15
0
    public virtual void OnHoldMovable(GameObject movable, bool forceHold = false)
    {
        if (!forceHold)
        {
            if (playerState == PlayerState.Dead || playerState == PlayerState.Stunned || holdState == HoldState.CannotHold)
            {
                return;
            }
        }

        gettingMovable = true;

        holdState = HoldState.Holding;

        SetMagnetPointPosition(movable);

        MovableScript movableScript = movable.GetComponent <MovableScript>();

        movable.tag          = "HoldMovable";
        movableScript.player = transform;
        movableScript.DestroyRigibody();
        movableScript.OnHold();

        holdMovableTransform = movable.transform;
        holdMovableTransform.SetParent(transform);

        for (int i = 0; i < GlobalVariables.Instance.EnabledPlayersList.Count; i++)
        {
            PlayersGameplay playerScript = GlobalVariables.Instance.EnabledPlayersList[i].GetComponent <PlayersGameplay>();

            if (playerScript.cubesAttracted.Contains(movableScript))
            {
                playerScript.cubesAttracted.Remove(movableScript);
            }

            if (playerScript.cubesRepulsed.Contains(movableScript))
            {
                playerScript.cubesRepulsed.Remove(movableScript);
            }
        }

        cubesAttracted.Clear();
        cubesRepulsed.Clear();

        if (OnHold != null)
        {
            OnHold();
        }

        gettingMovable = false;
    }
Example #16
0
 public void PickUp()
 {
     heldObject.GetComponent <Rigidbody>().isKinematic = true;
     distanceToHeldObject = Vector3.Distance(transform.position, heldObject.position);
     heldItemData         = heldObject.GetComponent <Item>();
     heldObject.GetComponent <Collider>().isTrigger = true;
     heldObject.position         = itemHeldTarget.position;
     heldObject.rotation         = itemHeldTarget.rotation;
     heldObject.parent           = itemHeldTarget;
     heldObject.gameObject.layer = LayerMask.NameToLayer("NOCLEAR");
     holdingObject    = true;
     currentHoldState = HoldState.delay;
     ;
 }
Example #17
0
    protected virtual IEnumerator DeathCoroutine()
    {
        playerState = PlayerState.Dead;

        GameAnalytics.NewDesignEvent("Player:" + name + ":" + GlobalVariables.Instance.CurrentModeLoaded.ToString() + ":LifeDuration",
                                     StatsManager.Instance.playersStats[playerName.ToString()].playersStats[WhichStat.LifeDuration.ToString()]);

        GlobalVariables.Instance.screenShakeCamera.CameraShaking(FeedbackType.Death);
        GlobalVariables.Instance.zoomCamera.Zoom(FeedbackType.Death);

        PlayerStats(playerThatHit);

        if (gettingMovable || holdState == HoldState.Holding)
        {
            yield return(new WaitWhile(() => gettingMovable == true));

            MovableScript movableScript = holdMovableTransform.gameObject.GetComponent <MovableScript>();

            movableScript.hold       = false;
            holdMovableTransform.tag = "Movable";
            holdMovableTransform.SetParent(null);
            holdMovableTransform.SetParent(movableParent);

            if (movableScript.rigidbodyMovable == null)
            {
                movableScript.AddRigidbody();
            }

            movableScript.OnRelease();
        }

        holdState = HoldState.CannotHold;

        gameObject.SetActive(false);

        RemoveFromAIObjectives();

        if (GlobalVariables.Instance != null)
        {
            GlobalVariables.Instance.ListPlayers();
        }

        GlobalVariables.Instance.lastManManager.PlayerDeath(playerName, gameObject);

        if (OnDeath != null)
        {
            OnDeath();
        }
    }
Example #18
0
    protected virtual void OnEnable()
    {
        StartCoroutine(WaitTillPlayerEnabled());

        if (GlobalVariables.Instance.GameState != GameStateEnum.Playing)
        {
            StartCoroutine(Startup());
        }

        cubesAttracted.Clear();
        cubesRepulsed.Clear();

        if (playerRigidbody != null)
        {
            playerRigidbody.velocity = Vector3.zero;
        }

        if (playerState != PlayerState.Startup)
        {
            playerState = PlayerState.None;
        }

        StartCoroutine(LifeDuration());

        dashState = DashState.CanDash;
        holdState = HoldState.CanHold;

        playerThatHit = null;

        if (GlobalVariables.Instance != null)
        {
            GlobalVariables.Instance.ListPlayers();
        }

        if (controllerNumber == 0)
        {
            GlobalVariables.Instance.SetPlayerMouseCursor();
        }

        if (gameObject.layer == LayerMask.NameToLayer("Safe"))
        {
            if (OnSafe != null)
            {
                OnSafe();
            }
        }
    }
Example #19
0
    private void StartMovingAgain()
    {
        Vector3 mousePosition = GetMousePositionInGamePlane();

        mouseOffset = rigidbodyHeld.transform.position - mousePosition;

        rigidbodyHeld.useGravity      = false;
        rigidbodyHeld.angularVelocity = Vector3.zero;
        rigidbodyHeld.constraints     = RigidbodyConstraints.FreezePositionZ |
                                        RigidbodyConstraints.FreezeRotationX |
                                        RigidbodyConstraints.FreezeRotationY |
                                        RigidbodyConstraints.FreezeRotationZ;
        rigidbodyHeld.gameObject.tag = "Untagged";

        holdState        = HoldState.Moving;
        Cursor.lockState = CursorLockMode.None;
    }
Example #20
0
    HoldState GetHoldState()
    {
        GameObject obj = holdingObject.gameObject;

        HoldState [] hsList = obj.GetComponents <HoldState>();

        for (int i = 0; i < hsList.Length; ++i)
        {
            if (hsList[i].Owner == this)
            {
                return(hsList[i]);
            }
        }

        HoldState hs = obj.AddComponent <HoldState>();

        hs.Owner = this;
        return(hs);
    }
Example #21
0
    private void Update()
    {
        if (m_HoopCollider != null)
        {
            m_ParticleSystem.transform.rotation = Quaternion.identity;
            m_ParticleSystem.transform.Rotate(new Vector3(1f, 0f, 0f), -90);
            m_ParticleSystem.transform.position = m_HoopCollider.transform.position;
        }

        if (m_BallState == State.PullToCenter)
        {
            m_SnapToCenterHoopTimer += Time.deltaTime;
            if (m_SnapToCenterHoopTimer > 1f)
            {
                m_SnapToCenterHoopTimer = 1f;
            }

            transform.position = Vector3.Lerp(transform.position, m_HoopCollider.transform.position, m_SnapToCenterHoopTimer);

            if (m_SnapToCenterHoopTimer == 1f && m_BallState != State.Falling)
            {
                m_ParticleSystem.Play();
                m_BallState       = State.Falling;
                m_Ball.useGravity = true;
            }

            if (m_BallState == State.Falling)
            {
                Vector3 NewPosition = transform.position;
                NewPosition.x      = m_HoopCollider.transform.position.x;
                NewPosition.z      = m_HoopCollider.transform.position.z;
                transform.position = NewPosition;
            }
        }

        if (m_HoldState == HoldState.Release)
        {
            m_Ball.useGravity = true;
            m_HoldState       = HoldState.None;
            m_Ball.AddForce(transform.forward * 400f);
        }
    }
Example #22
0
    /// <summary>
    /// 掴んでいるオブジェクトを放す.
    /// 成功した場合はtrueを返し,オブジェクトを掴んでいない場合は何もせずにfalseを返す.
    /// </summary>
    /// <returns>
    /// true: 成功
    /// false: 失敗
    /// </returns>
    public bool ReleaseObject()
    {
        if (holdingObject == null)
        {
            return(false);
        }

        if (spidar != null)
        {
            spidar.ClearForce();
        }

        HoldState hs = GetHoldState();

        hs.OnReleaseObject();
        RemoveHoldState();

        holdingObject.GetComponent <CutFriction>().holding = false;

        holdingObject = null;

        model.Clear();

        TransmitObject(null, false);

        if (collidingObject != null)
        {
            meshRenderer.material = CollidingMaterial;
            meshFilter.mesh       = CollidingMesh;
            TransmitObject(collidingObject, TransmitOnCollide);
        }
        else
        {
            meshRenderer.material = FreeMaterial;
            meshFilter.mesh       = FreeMesh;
        }

        return(true);
    }
Example #23
0
    void OnGUI()
    {
        if (!showInformation ||
            _pointers.Length == 0 ||
            (_pointerSetting != null && _pointerSetting.isOpened))
        {
            return;
        }

        int left = PointerSetting.SettingButtonLeft;
        int top  = Margin + (_pointerSetting == null ?
                             PointerSetting.SettingButtonTop :
                             PointerSetting.SettingButtonTop + PointerSetting.SettingButtonHeight);
        int width  = Screen.width - left;
        int height = Screen.height - top;

        GUILayout.BeginArea(new Rect(left, top, width, height));
        GUILayout.Label("Key configuration: ", _style);
        GUILayout.Label("   [ i ]   -  show/hide this information", _style);
        GUILayout.Label("   [   ]   -  hold/release object", _style);
        GUILayout.Label("   [v ]   -  clutch on/off", _style);
        GUILayout.Label("   [c ]   -  execute calibration", _style);
        GUILayout.Label("   [m]   -  select haptic pointer", _style);
        GUILayout.Space(20);

        HapticPointer hp = _pointers[_currentPointer];

        GUILayout.Label("Selected Haptic Pointer:  " + hp.name, _style);
        if (hp.Activated)
        {
            GUILayout.Label("   Device serial number: " + hp.SerialNumber, _style);
            GUILayout.Label("   Device Delta Time: " + (hp.DeviceDeltaTime * 1000).ToString("f3") + "[ms]", _style);
            GUILayout.Label("   Haptics: " + hp.Haptics + ", Gravity: " + hp.Gravity + ", Cascade Control: " + hp.CascadeControl, _style);
            if (hp.DebugMode)
            {
                GUILayout.Label("   GPIO: " + hp.GpioValue, _style);

                int[] encoderCount = new int[8];
                hp.GetEncoderCount(ref encoderCount);
                GUILayout.Label("   Encoder counts", _style);

                for (int i = 0; i < 8; ++i)
                {
                    GUILayout.Label("      Motor " + (i + 1) + ": " + encoderCount[i], _style);
                }

                if (hp.HoldingObject)
                {
                    GUILayout.Space(10);
                    HoldState hs = hp.HoldingObject.GetComponent <HoldState>();
                    GUILayout.Label(hp.HoldingObject.ToString(), _style);
                    GUILayout.Label(hs.ToString(), _style);
                    GUILayout.Label("   Collision state: " + hs.Collision, _style);
                    GUILayout.Label("   Mass: " + hp.HoldingObject.mass, _style);
                    GUILayout.Label("   Center of mass: " + hp.HoldingObject.centerOfMass.ToString("f4"), _style);
                    GUILayout.Label("   InertiaTensor: " + hp.HoldingObject.inertiaTensor.ToString("f4"), _style);
                    GUILayout.Label("   InertiaTensorRotation: " + hp.HoldingObject.inertiaTensorRotation.ToString("f4"), _style);
                }
            }
        }
        else
        {
            GUILayout.Label("  ... not activated", _style2);
        }
        GUILayout.Space(20);

        GUILayout.Label("Unity delta time: " + (Time.deltaTime * 1000).ToString("f3") + "[ms], Fixed delta time: "
                        + (Time.fixedDeltaTime * 1000).ToString("f3") + "[ms]", _style);

        GUILayout.EndArea();
    }
Example #24
0
    private void ProcessLoop()
    {
        while (true)
        {
            // If held, break as not to cause infinite loop :3
            if (hold == HoldState.Held)
            {
                break;
            }

            // Using XPath, finds current label, finds the step (any type) with the current step no (Note: XPath order selector starts at 1, not 0)
            var command = vnScript.SelectSingleNode($"/Script/Label[@name='{route}']/*[{step}]");

            switch (command.Name) // wew thats a large switch
            {
            case "Text":          // A plain VN Dialogue, nothing hard
                view.SetDialogue(command.InnerText);
                break;

            case "Element-Create":
                XMLElementAction.Create(command);
                break;

            case "Element-Destroy":
                Element.Destroy(command.Attributes["name"].Value);
                break;

            case "Music-Play":     // TODO: Not sure what this does, replace!
                var clip = ResourceController.Get <AudioClip>(command.InnerText);
                musicPlayer.PlayOneShot(clip);
                break;

            case "Load":
                if (command.Attributes?["type"]?.Value == "sprite")
                {
                    ResourceController.Load <Sprite>(command.InnerText);
                }
                else
                {
                    ResourceController.Load(command.InnerText);
                }
                break;

            case "Unload":
                ResourceController.Unload(command.InnerText);
                break;

            case "Jump":
                route = command.Attributes["label"].Value;
                step  = 0;    // somewhat hacky way to handle the increment at the end, will fix if this errs or something
                break;

            case "JS":     // JS Exec
                jsEngine.Execute(command.InnerText);
                break;

            default:
                throw new Exception($"{command.Name} is not a valid tag");
            }
            hold = Hold.GetHoldState(command);
            if (hold == HoldState.Clear)
            {
                step++;                          // Only progress to next step when HoldState is clear.
            }
        }
    }
Example #25
0
 public ActionState()
 {
     this.State = HoldState.UNHELD;
 }
Example #26
0
 public void SetRelease()
 {
     m_HoldState = HoldState.Release;
 }
Example #27
0
 public void Pickup()
 {
     oldParent      = transform.parent;
     _holdState     = HoldState.Held;
     _interactState = InteractionState.Activated;
 }
Example #28
0
 public void Drop()
 {
     _holdState       = HoldState.Dropped;
     _interactState   = InteractionState.Ready;
     transform.parent = oldParent;
 }
 protected virtual void HoldStateUpdate(HoldState state)
 {
 }
Example #30
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 10000.0f))
        {
            if (hit.collider.tag == "Interact")
            {
                if (Input.GetButtonDown("Interact"))
                {
                    hit.collider.gameObject.GetComponent <GameEventTrigger>().TriggerEvent();
                }
                return;
            }
        }



        switch (currentHoldState)
        {
        case HoldState.notHoldingItem:
            GameObject obj = DetectObject("Pickup");
            if (obj)
            {
                if (Input.GetButtonDown("Interact"))
                {
                    heldObject = obj.transform;
                    PickUp();
                }
            }
            else
            {
            }
            break;

        case HoldState.holdingItem:
            if (CanPutItemBack())
            {
                currentHoldState = HoldState.putItemBack;
            }
            if (Input.GetButtonDown("Interact"))
            {
                if (IsItemBehindWall())
                {
                    return;
                }
                else
                {
                    heldObject.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                    heldObject.gameObject.GetComponent <Rigidbody>().AddForce(Camera.main.transform.forward * throwForce, ForceMode.Impulse);
                    PutDown();
                }
            }
            break;

        case HoldState.delay:
            if (holdTimer > 0)
            {
                holdTimer -= Time.deltaTime;
            }
            else
            {
                holdTimer        = holdDelay;
                currentHoldState = HoldState.holdingItem;
            }
            break;

        case HoldState.putItemBack:
            if (!CanPutItemBack())
            {
                currentHoldState = HoldState.holdingItem;
            }


            if (Input.GetButton("Interact"))
            {
                heldObject.transform.position = heldItemData.originalLocation;
                heldObject.transform.rotation = heldItemData.originalRotation;
                PutDown();
            }
            break;
        }
    }
Example #31
0
 public PendingAction(int actionCode, HoldState state, IControllerActionInfo info)
 {
     this.ActionCode = actionCode;
     this.State      = state;
     this.Info       = info;
 }