private void LateUpdate() { if (_target == null) { return; } Vector3 offset = new Vector3(0.0f, _target.BarYOffset, 0.0f); Vector2 screenPos = GUIBehaviour.WorldToScreen(_target.transform.position + offset, _camera); GetComponent <RectTransform>().anchoredPosition = screenPos; Bar.value = _target.CurHealth / _target.MaxHealth; if (_target is Construct) { Construct target = _target as Construct; if (target.Broken) { BarFill.color = BrokenColor; } else { BarFill.color = target.Faction.Color; } } else if (_target is Player) { BarFill.color = ((Player)_target).Faction.Color; } else { BarFill.color = BrokenColor; } }
public Behaviour(GUIBehaviour view, BehaviourTree tree) { activeTasks = new List <TaskNode>(); this.view = view; this.view.SetModel(this); this.tree = tree; }
void Awake() { this.name = shipName; this.tag = SetFactionString(faction) + "Ship"; _renderer = GetComponent <Renderer>(); _guiBehaviour = GameObject.FindGameObjectWithTag("GUI_Listener").transform.GetChild(0).GetComponent <GUIBehaviour>(); _localShipsManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <LocalShipsManager>(); InvokeRepeating("ShieldsRegenerate", 6, shieldRegenFrequency); }
void Awake() { _guiBehaviour = _guiGameObject.GetComponent <GUIBehaviour>(); combatLogToDisplay = new List <string>(); textLogToDisplay = new List <string>(); combatLogToDisplay.Add(""); textLogToDisplay.Add(""); Invoke("AutoFade", idleFadeOutTime); }
public void Create(int nodeID, Vector2 guiPosition, ParentNode parent, BehaviourTree tree) { GUIBehaviour gui = new GUIBehaviour(nodeID, guiPosition); tree.AddGUINode(gui); activeTasks = new List <TaskNode>(); this.view = gui; this.view.SetModel(this); this.tree = tree; tree.SetBehaviour(this); }
void Start() { camera = Instantiate(camera); camera.targetDisplay = ownDisplay ? number - 1 : 0; foreach (Camera cam in camera.GetComponentsInChildren <Camera>()) { cam.targetDisplay = camera.targetDisplay; } canvas = Instantiate(canvas); canvas.targetDisplay = camera.targetDisplay; canvas.GetComponentInChildren <PlayerRebinder>(true).PlayerInput = GetComponent <PlayerInput>(); if (!playerSteering) { playerSteering = GetComponent <PlayerSteering>(); } GUI = Instantiate(GUI); GUI.MainCamera = camera; GUI.transform.SetParent(canvas.transform); GUI.transform.localPosition = Vector3.zero; GUI.transform.localScale = Vector3.one; GUI.player = this; GUI.Setup(); // GUI.takeScreen (numPlayersOffline, number); //GUI.GetComponent<Canvas> ().worldCamera = camera.GetComponent<Camera> (); /*switch (numPlayersOffline) { * case 2: * UnityEngine.UI.CanvasScaler CS = GUI.GetComponent<UnityEngine.UI.CanvasScaler> (); * Vector2 res = CS.referenceResolution; * res.y *= 2f; * CS.referenceResolution = res; * * break; * default: * break; * }*/ playerSteering.simpleCamera = camera.GetComponent <SimpleCamera>(); playerSteering.simpleSmooth = camera.GetComponent <SimpleSmooth>(); IntoVehicle(mainVehicle); }
// Start is called before the first frame update void Start() { // Get GUI script gui = GameObject.Find("GUI").GetComponent <GUIBehaviour>(); // Get tolerance zone mesh GameObject zoneObj = transform.Find("ToleranceZone").gameObject; if (zoneObj) { zoneMesh = zoneObj.GetComponent <MeshFilter>().mesh; } // Find shortest path from current position to destination, using navNodes as waypoints path = Pathfinding.GetShortestPath(gameObject, destination); gui.SetPathfindingInfo(Pathfinding.nodes, path); // Check if path is valid if (path == null || path.Count == 0) { Debug.Log("Failed to find a valid path"); } // Set initial tolerance zone position userPos0 = user.transform.position - transform.position; userPos0.y = 0; // project onto the horizontal plane UpdateToleranceZone(); // Initialize tracking if (useTracking) { tracking = new Tracking(); droneCam = GameObject.Find("DroneCamera"); userHeight = user.GetComponent <Renderer>().bounds.size.y; } }