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; } }
void Awake() { input = GetComponent <ManualInput> (); Animator[] animators = GetComponentsInChildren <Animator> (); animator = animators[animators.Length - 1]; //OnMenuChange (); currentMenuIndex = 0; //currentMenuObj = this.transform.GetChild (0).gameObject; //MenuIndexRecord.Add(0); SetButtonList(); //currentMenu = GetComponent<Canvas>(); //currentTime = 0f; }
public void ResumeGame() { VirtualInputManager.Instance.ClearAllInputsInBuffer(); if (Player != null) { ManualInput input = Player.GetComponent <ManualInput> (); input.enabled = true; } Time.timeScale = 1.0f; if (CurrMainMenuObj != null) { CurrMainMenuObj.SetActive(false); } }
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 PauseGame() { if (Player != null) { ManualInput input = Player.GetComponent <ManualInput> (); input.enabled = false; } Time.timeScale = 0.0f; if (CurrMainMenuObj != null) { CurrMainMenuObj.SetActive(true); MenuController controller = CurrMainMenuObj.GetComponent <MenuController> (); controller.InitButtonList(); } }
public void Init() { animator = GetComponentInChildren <Animator> (); detector = GetComponentInChildren <TriggerDetector> (); controller = GetComponent <CharacterController> (); aiProgress = GetComponent <AIProgress> (); manualInput = GetComponent <ManualInput> (); ParticleSystemTag[] particleSystemTags = GetComponentsInChildren <ParticleSystemTag> (); foreach (ParticleSystemTag p in particleSystemTags) { if (p.tag == VFXType.Trail) { particleSystemTrail = p.GetComponent <ParticleSystem> (); particleSystemTrail.Pause(true); particleSystemTrail.Clear(); } else if (p.tag == VFXType.Hold) { particleSystemHold = p.GetComponent <ParticleSystem> (); particleSystemHold.Pause(true); particleSystemHold.Clear(); } } if (manualInput != null) { isPlayerControl = true; } else { isPlayerControl = false; } // load data process xxxx SetRagdollAndAttackingParts(); //this.CharacterData.OnDead += Dead; //this.CharacterData.OnDamage += Dead; if (aiProgress != null) { aiProgress.enabled = false; } if (manualInput != null) { manualInput.enabled = false; } }
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; } }