protected void DrawSelectionBox(Rect selectBox) { GUI.Box(selectBox, ""); CalculateCurrentHealth(0.35f, 0.65f); DrawHealthBar(selectBox, ""); if (cachedHarvest) { long currentLoad = cachedHarvest.GetCurrentLoad(); if (currentLoad > 0) { float percentFull = currentLoad / (float)cachedHarvest.Capacity; float maxHeight = selectBox.height - 4; float height = maxHeight * percentFull; float leftPos = selectBox.x + selectBox.width - 7; float topPos = selectBox.y + 2 + (maxHeight - height); float width = 5; Texture2D resourceBar = GameResourceManager.GetResourceHealthBar(cachedHarvest.HarvestType); if (resourceBar) { GUI.DrawTexture(new Rect(leftPos, topPos, width, height), resourceBar); } } } }
public void HandleHighlightedChange() { if (ReplayManager.IsPlayingBack) { return; } if (Agent && Agent.IsActive) { if (!Agent.IsSelected && Agent.IsHighlighted) { if ((Agent as RTSAgent).Controller.Commander && (Agent as RTSAgent).Controller.Commander == cachedCommander) { //belongs to current cachedCommander cachedCommander.CachedHud.SetCursorState(CursorState.Select); } else if (Agent.Controller.GetAllegiance(cachedController) != AllegianceType.Friendly && cachedController.SelectedAgents.Count > 0 && Agent.MyAgentType != AgentType.Resource) { cachedCommander.CachedHud.SetCursorState(CursorState.Attack); } else if ((Agent.MyAgentType == AgentType.Unit || Agent.MyAgentType == AgentType.Building) && Agent.GetAbility <Attack>() && Agent.GetAbility <Attack>().CanAttack) { cachedCommander.CachedHud.SetCursorState(CursorState.Attack); } else { cachedCommander.CachedHud.SetCursorState(CursorState.Select); } } else if (Agent.IsSelected && Agent == Selector.MainSelectedAgent) { if (!SelectionManager.MousedAgent) { if (Agent.MyAgentType == AgentType.Building && cachedSpawner && cachedSpawner.GetFlagState() == FlagState.SettingFlag) { cachedCommander.CachedHud.SetCursorState(CursorState.RallyPoint); } else if (Agent.GetAbility <Move>() && Agent.GetAbility <Move>().CanMove) { cachedCommander.CachedHud.SetCursorState(CursorState.Move); } } else { if (cachedHarvest) { if (SelectionManager.MousedAgent.MyAgentType == AgentType.Resource && !SelectionManager.MousedAgent.GetAbility <ResourceDeposit>().IsEmpty()) { cachedCommander.CachedHud.SetCursorState(CursorState.Harvest); } else if (SelectionManager.MousedAgent.MyAgentType == AgentType.Building && (Agent as RTSAgent).objectName == cachedHarvest.ResourceStoreName && cachedHarvest.GetCurrentLoad() > 0) { cachedCommander.CachedHud.SetCursorState(CursorState.Deposit); } } } } } }