Exemplo n.º 1
0
    public void DoorTransition(bool right, float duration, float distance)
    {
        enabled = false;
        damageTimer.Stop(true);
        facingRight          = right;
        transform.localScale = new Vector3(facingRight ? 1 : -1, 1, 1);
        renderer.material.SetInt("_FlipX", facingRight ? 0 : 1);
        arm.localScale = new Vector3(facingRight ? 1 : -1, 1, 1);
        SetAnimatorUpdateMode(AnimatorUpdateMode.UnscaledTime);
        Play("run");
        LerpToTarget lerp = gameObject.GetComponent <LerpToTarget>();

        if (lerp == null)
        {
            lerp = gameObject.AddComponent <LerpToTarget>();
        }
        lerp.moveTransform       = transform;
        lerp.WorldTarget         = true;
        lerp.targetPositionWorld = transform.position + ((right ? Vector3.right : Vector3.left) * distance);
        lerp.duration            = duration;
        lerp.unscaledTime        = true;
        lerp.enabled             = true;
        lerp.OnLerpEnd           = delegate
        {
            enabled = true;
            SetAnimatorUpdateMode(AnimatorUpdateMode.Normal);
        };
    }
Exemplo n.º 2
0
    public void PositionItems()
    {
        float unit = 1.0f / 5.0f;

        for (int i = 0; i < RightHandItemMount.childCount; i++)
        {
            int          index = (rightSelectedIndex + i) % RightHandItemMount.childCount;
            LerpToTarget lerp  = RightHandItemMount.GetChild(index).GetComponent <LerpToTarget>();
            lerp.lerpType        = LerpToTarget.LerpType.Linear;
            lerp.duration        = 0.2f;
            lerp.targetTransform = RightHandItemMount;
            lerp.localOffset     = new Vector3(unit * (float)i, 0, 0) * ScaleItemsRight;
            lerp.OnLerpEnd       = null;
            lerp.enabled         = true;

      #if UNITY_EDITOR
            InventoryItem item   = RightHandItemMount.GetChild(index).GetComponent <InventoryItem>();
            InventoryItem prefab = item.CarryObjectPrefab.Item;
            RightHandItemMount.GetChild(index).localRotation = Quaternion.LookRotation(prefab.InInventoryForward, prefab.InInventoryUp);
      #endif
        }
        for (int i = 0; i < LeftHandItemMount.childCount; i++)
        {
            int          index = (leftSelectedIndex + i) % LeftHandItemMount.childCount;
            LerpToTarget lerp  = LeftHandItemMount.GetChild(index).GetComponent <LerpToTarget>();
            lerp.lerpType        = LerpToTarget.LerpType.Linear;
            lerp.duration        = 0.2f;
            lerp.targetTransform = LeftHandItemMount;
            lerp.localOffset     = new Vector3(unit * (float)i, 0, 0) * ScaleItemsLeft;
            lerp.OnLerpEnd       = null;
            lerp.enabled         = true;
        }
    }
Exemplo n.º 3
0
 public void ShieldOff()
 {
     if (ShieldTransform != null && shielding)
     {
         shielding = false;
         ShieldTransform.localRotation = Quaternion.identity;
         LerpToTarget lerp = ShieldTransform.GetComponent <LerpToTarget>();
         lerp.enabled     = true;
         lerp.duration    = 0.2f;
         lerp.localOffset = ShieldInactiveLocal;
         lerp.OnLerpEnd   = null;
     }
 }
Exemplo n.º 4
0
 public void ShieldOn()
 {
     if (ShieldTransform != null && !shielding)
     {
         shielding = true;
         ShieldTransform.localRotation = Quaternion.identity;
         LerpToTarget lerp = ShieldTransform.GetComponent <LerpToTarget>();
         lerp.targetTransform = moveTransform;
         lerp.enabled         = true;
         lerp.duration        = 0.2f;
         lerp.localOffset     = ShieldActiveLocal;
     }
 }
Exemplo n.º 5
0
    public void AcquireItem(InventoryItem item)
    {
        LerpToTarget lerp = item.GetComponent <LerpToTarget>();

        lerp.targetTransform = item.transform.parent;
        lerp.duration        = 1f;
        lerp.Continuous      = false;
        lerp.Scale           = true;
        lerp.targetScale     = ItemScale;
        lerp.lerpType        = LerpToTarget.LerpType.Curve;
        lerp.translateCurve  = AddTranslateCurve;
        lerp.enabled         = true;
        lerp.OnLerpEnd       = delegate {
            PositionItems();
        };

        if (item.Type == "weapon")
        {
            item.transform.parent = RightHandItemMount;
            if (RightHandItemMount.childCount == 1)
            {
                SelectRightHand(0);
            }
        }
        if (item.Type == "shield")
        {
            item.transform.parent = LeftHandItemMount;
            if (LeftHandItemMount.childCount == 1)
            {
                SelectLeftHand(0);
            }
        }
        if (item.Type == "health")
        {
            Health += 1;
        }

        item.transform.localRotation = Quaternion.LookRotation(item.InInventoryForward, item.InInventoryUp);
    }
Exemplo n.º 6
0
    void PushSleep()
    {
        InSleepCycle = true;

        CurrentMoveSpeed = SprintSpeed;
        SleepInterrupt   = false;

        spriteLerp = billboard.gameObject.GetComponent <LerpToTarget>();
        if (spriteLerp == null)
        {
            spriteLerp = billboard.gameObject.AddComponent <LerpToTarget>();
        }

        moveTransformLerp = moveTransform.gameObject.GetComponent <LerpToTarget>();
        if (moveTransformLerp == null)
        {
            moveTransformLerp = moveTransform.gameObject.AddComponent <LerpToTarget>();
        }


        if (!isPlayerControlled && TargetBed != null && Vector3.Distance(moveTransform.position, TargetBed.transform.position) > MaxBedLerpDistance)
        {
            sleepState       = SleepState.MovingToBed;
            CurrentMoveSpeed = WalkSpeed;
            if (!SetPath(TargetBed.destination.transform.position, delegate
            {
                StartSleep();
            }))
            {
                Debug.Log("path failed");
            }
        }
        else
        {
            sleepState = SleepState.GettingIntoBed;
            StartSleep();
        }
    }