public void FindTarget() { if (Time.time - lastFindTargetTime > aquisitionInterval) { //GameObject player = (FindObjectOfType (typeof (ManualInput)) as ManualInput).gameObject; ManualInput playerObjManu = FindObjectOfType(typeof(ManualInput)) as ManualInput; if (playerObjManu != null && this.enabled == true) { enemyTarget = playerObjManu.GetComponent <CharacterControl> (); if (IsTargetVisible() && enemyTarget.CharacterData.Team != team) { pathFindingAgent.SetTarget(enemyTarget.gameObject.transform); //Debug.Log ("Find player!"); CameraManager.Instance.AddToTargetGroup(aiUnit); RegisterTargetActionEvent(enemyTarget); } else { CameraManager.Instance.RemoveFromTargetGroup(aiUnit); DeregisterTargetActionEvent(enemyTarget); enemyTarget = null; } lastFindTargetTime = Time.time; } else { Task.current.Fail(); } } Task.current.Complete(enemyTarget != null); }
public void Init() { ManualInput playerObjManu = FindObjectOfType(typeof(ManualInput)) as ManualInput; if (playerObjManu != null) { CharacterControl playerControl = playerObjManu.GetComponent <CharacterControl> (); data = playerControl.CharacterData; BarImage[] barImages = this.GetComponentsInChildren <BarImage> (); foreach (BarImage im in barImages) { if (im.type == BarImageType.Bound) { BarBound = im.GetComponent <Image> (); } else if (im.type == BarImageType.Fill) { BarFill = im.GetComponent <Image> (); } } Count = this.GetComponentInChildren <TextMeshProUGUI> (); BarBoundAnim = BarBound.GetComponent <Animator> (); playerControl.CharacterData.OnEnergyChange += EnergyChange; playerControl.CharacterData.OnEnergyTake += PlayTakeEnergy; playerControl.CharacterData.OnEnergyNotEnough += PlayNotEnoughEnergy; playerControl.CharacterData.OnEnergyGet += PlayGetEnergy; } }
public void RegisterAllUnit() { ManualInput playerInput = null; if (Player == null) { playerInput = FindObjectOfType(typeof(ManualInput)) as ManualInput; Player = playerInput.GetComponent <CharacterControl> (); } playerInput = Player.GetComponent <ManualInput> (); playerInput.enabled = true; AIAgentManager.Instance.RegisterAllEnemies(); }
public void RegisterDamageEvent() { //Debug.Log ("register damage event!"); ManualInput playerObjManu = FindObjectOfType(typeof(ManualInput)) as ManualInput; if (playerObjManu != null) { CharacterControl player = playerObjManu.GetComponent <CharacterControl> (); /* * foreach(Delegate exist in aiUnit.CharacterData.OnDamage.GetInvocationList()) * { * if(player.OnEnemyGetDamaged == exist) * return; * } */ aiUnit.CharacterData.OnDamage -= player.OnEnemyGetDamaged; aiUnit.CharacterData.OnDamage += player.OnEnemyGetDamaged; aiUnit.CharacterData.OnDead -= GameManager.Instance.OnUnitDead; aiUnit.CharacterData.OnDead += GameManager.Instance.OnUnitDead; } }