43 lines
927 B
C#
43 lines
927 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using BITFALL.Player.Equip;
|
||
|
using BITKit;
|
||
|
using BITKit.Entities;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITFALL.Player
|
||
|
{
|
||
|
public class PlayerScopeController : EntityBehavior
|
||
|
{
|
||
|
[SerializeField] private LocationAdditive locationAdditive;
|
||
|
|
||
|
[SerializeField] private Vector3 scopePositionWeight;
|
||
|
|
||
|
[Inject]
|
||
|
private IEquipService _equipService;
|
||
|
|
||
|
private GameObject _scopeObject=>UXPlayerScope.Singleton.scopeObject;
|
||
|
public override void OnStart()
|
||
|
{
|
||
|
}
|
||
|
private void Update()
|
||
|
{
|
||
|
_scopeObject.SetActive(
|
||
|
_equipService.AllowScope
|
||
|
);
|
||
|
if (_scopeObject.transform is RectTransform rectTransform)
|
||
|
{
|
||
|
rectTransform.anchoredPosition3D = MathV.Multiply(locationAdditive.transform.localPosition, scopePositionWeight);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override void OnDestroyComponent()
|
||
|
{
|
||
|
if (_scopeObject)
|
||
|
_scopeObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|