//setup void Awake() { if(transform.tag != "Enemy") { //add kinematic rigidbody if(!GetComponent<Rigidbody>()) gameObject.AddComponent<Rigidbody>(); GetComponent<Rigidbody>().isKinematic = true; GetComponent<Rigidbody>().useGravity = false; GetComponent<Rigidbody>().interpolation = RigidbodyInterpolation.Interpolate; } else { characterMotor = GetComponent<CharacterMotor>(); enemyAI = GetComponent<EnemyAI>(); } //get child waypoints, then detach them (so object can move without moving waypoints) foreach (Transform child in transform) if(child.tag == "Waypoint") waypoints.Add (child); foreach(Transform waypoint in waypoints) waypoint.parent = null; if(waypoints.Count == 0) Debug.LogError("No waypoints found for 'MoveToPoints' script. To add waypoints: add child gameObjects with the tag 'Waypoint'", transform); }
public void setIsland(GameObject Island) { myAIController = gameObject.AddComponent<EnemyAI>() as EnemyAI; myAIController._owner = this; myAIController.waypointContainer = Island; myAIController.InstantiatePath(); }
public override void Start() { _AI = GetComponent<EnemyAI>(); _groundCheck = transform.Find("GroundCheck"); _rigidbody2D = GetComponent<Rigidbody2D>(); _target = GetComponent<EnemyAI>().Target; }
/// <summary> /// When an enemy dies, if applicable duplicate the enemies on the spot that the enemy had died. /// </summary> /// <returns></returns> public virtual EnemyAI[] OnDeath() { EnemyAI[] duplicateEnemies = null; if (duplicates && !hasDuplicated) { health = maxHealth; duplicateEnemies = new EnemyAI[numDuplicates]; for (int i = 0; i < numDuplicates; i++) { Vector3 newPosition = transform.position - new Vector3(0.1f, 0.1f, 0); EnemyAI duplicate = (EnemyAI)GameObject.Instantiate(this, newPosition, transform.rotation); duplicate.transform.Rotate(Vector3.zero, 15 * i, Space.Self); duplicate.hasDuplicated = true; duplicate.health = maxHealth; duplicate.movementPoints = movementPoints; duplicate.transform.parent = transform.parent; duplicateEnemies[i] = duplicate; } } GameObject.Destroy(gameObject); return duplicateEnemies; }
public override void Handle(EnemyAI context) { if (context.playerIsFar()) context.State = new Idle(); else context.direction = (context.player.transform.position - context.transform.position).normalized; }
void Awake() { player = GameObject.FindGameObjectWithTag (Tags.player); pushedBack = 3; enemyAI = GetComponent<EnemyAI> (); rb = GetComponent<Rigidbody2D> (); sr = GetComponent<SpriteRenderer> (); }
public override void Handle(EnemyAI context) { if (context.playerIsClose()) context.State = new Pursuit (); else if (Physics.Raycast (context.transform.position, context.direction, 1.0f)) context.direction *= -1; }
void Start() { rb = GetComponent<Rigidbody2D>(); enemyAI = GetComponent<EnemyAI>(); nextWanderTime = Time.time + Random.Range(0f, 3f); colliderSize = GetComponent<BoxCollider2D>().size; mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>(); }
void Awake() { // Setting up the references. //nav = GetComponent<NavMeshAgent>(); col = GetComponent<SphereCollider>(); enemyAI = GetComponent<EnemyAI>(); //Player = GameObject.Find("Lokahi"); }
public bool ContainsEnemy(EnemyAI enemy) { bool containsEnemy = false; PolygonCollider2D box = enemy.gameObject.GetComponent<PolygonCollider2D>(); if (gameObject.GetComponent<Renderer>().bounds.Intersects(box.bounds)) { containsEnemy = true; } return containsEnemy; }
// public delegate void ActivateNearBear(); // public static event ActivateNearBear TurnNearBearTrue; // public delegate void DeactivateNearBear(); // public static event DeactivateNearBear TurnNearBearFalse; // Use this for initialization void Start() { enemyAI = gameObject.GetComponentInParent<EnemyAI> (); //animEnemy = GetComponent<Animator> (); animEnemy = gameObject.GetComponentInParent<Animator> (); //anim.SetTrigger("stand"); animEnemy.SetInteger ("AnimState", 0); //rb2DenemyWolf = gameObject.transform.parent.gameObject.GetComponent<Rigidbody2D>(); //rb2DenemyWolf = gameObject.GetComponentInParent<Rigidbody2D> (); //speed = attackSpeed; }
// Use this for initialization void Start() { PlayerRounds = 0; EnemyRounds = 0; PlayerEmptyRound = GameObject.FindGameObjectWithTag("PlayerEmptyRound"); PlayerEmptyRoundTwo = GameObject.FindGameObjectWithTag("PlayerEmptyRoundTwo"); EnemyEmptyRound = GameObject.FindGameObjectWithTag("EnemyEmptyRound"); EnemyEmptyRound = GameObject.FindGameObjectWithTag("EnemyEmptyRoundTwo"); _playerManager = GetComponent<PlayerManager>(); _enemyAI = GetComponent<EnemyAI>(); }
public IEnumerator SummonEnemy(EnemyAI enemy) { enemy.gameObject.SetActive(false); enemy.SetCoordinates(x, y); enemy.MovePosition(x, y); yield return new WaitForSeconds(1.0f); gameObject.SetActive(true); yield return new WaitForSeconds(1.0f); enemy.gameObject.SetActive(true); gameObject.SetActive(false); }
void Start() { Enemyhealth = gameObject.GetComponent<EnemyAI>(); // username = savegame.txtUsername; Debug.Log (PlayerPrefs.GetString ("un")); Debug.Log( PlayerPrefs.GetString ("Load")+" on enemies"); if (PlayerPrefs.GetString ("Load") != "") { LoadEnemy(); } }
// Gets the group of enemies ready to be controlled public override void start(EnemyAI[] enemies, GameObject target) { m_EnemyGroup = enemies; m_Target = target; for (int i = 0; i < m_EnemyGroup.Length; i++) { // Stop all the enemies in the group from updating their movement ad targeting m_EnemyGroup[i].m_UMovement = false; //m_EnemyGroup[i].m_UTargeting = false; // Make sure all their states are set to attack m_EnemyGroup[i].SetState(EnemyAI.EnemyState.Attack); } }
// Use this for initialization void Start() { //Always want to start with the enemy alive isDead = false; try { flashTimer = gameObject.AddComponent<Timer>(); flashTimer.initialize(.1f, false); self = transform.GetComponent<Enemy>(); enemyAI = transform.GetComponent<EnemyAI>(); } catch { } }
// public EnemyCaptive( ISoldier theSoldier, Vector3 AttackPos) { m_emEnemyType = ENUM_Enemy.Catpive; m_Captive = theSoldier; // 設定成像 SetGameObject( theSoldier.GetGameObject() ); // 將Soldier數值轉成Enemy用的 EnemyAttr tempAttr = new EnemyAttr(); SetCharacterAttr( tempAttr ); // 設定武器 SetWeapon( theSoldier.GetWeapon() ); // 更改為SoldierAI m_AI = new EnemyAI( this, AttackPos ); m_AI.ChangeAIState( new IdleAIState() ); }
public void setUp(Transform newModel, Transform newUpperBody) { model = newModel; upperBody = newUpperBody; enemyController = GetComponent<EnemyController>(); enemyAI = GetComponent<EnemyAI>(); if (model.animation["Idle01"]) { model.animation["Idle01"].wrapMode = WrapMode.Once; model.animation["Idle01"].layer = 1; } if (model.animation["Walk"]) { model.animation["Walk"].wrapMode = WrapMode.Once; model.animation["Walk"].layer = 1; model.animation["Walk"].speed = 0.75f; } if (model.animation["Run"]) { model.animation["Run"].wrapMode = WrapMode.Once; model.animation["Run"].layer = 1; model.animation["Run"].speed = 1.25f; } if (model.animation["LookAround"]) { model.animation["LookAround"].wrapMode = WrapMode.Once; model.animation["LookAround"].layer = 2; } if (model.animation["GetUp"]) { model.animation["GetUp"].wrapMode = WrapMode.Once; model.animation["GetUp"].layer = 2; } if (model.animation["PullGun"]) { model.animation["PullGun"].wrapMode = WrapMode.ClampForever; model.animation["PullGun"].layer = 2; model.animation["PullGun"].AddMixingTransform(upperBody); } }
public void Init(int enemyID) { data = DataManager.Instance.GetEnemyDataSet ().GetEnemyData (enemyID).Clone(); enemyData = data as EnemyData; isEnemy = true; UIEvent = this.GetComponent<BattleObjectUIEvent>(); UIEvent.Init(enemyData.imageID); UIEvent.InitEnemyHPBar(maxHP, data.battleType); currentHP = maxHP; AI = this.GetComponent<EnemyAI>(); AI.InitAI(enemyData.aiID); for(int i = 0; i < data.bornBuffs.Count; i++) { AddBuff(data.bornBuffs[i], -1);//添加固有BUFF } SkillHelper.CheckWeaponBuff(this); MessageEventArgs args = new MessageEventArgs(); args.AddMessage("Object", this); EventManager.Instance.PostEvent(BattleEvent.OnEnemySpawn, args); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateinfo, int layerIndex) { enemyAI = animator.gameObject.GetComponent <EnemyAI>(); }
public void Next() { bool anydead = false; SetupBattle setup = (SetupBattle)setupbattle.GetComponent("SetupBattle"); if (endbattletext == true) { EndBattle(); } if (allenemiesdead == true) { commentarytext.text = "You gained " + exppool.ToString() + " experience pts."; endbattletext = true; } if (setup.numenemies == 1) { if (enemy1 != null) { EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); if (enem1.dead == true) { exppool += enem1.expgain; anydead = true; enemy1 = null; allenemiesdead = true; } } } if (setup.numenemies == 2) { if (enemy1 != null) { EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); if (enem1.dead == true) { exppool += enem1.expgain; anydead = true; enemy1 = null; } } if (enemy2 != null) { EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI"); if (enem2.dead == true) { exppool += enem2.expgain; anydead = true; enemy2 = null; } } if (enemy1 == null && enemy2 == null) { allenemiesdead = true; } } if (setup.numenemies == 3) { if (enemy1 != null) { EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); if (enem1.dead == true) { exppool += enem1.expgain; anydead = true; enemy1 = null; } } if (enemy2 != null) { EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI"); if (enem2.dead == true) { exppool += enem2.expgain; anydead = true; enemy2 = null; } } if (enemy3 != null) { EnemyAI enem3 = (EnemyAI)enemy3.GetComponent("EnemyAI"); if (enem3.dead == true) { exppool += enem3.expgain; anydead = true; enemy3 = null; } } if (enemy1 == null && enemy2 == null && enemy3 == null) { allenemiesdead = true; } } if (anydead == true) { if (firstperson != player && firstperson != null) { EnemyAI enem = (EnemyAI)firstperson.GetComponent("EnemyAI"); if (enem.dead == true) { if (deadenemy1 == null) { deadenemy1 = firstperson; } else { if (deadenemy2 == null) { deadenemy2 = firstperson; } else { deadenemy3 = firstperson; } } commentarytext.text = enem.enemyname + " has died."; SpriteRenderer enemysprite = firstperson.GetComponent <SpriteRenderer> (); enemysprite.sprite = null; enem.curhealth = 1; enem.active = false; if (setup.numenemies == 1) { firstperson = secondperson; secondperson = null; } if (setup.numenemies == 2) { firstperson = secondperson; secondperson = thirdperson; thirdperson = null; } if (setup.numenemies == 3) { firstperson = secondperson; secondperson = thirdperson; thirdperson = fourthperson; fourthperson = null; } } } if (secondperson != player && secondperson != null) { EnemyAI enem = (EnemyAI)secondperson.GetComponent("EnemyAI"); if (enem.dead == true) { if (deadenemy1 == null) { deadenemy1 = secondperson; } else { if (deadenemy2 == null) { deadenemy2 = secondperson; } else { deadenemy3 = secondperson; } } commentarytext.text = enem.enemyname + " has died."; SpriteRenderer enemysprite = secondperson.GetComponent <SpriteRenderer> (); enemysprite.sprite = null; enem.curhealth = 1; enem.active = false; if (setup.numenemies == 1) { secondperson = null; } if (setup.numenemies == 2) { secondperson = thirdperson; thirdperson = null; } if (setup.numenemies == 3) { secondperson = thirdperson; thirdperson = fourthperson; fourthperson = null; } } } if (thirdperson != player && thirdperson != null) { EnemyAI enem = (EnemyAI)thirdperson.GetComponent("EnemyAI"); if (enem.dead == true) { if (deadenemy1 == null) { deadenemy1 = thirdperson; } else { if (deadenemy2 == null) { deadenemy2 = thirdperson; } else { deadenemy3 = thirdperson; } } commentarytext.text = enem.enemyname + " has died."; SpriteRenderer enemysprite = thirdperson.GetComponent <SpriteRenderer> (); enemysprite.sprite = null; enem.curhealth = 1; enem.active = false; if (setup.numenemies == 1) { } if (setup.numenemies == 2) { thirdperson = null; } if (setup.numenemies == 3) { thirdperson = fourthperson; fourthperson = null; } } } if (fourthperson != player && fourthperson != null) { EnemyAI enem = (EnemyAI)fourthperson.GetComponent("EnemyAI"); if (enem.dead == true) { if (deadenemy1 == null) { deadenemy1 = fourthperson; } else { if (deadenemy2 == null) { deadenemy2 = fourthperson; } else { deadenemy3 = fourthperson; } } commentarytext.text = enem.enemyname + " has died."; SpriteRenderer enemysprite = fourthperson.GetComponent <SpriteRenderer> (); enemysprite.sprite = null; enem.curhealth = 1; enem.active = false; if (setup.numenemies == 1) { } if (setup.numenemies == 2) { } if (setup.numenemies == 3) { fourthperson = null; } } } } else { if (allenemiesdead == false && endbattletext == false) { NextPerson(); } } }
public void Optionmagic(GameObject attack) { Attacks att = (Attacks)attack.GetComponent("Attacks"); PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle"); if (pbattle.curmana >= att.manacost) { SetupBattle setup = (SetupBattle)setupbattle.GetComponent("SetupBattle"); thisturnattack = attack; if (setup.numenemies == 1) { selectbutton1.SetActive(false); selectbutton2.SetActive(false); selectbutton3.SetActive(false); selectbutton4.SetActive(false); selectbutton5.SetActive(false); enemyhealthbar1.SetActive(false); enemyhealthbar2.SetActive(false); enemyhealthbar3.SetActive(false); enemyhealthbar4.SetActive(false); enemyhealthbar5.SetActive(false); if (enemy1 != null) { selectbutton3.SetActive(true); EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); enem1.ChooseAttack(); enemyhealthbar3.SetActive(true); } } if (setup.numenemies == 2) { selectbutton1.SetActive(false); selectbutton2.SetActive(false); selectbutton3.SetActive(false); selectbutton4.SetActive(false); selectbutton5.SetActive(false); enemyhealthbar1.SetActive(false); enemyhealthbar2.SetActive(false); enemyhealthbar3.SetActive(false); enemyhealthbar4.SetActive(false); enemyhealthbar5.SetActive(false); if (enemy1 != null) { selectbutton2.SetActive(true); EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); enem1.ChooseAttack(); enemyhealthbar2.SetActive(true); } if (enemy2 != null) { selectbutton4.SetActive(true); EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI"); enem2.ChooseAttack(); enemyhealthbar4.SetActive(true); } } if (setup.numenemies == 3) { selectbutton1.SetActive(false); selectbutton2.SetActive(false); selectbutton3.SetActive(false); selectbutton4.SetActive(false); selectbutton5.SetActive(false); enemyhealthbar1.SetActive(false); enemyhealthbar2.SetActive(false); enemyhealthbar3.SetActive(false); enemyhealthbar4.SetActive(false); enemyhealthbar5.SetActive(false); if (enemy1 != null) { selectbutton1.SetActive(true); EnemyAI enem1 = (EnemyAI)enemy1.GetComponent("EnemyAI"); enem1.ChooseAttack(); enemyhealthbar1.SetActive(true); } if (enemy2 != null) { selectbutton3.SetActive(true); EnemyAI enem2 = (EnemyAI)enemy2.GetComponent("EnemyAI"); enem2.ChooseAttack(); enemyhealthbar3.SetActive(true); } if (enemy3 != null) { selectbutton5.SetActive(true); EnemyAI enem3 = (EnemyAI)enemy3.GetComponent("EnemyAI"); enem3.ChooseAttack(); enemyhealthbar5.SetActive(true); } } } }
public void registerNewEnemy(GameObject newEnemy, EnemyAI ai) { enemyList.Add(new EnemyInfo(newEnemy, ai)); }
public abstract void OnStateExit(EnemyAI enemyAI);
public abstract void OnStateEnter(EnemyAI enemyAI);
override public void Enter(EnemyAI enemyAi) { state = (int)State.TRACE; }
/// <summary> /// Sends the enemy attack. /// </summary> /// <param name="enemyId">The enemy identifier.</param> /// <param name="prefabName">Name of the prefab.</param> /// <param name="teamId">The team identifier.</param> /// <param name="spawnerId">The spawner identifier.</param> /// <param name="enemy">The enemy.</param> public void SendEnemyAttack(int enemyId, string prefabName, int teamId, int spawnerId, EnemyAI enemy) { enemies.Add(enemyId, enemy); netAdapter.Send((int)MessageType.SendEnemy, enemyId.ToString(), prefabName, teamId.ToString(), spawnerId.ToString(), username); UpdateLastCommunicationWithServer(); }
void Start() { // Reference to EnemyAI script this.enemyAI = this.GetComponent <EnemyAI>(); }
void Awake() { target = null; enemyPosition = transform; enemyBrain = gameObject.GetComponent<EnemyAI>(); }
void Start() { enemy = this.gameObject.GetComponent <EnemyAI>(); anim = this.gameObject.GetComponent <Animator>(); }
public WanderAIState(EnemyAI _Owner) : base(_Owner) { Type = StateType.Wander; }
public KiteAIState(EnemyAI _Owner) : base(_Owner) { Owner.attackTimer = Time.time + Owner.timeBetweenAttacks; Type = StateType.Kite; }
public EnemyPatrolState(EnemyAI fighterRef) { _stateName = "PatrolState"; _fighterRef = fighterRef; }
public SearchState(EnemyAI enemyAI, float timeNotSeen, Vector3 positionSeen) { this.enemyAI = enemyAI; this.timeNotSeen = timeNotSeen; this.positionSeen = positionSeen; }
public void SetAI(EnemyAI newAI) { AI = newAI; }
public void Start() { enemyAI = GetComponent <EnemyAI>(); }
public abstract void OnStateUpdate(EnemyAI enemyAI);
// Use this for initialization void Start() { _anim = GetComponent <Animator>(); _EnemyAI = GetComponent <EnemyAI>(); }
public EnemyInfo(GameObject obj, EnemyAI ai) { this.obj = obj; this.ai = ai; }
public void InitializeStuff() { //Initialize Canvas items... GameObject canvas = GameObject.FindGameObjectWithTag (Tags.canvas); Text[] allText = canvas.GetComponentsInChildren<Text> (); foreach (Text txt in allText){ if(txt.tag == Tags.dialogueText){ dialogueTextField = txt; } else if(txt.tag == Tags.characterNameText){ characterNameText = txt; } } Scrollbar[] allScrollBars = canvas.GetComponentsInChildren<Scrollbar> (); foreach (Scrollbar sb in allScrollBars){ if(sb.tag == Tags.scrollBar){ scrollBar = sb; } } //Initialize particle system for Interaction Indicator... indicatorParticleSystem = GetComponentInChildren<ParticleSystem> (); cursorGO = GameObject.FindGameObjectWithTag (Tags.cursor); //Initialize interaction collider on awake... col = GetComponent<SphereCollider>(); SetColliderPosition (); //Parse the text file into the array, dialogueTextParsed... dialogueTextParsed = dialogueText.text.Split('\n'); if(messageIsUrgent && !noMessageJustMove){ indicatorParticleSystem.Play (); } playerTransform = GameObject.FindGameObjectWithTag (Tags.player).transform; playerRB = playerTransform.GetComponent<Rigidbody>(); //Initialize NPC NavMeshAgent and EnemyAI... nav = gameObject.GetComponentInParent<NavMeshAgent> (); enemyAI = gameObject.GetComponentInParent<EnemyAI> (); //Get interaction rate from Player.. interactionRate = GameObject.FindGameObjectWithTag (Tags.player).GetComponent<PlayerInteraction> ().interactionRate; //Get animator info... animatorArrayNPC = transform.parent.GetComponentsInChildren<Animator> (); //Initialize dialoguePanelOpenClose... dialoguePanelOpenClose = canvas.GetComponentInChildren<DialoguePanelOpenClose> (); }
// Start is called before the first frame update void Start() { parent = GetComponentInParent <EnemyAI>(); }
void Start() { charStat = GetComponentInParent<CharacterStats>(); enAi = GetComponentInParent<EnemyAI>(); }
// Use this for initialization void Start() { commentarygui.SetActive(false); choicesgui.SetActive(true); option1gui.SetActive(true); optionattackgui.SetActive(false); optionmagicgui.SetActive(false); selectbutton1.SetActive(false); selectbutton2.SetActive(false); selectbutton3.SetActive(false); selectbutton4.SetActive(false); selectbutton5.SetActive(false); selectbutton22.SetActive(false); backbutton.SetActive(false); enemyhealthbar1.SetActive(false); enemyhealthbar2.SetActive(false); enemyhealthbar3.SetActive(false); enemyhealthbar4.SetActive(false); enemyhealthbar5.SetActive(false); playervars = GameObject.FindGameObjectWithTag("Walk To Battle"); player = GameObject.FindGameObjectWithTag("Player"); SetupBattle setup = (SetupBattle)setupbattle.GetComponent("SetupBattle"); enemy1 = setup.enemy1; enemy2 = setup.enemy2; enemy3 = setup.enemy3; setup.attack1button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack1)); setup.attack2button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack2)); setup.attack3button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack3)); setup.attack4button.GetComponent <Button> ().onClick.AddListener(() => Optionattack(setup.attack4)); setup.magic1button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic1)); setup.magic2button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic2)); setup.magic3button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic3)); setup.magic4button.GetComponent <Button> ().onClick.AddListener(() => Optionmagic(setup.magic4)); PLayerBattle pbattle = (PLayerBattle)player.GetComponent("PLayerBattle"); if (setup.numenemies == 1) { EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI"); if (enem1stats.speed >= pbattle.speed) { firstperson = enemy1; secondperson = player; } else { firstperson = player; secondperson = enemy1; } } if (setup.numenemies == 2) { EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI"); EnemyAI enem2stats = (EnemyAI)enemy2.GetComponent("EnemyAI"); if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed) { firstperson = player; if (enem1stats.speed >= enem2stats.speed) { secondperson = enemy1; thirdperson = enemy2; } else { secondperson = enemy2; thirdperson = enemy1; } } if (enem1stats.speed >= pbattle.speed && enem1stats.speed >= enem2stats.speed) { firstperson = enemy1; if (pbattle.speed >= enem2stats.speed) { secondperson = player; thirdperson = enemy2; } else { secondperson = enemy2; thirdperson = player; } } if (enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem1stats.speed) { firstperson = enemy2; if (pbattle.speed >= enem1stats.speed) { secondperson = player; thirdperson = enemy1; } else { secondperson = enemy1; thirdperson = player; } } } if (setup.numenemies == 3) { EnemyAI enem1stats = (EnemyAI)enemy1.GetComponent("EnemyAI"); EnemyAI enem2stats = (EnemyAI)enemy2.GetComponent("EnemyAI"); EnemyAI enem3stats = (EnemyAI)enemy3.GetComponent("EnemyAI"); if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed && pbattle.speed >= enem3stats.speed) { firstperson = player; if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed) { secondperson = enemy1; if (enem2stats.speed >= enem3stats.speed) { thirdperson = enemy2; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = enemy2; } } if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= enem3stats.speed) { secondperson = enemy2; if (enem1stats.speed >= enem3stats.speed) { thirdperson = enemy1; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = enemy1; } } if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= enem2stats.speed) { secondperson = enemy3; if (enem1stats.speed >= enem2stats.speed) { thirdperson = enemy1; fourthperson = enemy2; } else { thirdperson = enemy2; fourthperson = enemy1; } } } if (enem1stats.speed >= pbattle.speed && enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed) { firstperson = enemy1; if (pbattle.speed >= enem2stats.speed && pbattle.speed >= enem3stats.speed) { secondperson = player; if (enem2stats.speed >= enem3stats.speed) { thirdperson = enemy2; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = enemy2; } } if (enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem3stats.speed) { secondperson = enemy2; if (pbattle.speed >= enem3stats.speed) { thirdperson = player; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = player; } } if (enem3stats.speed >= pbattle.speed && enem3stats.speed >= enem2stats.speed) { secondperson = enemy3; if (pbattle.speed >= enem2stats.speed) { thirdperson = player; fourthperson = enemy2; } else { thirdperson = enemy2; fourthperson = player; } } } if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= pbattle.speed && enem2stats.speed >= enem3stats.speed) { firstperson = enemy2; if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= enem3stats.speed) { secondperson = enemy1; if (pbattle.speed >= enem3stats.speed) { thirdperson = player; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = player; } } if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem3stats.speed) { secondperson = player; if (enem1stats.speed >= enem3stats.speed) { thirdperson = enemy1; fourthperson = enemy3; } else { thirdperson = enemy3; fourthperson = enemy1; } } if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= pbattle.speed) { secondperson = enemy3; if (enem1stats.speed >= pbattle.speed) { thirdperson = enemy1; fourthperson = player; } else { thirdperson = player; fourthperson = enemy1; } } } if (enem3stats.speed >= enem1stats.speed && enem3stats.speed >= enem2stats.speed && enem3stats.speed >= pbattle.speed) { firstperson = enemy3; if (enem1stats.speed >= enem2stats.speed && enem1stats.speed >= pbattle.speed) { secondperson = enemy1; if (enem2stats.speed >= pbattle.speed) { thirdperson = enemy2; fourthperson = player; } else { thirdperson = player; fourthperson = enemy2; } } if (enem2stats.speed >= enem1stats.speed && enem2stats.speed >= pbattle.speed) { secondperson = enemy2; if (enem1stats.speed >= pbattle.speed) { thirdperson = enemy1; fourthperson = player; } else { thirdperson = player; fourthperson = enemy1; } } if (pbattle.speed >= enem1stats.speed && pbattle.speed >= enem2stats.speed) { secondperson = player; if (enem1stats.speed >= enem2stats.speed) { thirdperson = enemy1; fourthperson = enemy2; } else { thirdperson = enemy2; fourthperson = enemy1; } } } } commentarygui.SetActive(false); }
void Setup(Scene scene, LoadSceneMode mode) { endGamePanel = GameObject.FindGameObjectWithTag("End"); changePuck = FindObjectOfType <ChangePuck>(); textControl = FindObjectOfType <TextControl>(); won = false; textControl.SpritesOfNumbers[5] = textControl.RoundSprites[roundNumber]; if (NewGame.mode == NewGame.GameMode.Singleplayer) { markBehaviour = FindObjectsOfType <MarkBehaviour>(); enemyShootPuck = FindObjectOfType <EnemyShootPuck>(); shootPuck = FindObjectOfType <ShootPuck>(); enemyAI = FindObjectOfType <EnemyAI>(); } else if (NewGame.mode == NewGame.GameMode.LocalMultiplayer) { markBehaviour = FindObjectsOfType <MarkBehaviour>(); localShootPuck = FindObjectsOfType <ShootPuck>(); } switch (winner) { case Winner.Player: playerWins++; winner = Winner.None; if (playerWins == 2) { endGamePanel.SetActive(true); text = endGamePanel.GetComponentInChildren <Text>(); textControl.gameObject.SetActive(false); markBehaviour[0].enabled = false; markBehaviour[1].enabled = false; shootPuck.enabled = false; enemyAI.enabled = false; enemyShootPuck.enabled = false; for (int i = 0; i < endGamePanel.transform.childCount; ++i) { endGamePanel.transform.GetChild(i).gameObject.SetActive(true); } text.text = "Player Wins"; } break; case Winner.Enemy: enemyWins++; winner = Winner.None; if (enemyWins == 2) { markBehaviour[0].enabled = false; markBehaviour[1].enabled = false; enemyAI.enabled = false; shootPuck.enabled = false; enemyShootPuck.enabled = false; endGamePanel.SetActive(true); textControl.gameObject.SetActive(false); for (int i = 0; i < endGamePanel.transform.childCount; ++i) { endGamePanel.transform.GetChild(i).gameObject.SetActive(true); } text = endGamePanel.GetComponentInChildren <Text>(); text.text = "Enemy Wins"; } break; case Winner.Player1: player1Wins++; winner = Winner.None; if (player1Wins == 2) { markBehaviour[0].enabled = false; markBehaviour[1].enabled = false; localShootPuck[0].enabled = false; localShootPuck[1].enabled = false; endGamePanel.SetActive(true); textControl.gameObject.SetActive(false); for (int i = 0; i < endGamePanel.transform.childCount; ++i) { endGamePanel.transform.GetChild(i).gameObject.SetActive(true); } text = endGamePanel.GetComponentInChildren <Text>(); text.text = "Player right wins"; } break; case Winner.Player2: player2Wins++; winner = Winner.None; if (player2Wins == 2) { markBehaviour[0].enabled = false; markBehaviour[1].enabled = false; localShootPuck[0].enabled = false; localShootPuck[1].enabled = false; endGamePanel.SetActive(true); textControl.gameObject.SetActive(false); for (int i = 0; i < endGamePanel.transform.childCount; ++i) { endGamePanel.transform.GetChild(i).gameObject.SetActive(true); } text = endGamePanel.GetComponentInChildren <Text>(); text.text = "Player left Wins"; } break; } }
private void Start() { _enemyAi = GetComponent <EnemyAI>(); }
private void NotifyMouseOverEnemyObservers(EnemyAI enemy) { notifyMouseOverEnemy(enemy); }
private void Start() { playerResources = GetComponent <PlayerResources>(); playerResources.SetHealth(100); enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyAI>(); }
// Use this for initialization void Start() { stat = GetComponent <StatContol>(); agent = gameObject.GetComponent <NavMeshAgent>(); enemyAI = gameObject.GetComponent <EnemyAI>(); }
void Start() { eA = this.GetComponent <EnemyAI>(); anim = this.GetComponentInChildren <Animator>(); pm = player.GetComponent <playerMovement>(); }
// Use this for initialization void Start() { emc = GetComponent <EnemyMovementController>(); ai = GetComponent <EnemyAI>(); esc = GetComponent <EnemyStaggerController>(); }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); ai = gameObject.GetComponent <EnemyAI> (); }
override public void Exit(EnemyAI enemyAi) { Destroy(this); }
private void Awake() { ai = transform.parent.gameObject.GetComponent <EnemyAI>(); }
private void OnTriggerEnter2D(Collider2D col) { // was the collider hit an enemy? if (col.tag == "Enemy") { // grab the enemies stats EnemyStats targetStatsScript = col.transform.parent.GetComponent <EnemyStats>(); // make a ref to the script on the enemy EnemyAI script = col.transform.parent.GetComponent <EnemyAI>(); // check to see if he had stats if (targetStatsScript != null && script != null) { // if he still has health left if (targetStatsScript.MyCurrentHealth > 0) { // play the impact particles that belongs to this enemy ParticleSystemHolder.instance.PlayImpactEffect(col.transform.parent.name + "_impact", transform.position); // if this projectile is not a sword if ((int)projectileType == 0) { // increment the amount of arrows that have hit the enemy script.ProjectileWoundGraphics(arrowType); } // Chanage the behaviour of the enemy because he has been hit script.HyperAlert(); // does this projectile have the ability to knock things back? if (knockBack) { // create a direction Vector3 dir = col.transform.position - PlayerController.instance.transform.position; // normalize the direction to give it magnitude of 1 dir = dir.normalized; // call the knockback method in the direction script.Knockback(dir); } // if this is NOT a max charged hit if (!PlayerController.instance.maxChargedHit) { // stop the projectile from moving any further rigid.isKinematic = true; rigid.velocity = Vector2.zero; // disable the projectile collider so it cannot hit anything else myCollider.enabled = false; // make the arrow invisible projectileSpriteRenderer.enabled = false; // make the enemy take the damage targetStatsScript.TakeDamage(playerStats.damage.GetValue()); } // if it is a charged hit let the arrow penetrate all enemies else if (PlayerController.instance.maxChargedHit) { // make the enemy take the damage targetStatsScript.TakeDamage(playerStats.damage.GetValue()); } } } } else if (col.tag == "ProjectileSurface") { SoundManager.instance.PlayCombatSound("hit_wall"); rigid.isKinematic = true; myCollider.enabled = false; rigid.velocity = Vector2.zero; foreach (var impact in impacts) { if (impact.name == "ArrowImpact") { impact.Play(); } } if (col.gameObject.GetComponent <Destructable>() != null) { Destructable des = col.gameObject.GetComponent <Destructable>(); des.Impact(); if (des.MyHealth < 0) { Destroy(); } } } else if (col.tag == "TargetBrick") { SoundManager.instance.PlayCombatSound("hit_wall"); rigid.isKinematic = true; myCollider.enabled = false; rigid.velocity = Vector2.zero; foreach (var impact in impacts) { if (impact.name == "ArrowImpact") { impact.Play(); } } if (col.gameObject.GetComponent <TargetBrick>() != null) { TargetBrick target = col.gameObject.GetComponent <TargetBrick>(); target.Impact(); } transform.parent = col.gameObject.transform; } }
//private enemyController enemyController; void Start () { EnemyAI =gameObject.GetComponentInParent<EnemyAI>(); // referencing the enemy script }
// Sniper State constructor, is called upon when this object is instantiated. also calls base(baseAIState) constructor // so grab the enemy this script is now attatched too. public SniperState(EnemyAI obj) : base(obj.gameObject) { _obj = obj; }
void Awake() { enemyAI = GetComponent<EnemyAI>(); enemyDeath = GetComponent<EnemyDeath>(); }
public AlertState(EnemyAI enemy) { myEnemy = enemy; }
public bool CanSeeEnemy(EnemyAI enemy) { Vector3 toEnemy = enemy.transform.position - transform.position; return (enemy.transform.position - transform.position).sqrMagnitude < squaredGuardRange && Physics2D.Raycast(transform.position, toEnemy, toEnemy.magnitude, LayerMasks.WallLayerMask).transform == null; }
void Shoot(EnemyAI shootingTarget) { GameObject bullet = Instantiate(bulletPrefab, transform.position, Quaternion.identity); bullet.GetComponent <Bullet>().Init(shootingTarget); }