public void ShowUI(Transform followTransform, Vector3 origin, float shieldRadius) { if (m_Follow == null) { m_Follow = GetComponent <FollowTransformController>(); } //Переместить объект в позицию игрока transform.position = followTransform.position; //Начать следовать за игроком m_Follow.Init(followTransform); //Размер индикатора IndicatorController.Scale = m_INDICATOR_SCALE * shieldRadius; //Включить индикатор IndicatorController.gameObject.SetActive(true); //Вращение индикатора Vector3 lookRotationEuler = Quaternion.LookRotation(origin).eulerAngles; transform.eulerAngles = new Vector3(transform.localEulerAngles.x, lookRotationEuler.y, transform.localEulerAngles.z); Debug.Log("Shield dir " + origin + " Shield euler: " + lookRotationEuler); //Обнулить угол IndicatorController.Angle = 0; }
public void Init(Transform parent, AbilityTypes type) { //Follow if (m_FollowController == null) { m_FollowController = GetComponent <FollowTransformController> (); } m_FollowController.Init(parent); //Rotation m_TargetRot = parent.rotation; //Color if (m_Material == null) { m_Material = new Material(Renderer.sharedMaterial); Renderer.sharedMaterial = m_Material; } //Length Vector3 scale = transform.localScale; scale.z = GameManager.Instance.GameState.DataTableAbilities.GetAbilityData(type).Length; transform.localScale = scale; m_Material.color = GameManager.Instance.GameState.AbilityColorController.GetAbilityColor(type); m_IsActive = true; }
public void Init(Transform parent, Dictionary <AbilityTypes, Character.Health.HealthController.HealthSegment> healthData) { //Follow if (m_FollowController == null) { m_FollowController = GetComponent <FollowTransformController>(); } m_FollowController.Init(parent); //Healthbar int segments = 0; m_Segments = new Dictionary <AbilityTypes, UIHealthBarSegment>(); foreach (Character.Health.HealthController.HealthSegment segmentData in healthData.Values) { //Create segment UIHealthBarSegment segment = PoolManager.GetObject(GameManager.Instance.PrefabLibrary.UIHealthBarSegmentPrefab) as UIHealthBarSegment; //Position segment RectTransform segmentRectTransform = segment.GetComponent <RectTransform>(); segmentRectTransform.SetParent(SegmentParent); segmentRectTransform.anchoredPosition = Vector3.zero; segmentRectTransform.localPosition = Vector3.zero; segmentRectTransform.localEulerAngles = Vector3.zero; //Scale segment float scale = m_InitSize - m_StepDelta * segments; segmentRectTransform.localScale = new Vector3(scale, scale, scale); //Init segment segment.Init(segmentData.Type, segmentData.Health); //Other m_Segments.Add(segmentData.Type, segment); segments++; } }