/// <summary> /// Add a lock to the target box. /// </summary> /// <param name="targetLocker">The lock information source.</param> public virtual void AddLock(TargetLocker targetLocker) { if (locksController != null) { locksController.AddLock(targetLocker); } }
/// <summary> /// Add a target locker to the HUD target boxes. /// </summary> /// <param name="targetLocker">The target locker to add.</param> public virtual void AddTargetLocker(TargetLocker targetLocker) { if (!targetLockers.Contains(targetLocker)) { targetLockers.Add(targetLocker); } }
/// <summary> /// Remove a target locker from the HUD target boxes. /// </summary> /// <param name="targetLocker">The target locker to remove.</param> public virtual void RemoveTargetLocker(TargetLocker targetLocker) { int index = targetLockers.IndexOf(targetLocker); if (index != -1) { targetLockers.RemoveAt(index); } }
/// <summary> /// Add a lock to the target box. /// </summary> /// <param name="targetLocker">The target locker that is locked onto the target.</param> public virtual void AddLock(TargetLocker targetLocker) { lastUsedIndex += 1; if (lastUsedIndex < lockBoxes.Count) { lockBoxes[lastUsedIndex].gameObject.SetActive(true); // Update the lock state switch (targetLocker.LockState) { case LockState.NoLock: lockBoxes[lastUsedIndex].gameObject.SetActive(false); break; case LockState.Locking: lockBoxes[lastUsedIndex].gameObject.SetActive(true); lockBoxes[lastUsedIndex].RectTransform.offsetMin = new Vector2(-lockingMargin, -lockingMargin); lockBoxes[lastUsedIndex].RectTransform.offsetMax = new Vector2(lockingMargin, lockingMargin); break; case LockState.Locked: lockBoxes[lastUsedIndex].gameObject.SetActive(true); float amount = Mathf.Clamp((Time.time - targetLocker.LockStateChangeTime) / animationTime, 0, 1); float offset = lockingMargin - amount * (lockingMargin - lockedMargin); lockBoxes[lastUsedIndex].RectTransform.offsetMin = new Vector2(-offset, -offset); lockBoxes[lastUsedIndex].RectTransform.offsetMax = new Vector2(offset, offset); break; } numLocks += 1; numLocksText.text = numLocks.ToString(); } else { return; } }