コード例 #1
0
    private void Update()
    {
        //Fulfixar
        if (!isDead)
        {
            //Fullfix för om target-objekt försvinner.
            if (currentTargetObject == null)
            {
                returnedState = new NewObjectThiefSearchState();
                StateSwap();
            }

            //Fulfix för om hand-objektet försvinner
            //else if (currentTargetObject.tag == "OutOfBounds" && (objectInHand == null || objectInHand.activeInHierarchy == false))
            //{
            //    objectInHand = null;
            //    returnedState = new NewObjectThiefSearchState();
            //    StateSwap();
            //}
        }

        returnedState = currentState.Update(this, Time.deltaTime);
        if (returnedState != null)
        {
            StateSwap();
        }
    }
コード例 #2
0
    public void Die()
    {
        ghostSound.Stop();

        isDead        = true;
        returnedState = new NewObjectThiefDeathState();
        StateSwap();
    }
コード例 #3
0
    private void OnEnable()
    {
        ghostSound.Play();

        //Enable and set marionette at correct position again.
        ToggleMarionetteStrings(true);
        //transform.position = new Vector3(transform.position.x, 3, transform.position.z);
        //rigidBodyMarionette.velocity = new Vector3(0, 0, 0);
        //rigidBodyArm.velocity = new Vector3(0, 0, 0);

        //for (int i = 0; i < marionetteStringGameObjects.Length; i++)
        //{

        //    marionetteStringGameObjects[0].transform.localPosition = new Vector3(0, 1.398f, 0);
        //    marionetteStringGameObjects[1].transform.localPosition = new Vector3(0, 0, 0);

        //}

        if (relativeStartPositions != null)
        {
            RestartAllPositions();
        }

        //Fullösning för att få de att ställa sig upp när de spawnas om de råkar vara liggandes när de despawnade.
        rigidBodyMarionette.AddForce(new Vector3(0, 500, 0));
        //transform.position = new Vector3(0, 5, 0);

        randomTargetArea.SetTargetPositionToPlayArea();
        currentTargetObject = randomTargetObject;

        if (stateMachineOn)
        {
            currentState = new NewObjectThiefMoveToTargetState();
        }

        else
        {
            currentState = new NewObjectThiefEmptyStateForTesting();
        }

        currentState.Enter(this);
    }
コード例 #4
0
 private void StateSwap()
 {
     currentState.Exit(this);
     currentState = returnedState;
     currentState.Enter(this);
 }
コード例 #5
0
 private void FixedUpdate()
 {
     returnedState = currentState.FixedUpdate(this, Time.deltaTime);
 }