private void Awake() { var mainStatus = Unit_Status_Information.GetMainStatusFieldsName(); MainStatus = new UI_Menu_Inventory_Right_PlayerInfo_MainStatus_Child[mainStatus.Length]; var spacing = new float[] { SPACING, SPACING, SPACING }; var index = 0; var startPos = new Vector2((RectTransform.sizeDelta.x * -0.5f) + (WIDTH * 0.5f), (RectTransform.sizeDelta.y * 0.5f) - (HEIGHT * 0.5f)); var childSize = new Vector2(WIDTH, HEIGHT); foreach (var m in mainStatus) { var mainStatusGO = new GameObject(m); var mainStatusRT = mainStatusGO.AddComponent <RectTransform>(); mainStatusRT.SetParent(RectTransform); mainStatusRT.sizeDelta = childSize; mainStatusRT.localPosition = startPos; MainStatus[index] = mainStatusGO.AddComponent <UI_Menu_Inventory_Right_PlayerInfo_MainStatus_Child>(); if (index < spacing.Length) { startPos -= new Vector2(0, spacing[index]); } startPos -= new Vector2(0, HEIGHT); index++; } // =============================================================================================== // Register OnEquipped and OnUnequipped callback to event // =============================================================================================== GameManager.Player.Equipment.OnEquippedEvent.AddListener(OnEquipped); GameManager.Player.Equipment.OnUnequippedEvent.AddListener(OnUnequipped); }
public Unit_Status_HP(Unit_Status_Information information, EventManager <Unit_Status_DamageData> onDamageReceivedListener) { this.information = information; CurrentHealth = this.information.HP; onDamageReceivedListener.AddListener(Damage); }
public void Initialize(Unit_Status_Information mainStatus) { if (this.mainStatus != null) { Debug.Log("This component was already initialized", Debug.LogType.Warning); return; } this.mainStatus = mainStatus; }
public Unit_Status_ST(Unit_Status_Information information) { this.information = information; OnStaminaReducedBecauseAttackingEvent = new EventManager <int>(); OnStaminaReducedBecauseParryingEvent = new EventManager <int>(); OnStaminaReducedToZeroEvent = new EventManager(); OnStaminaBeginRegeneratingEvent = new EventManager(); OnStaminaRegeneratingEvent = new EventManager <int>(); OnStaminaFullyRegeneratedEvent = new EventManager(); OnStaminaHealedEvent = new EventManager <int>(); waitTimeInSeconds = new WaitForSeconds(waitingTimeBeforeStaminaStartToRegenerateInSeconds); CurrentStamina = MaxStamina; }
private void Awake() { var status = Unit_Status_Information.GetMainStatusFieldsName(); var spacing = UI_Menu_Inventory_Right_PlayerInfo_MainStatus.SPACING; var spacingBIG = UI_Menu_Inventory_Right_PlayerInfo_MainStatus.SPACING_BIG; var height = UI_Menu_Inventory_Right_PlayerInfo_MainStatus.HEIGHT; var totalSpacing = (spacing * 3) + spacingBIG; var totalHeight = height * status.Length; var ySize = totalSpacing + totalHeight; var statusGO = new GameObject(nameof(UI_Menu_Inventory_Right_PlayerInfo_MainStatus)); var statusRT = statusGO.AddComponent <RectTransform>(); statusRT.SetParent(RectTransform); statusRT.sizeDelta = new Vector2(RectTransform.sizeDelta.x, ySize); statusRT.localPosition = Vector3.zero; Status = statusGO.AddComponent <UI_Menu_Inventory_Right_PlayerInfo_MainStatus>(); }