void Start() { cl = GetComponent <Collider> (); unitAgent parent = GetComponentInParent <unitAgent> (); Destroy(gameObject, destroyTimer); }
void groupSelection(Vector2 RectStart, Vector2 RectEnd, GameObject selected, int Type) { currentSelection.Clear(); if (debugActive) { Debug.Log("GROUP SELECT CALLED"); } Rect aimRect = new Rect(Mathf.Min(RectEnd.x, RectStart.x), Mathf.Min(RectEnd.y, RectStart.y), Mathf.Abs(RectEnd.x - RectStart.x), Mathf.Abs(RectEnd.y - RectStart.y)); foreach (GameObject Unit in unitsInPlay) { if (Unit != null) { Vector3 pos = Camera.main.WorldToScreenPoint(Unit.transform.position); //pos.y = Screen.height - pos.y; if (aimRect.Contains(pos)) { unitAgent logic = Unit.GetComponent <unitAgent> (); if (logic.playerID == playerID) { currentSelection.Add(Unit); } } } } if (debugActive) { Debug.Log("Units Selected"); } setUnitSelects(); }
// Use this for initialization void Start() { if (unitmgmt == null) { unitmgmt = GetComponentInParent <unitAgent> (); } }
void typeSelection(string type) { currentSelection.Clear(); if (debugActive) { Debug.Log("Type SELECT CALLED"); } Rect screenRect = new Rect(0, 0, Screen.width, Screen.height); foreach (GameObject Unit in unitsInPlay) { Vector3 pos = Camera.main.WorldToScreenPoint(Unit.transform.position); unitAgent mgmt = Unit.GetComponent <unitAgent> (); string mgType = mgmt._type.ToString(); if (screenRect.Contains(pos) && mgType == type) { currentSelection.Add(Unit); } } setUnitSelects(); if (debugActive) { Debug.Log("Units Selected"); } }
public void reCacheUnits(int ID) { miners.Clear(); mGuns.Clear(); missiles.Clear(); utilities.Clear(); idle_miners.Clear(); idle_mGuns.Clear(); idle_missiles.Clear(); idle_utilities.Clear(); foreach (GameObject unit in gManager.GetComponent <unitIndex>().units[playerID]) { if (unit != null) { unitAgent ai = unit.GetComponent <unitAgent> (); if (ai._type == unitAgent.Type.mGun) { mGuns.Add(unit); if (ai.onMission == false) { idle_mGuns.Add(unit); } } if (ai._type == unitAgent.Type.missile) { missiles.Add(unit); if (ai.onMission == false) { idle_missiles.Add(unit); } } if (ai._type == unitAgent.Type.miner) { miners.Add(unit); if (ai.onMission == false) { idle_miners.Add(unit); } } if (ai._type == unitAgent.Type.utility) { utilities.Add(unit); if (ai.onMission == false) { idle_utilities.Add(unit); } } } } }
// Use this for initialization void Start() { podsCount = cargoPods.Length; uLogic = GetComponentInParent <unitAgent> (); foreach (GameObject pod in cargoPods) { pod.SetActive(false); capacity = uLogic.rCapacity; } refresh = refreshRate; }
void unitSelection(GameObject selected, int ID) { currentSelection.Clear(); unitAgent logic = selected.GetComponent <unitAgent> (); if (logic.playerID == playerID) { currentSelection.Add(selected); } eventManager.SelectEvent(this.gameObject, playerID); if (debugActive) { Debug.Log("Units Selected"); } }
void miningEvent(int hitpoints, GameObject sender, GameObject reciever) { cutOff = false; if (reciever == this.gameObject) { unitAgent tempUnit = sender.GetComponent <unitAgent> (); if (tempUnit._type == unitAgent.Type.miner) { float rand = Random.Range(0, 10); if (rand < debrisRate) { GameObject temp = Instantiate(debris, transform.position, Random.rotation); debrisLogic tempLogic = temp.GetComponent <debrisLogic> (); tempLogic.Target = sender; temp.transform.parent = transform; Vector3 randScale = new Vector3(rand / debrisScale, rand / debrisScale, rand / debrisScale); temp.transform.localScale = temp.transform.localScale + randScale; } resourceValue = (resourceValue - hitpoints); if (resourceValue > 50) { transform.localScale -= new Vector3(0.02f, 0.02f, 0.02f); Debug.Log("Damage Recieved"); } if (resourceValue < 50 && resourceValue > 2) { //float mini = (float)hitpoints / resourceReset; int i = 1; transform.localScale -= new Vector3(0.03f, 0.03f, 0.03f); if (i == 1) { var myBounds = new GraphUpdateObject(GetComponent <Collider> ().bounds); AstarPath.active.UpdateGraphs(myBounds); i++; } } if (resourceValue <= 0) { onDamage(); onDeplete(); } } } }
// Use this for initialization void Start() { gManager = GameObject.Find("gameManager"); GameObject temp = GameObject.FindGameObjectWithTag("playerSeed"); playerID = temp.GetComponent <playerCommand>().playerID; List <GameObject> tempList = new List <GameObject>(); tempList.AddRange(GameObject.FindGameObjectsWithTag("Friendly")); foreach (GameObject unit in tempList) { unitAgent ai = unit.GetComponent <unitAgent> (); if (ai.playerID == playerID) { unitsInPlay.Add(unit); } } }
// Use this for initialization void Start() { manager = GetComponentInParent <unitAgent> (); text = GetComponent <TextMesh> (); }
// Use this for initialization void Start() { uLogic = GetComponentInParent <unitAgent> (); particles = GetComponent <ParticleSystem> (); ticker = startUp; }
/** Starts searching for paths. * If you override this function you should in most cases call base.Start () at the start of it. * \see OnEnable * \see RepeatTrySearchPath */ protected virtual void Start() { startHasRun = true; uLogic = GetComponent <unitAgent> (); OnEnable(); }