// Use this for initialization protected override void Start() { base.Start(); currentState = State.Idle; hasTarget = GameObject.FindWithTag("Player") != null; if (hasTarget) { target = GameObject.FindWithTag("Player").transform; targetEntity = target.GetComponent<LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; pathFinder = GetComponent<NavMeshAgent>(); currentState = State.Chasing; StartCoroutine(UpdatePath()); myColliderRadius = GetComponent<CapsuleCollider>().radius; targetColliderRadius = target.GetComponent<CapsuleCollider>().radius; skinMaterial = GetComponent<Renderer>().material; originalColor = skinMaterial.color; } }
protected override void Start() { base.Start (); //nextAttackTime = Time.time; currentState = State.Chasing; mPathFinder = GetComponent<NavMeshAgent> (); skinMaterial = GetComponent<Renderer> ().material; GameObject player = GameObject.FindGameObjectWithTag ("Player"); if (player) { hasTarget = true; target = player.transform; targetEntity = target.GetComponent<LivingEntity> (); targetEntity.OnDeath += OnTargetDeath; //mTargetCollisionRadius = target.GetComponent<CapsuleCollider> ().radius; mTargetCollisionRadius = target.GetComponent<CharacterController> ().radius; mCollisionRadius = GetComponent<CapsuleCollider> ().radius; StartCoroutine (UpdatePath ()); } }
void Start() { playerEntity = FindObjectOfType<Player> (); playerT = playerEntity.transform; nextCampCheckTime = timeBetweenCampingChecks + Time.time; campPositionOld = playerT.position; playerEntity.OnDeath += OnPlayerDeath; map = FindObjectOfType<MapGenerator> (); NextWave (); }
void Awake() { pathfinder = GetComponent<NavMeshAgent> (); if (GameObject.FindGameObjectWithTag ("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag ("Player").transform; targetEntity = target.GetComponent<LivingEntity> (); myCollisionRadius = GetComponent<CapsuleCollider> ().radius; targetCollisionRadius = target.GetComponent<CapsuleCollider> ().radius; } }
void Start() { player = FindObjectOfType<Player>(); pt = player.transform; player.OnDeath += OnPlayerDeath; nextCampCheckTime = timeBetweenCampChecks + Time.time; campPosOld = pt.position; map = FindObjectOfType<MapGenerator>(); NextWave(); }
void OnWaveEnd() { if (doctorSpecialisation.currentCount > 0) { GameObject[] survivors = GameObject.FindGameObjectsWithTag("Survivor"); for (int i = 0; i < survivors.Length; i++) { LivingEntity entity = survivors [i].GetComponent <LivingEntity> (); if (entity != null) { entity.Heal(99999, true); } } } }
private void Awake() { pathFinder = GetComponent <NavMeshAgent>(); if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; playerEntity = target.GetComponent <LivingEntity>(); collisionRadius = GetComponent <CapsuleCollider>().radius; playerCollisionRadius = GetComponent <CapsuleCollider>().radius; } }
private bool IsDead(LivingEntity entity) { if (entity == null) { return(true); } if (!entity.IsAlive) { Debug.Log("selected Unit was dead"); OnUnitChanged(null); return(true); } OnUnitChanged(entity); return(false); }
private LivingEntity targetEntity; // 추적 대상으로부터 가져온 '생명' 정보 private void Awake() { audioPlayer = GetComponent <AudioSource>(); pathFinder = GetComponent <NavMeshAgent>(); if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent <LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; } }
void OnTriggerEnter(Collider col) { if (col.CompareTag("Player")) { for (int i = 0; i < number; i++) { int x = Random.Range(-3, 3); int z = Random.Range(-3, 3); int enemyindex = Random.Range(0, enemies.Length); LivingEntity spawnedEnemy = Instantiate(enemies[enemyindex], transform.position + new Vector3(x, 0, z), Quaternion.identity) as LivingEntity; control--; } } }
private void InializeComponents() { this.pathFinder = GetComponent <NavMeshAgent>(); GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player != null) { this.hasTarget = true; this.target = player.transform; this.targetEntity = target.GetComponent <LivingEntity>(); this.myCollisionRadius = GetComponent <CapsuleCollider>().radius; this.targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; } }
private void Awake() { if (GameObject.FindGameObjectWithTag("Player") != null) { targetAlive = true; //get ref targetEntity = GameObject.FindGameObjectWithTag("Player").GetComponent <LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; target = GameObject.FindGameObjectWithTag("Player").transform; myCollisionRadius = GetComponent <CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; } }
bool hasTarget; //has target to attack void Awake() { pathfinder = GetComponent <NavMeshAgent>(); //find component of NavMeshAgent of enemy if (GameObject.FindGameObjectWithTag("Player") != null) //if enemy finds a player { hasTarget = true; //enemy has a target to attack target = GameObject.FindGameObjectWithTag("Player").transform; // set target position targetEntity = target.GetComponent <LivingEntity>(); //get target's "LivingEntity" script myCollisionRadius = GetComponent <CapsuleCollider>().radius; //get enemy radius targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; //get target radius } }
public static void RunAbilitySetupOnEntity(LivingEntity entity, string className) { if (className == "Human Warrior") { TeachEntityHumanWarriorAbilities(entity); } else if (className == "Human Archer") { TeachEntityHumanArcherAbilities(entity); } else if (className == "Human Priest") { TeachEntityHumanPriestAbilities(entity); } }
public static bool IsEngagedInMelee(LivingEntity enemyConsidered) { List <TileScript> tilesInMyMeleeRange = LevelManager.Instance.GetTilesWithinRange(1, enemyConsidered.TileCurrentlyOn); bool inMelee = false; foreach (LivingEntity entity in LivingEntityManager.Instance.allLivingEntities) { if (tilesInMyMeleeRange.Contains(entity.TileCurrentlyOn) && CombatLogic.Instance.IsTargetFriendly(enemyConsidered, entity) == false) { inMelee = true; } } return(inMelee); }
IEnumerator DamageSurvivor(GameObject survivor) { LivingEntity survivorEntity = survivor.GetComponent <LivingEntity> (); while (!survivorEntity.Dead) { if (Time.time > nextHitTime) { nextHitTime = Time.time + 0.6f; survivorEntity.TakeHit(damage); popuptext.SetPopUpText(survivor.transform.position, "-" + damage, PopUpText.Types.Default, new Color(255, 0, 0), 2); } yield return(new WaitForSeconds(0.5f)); } }
private void CallDoDamageSpellElementalProjectile(LivingEntity attacker, LivingEntity victim) { if (attacker is Hero) { var wpn = game.GameManager.LootGenerator.GetLootByAsset("staff") as Weapon; SetHeroEquipment(wpn); var weapon = game.Hero.GetActiveWeapon(); Assert.AreEqual(weapon.SpellSource.Kind, SpellKind.FireBall); Assert.True(game.GameManager.SpellManager.ApplyAttackPolicy(game.Hero, victim, weapon.SpellSource)); } else { game.GameManager.SpellManager.ApplyAttackPolicy(attacker, victim, attacker.ActiveManaPoweredSpellSource, null, (p) => {}); } }
void Start() { isDisabled = false; playerEntity = FindObjectOfType <Player>(); playerT = playerEntity.gameObject; nextCampCheckTime = timeBetweenCampingChecks + Time.time; campPositionOld = playerT.transform.position; playerEntity.OnDeath += OnPlayerDeath; map = FindObjectOfType <MapGenerator>(); NextWave(); }
public override IEnumerator DoEffect(LivingEntity entity) { var modifer = new StatModifer(Amount, type, this); entity.AddStatModifer(modifer, attributeEnum); if (!isPersistent) { yield return(new WaitForSeconds(effectLifeTime)); entity.RemoveStatModifer(modifer, attributeEnum); entity.GetComponent <StatusEffectSystem>().RegisterDebuffCooldown(new Cooldown(reapplyCooldown, name)); EndEffect(entity); yield return(null); } }
public static bool AttackSucceeded(LivingEntity attacker, LivingEntity target) { // Currently using the same formula as FirstAttacker initiative. // This will change as we include attack/defense skills, // armor, weapon bonuses, enchantments/curses, etc. int playerDexterity = attacker.GetAttribute("DEX").ModifiedValue * attacker.GetAttribute("DEX").ModifiedValue; int opponentDexterity = target.GetAttribute("DEX").ModifiedValue * target.GetAttribute("DEX").ModifiedValue; decimal dexterityOffset = (playerDexterity - opponentDexterity) / 10m; int randomOffset = DiceService.Instance.Roll(20).Value - 10; decimal totalOffset = dexterityOffset + randomOffset; return(DiceService.Instance.Roll(100).Value <= 50 + totalOffset); }
// Use this for initialization void Start() { BabyRoomGenerator mapGen = GameObject.FindGameObjectWithTag("Map").GetComponent <BabyRoomGenerator>(); mapBottomEdge = mapGen.CoordToPosition(0, 0) + Vector3.forward * mapGen.tileSize / 2; if (playerT != null) { hasTarget = true; targetLivingEntity = playerT.GetComponent <LivingEntity>(); targetLivingEntity.OnDeath += OnPlayerDeath; //That's how we subscribe a method to a System.Action method (OnDeath) } mainCamera = Camera.main; }
void Awake() { pathfinder = GetComponent <UnityEngine.AI.NavMeshAgent> (); if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent <LivingEntity> (); myCollisionRadius = GetComponent <CapsuleCollider> ().radius; targetCollisionRadius = target.GetComponent <CapsuleCollider> ().radius; } }
protected virtual void FindFood() { LivingEntity foodSource = Environment.SenseFood(coord, this, FoodPreferencePenalty); if (foodSource) { currentAction = CreatureAction.GoingToFood; foodTarget = foodSource; CreatePath(foodTarget.coord); } else { currentAction = CreatureAction.Exploring; } }
protected override void Start() { base.Start(); _currentState = State.Chasing; _pathfinder = GetComponent <NavMeshAgent>(); _target = GameObject.FindWithTag("Player").transform; _targetEntity = _target.GetComponent <LivingEntity>(); _targetEntity.OnDeath += OnTargetDeath; _hasTarget = true; _myCollisionRadius = GetComponent <CapsuleCollider>().radius; _targetCollisionRadius = _target.GetComponent <CapsuleCollider>().radius; StartCoroutine(UpdatePath()); _animator = GetComponent <Animator>(); _animator.SetInteger("State", 2); }
private void Start() { playerEntity = FindObjectOfType <Player>(); playerT = playerEntity.transform; nextCampCheckTime = timeBetweenCampingChecks + Time.time; campPositionOld = playerT.position; playerEntity.OnDeath += OnPlayerDeath; map = FindObjectOfType <MapGenerator>(); NextWave(); // highlight player position - debug //StartCoroutine(HighLightPlayerTile()); }
private void Awake() { m_Pathfinder = GetComponent <NavMeshAgent> (); if (GameObject.FindGameObjectWithTag("Player") != null) { m_HasTarget = true; m_Target = GameObject.FindGameObjectWithTag("Player").transform; m_TargetEntity = m_Target.GetComponent <LivingEntity> (); m_EnemyCollisionRadius = GetComponent <CapsuleCollider> ().radius; m_TargetCollisionRadius = GetComponent <CapsuleCollider> ().radius; } }
public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face) { StructBlock block = (StructBlock)iBlock; LivingEntity living = (entity as LivingEntity); if (living == null) { return; } switch (living.FacingDirection(8)) { case "N": block.MetaData = (byte)MetaData.SignPost.North; break; case "NE": block.MetaData = (byte)MetaData.SignPost.Northeast; break; case "E": block.MetaData = (byte)MetaData.SignPost.East; break; case "SE": block.MetaData = (byte)MetaData.SignPost.Southeast; break; case "S": block.MetaData = (byte)MetaData.SignPost.South; break; case "SW": block.MetaData = (byte)MetaData.SignPost.Southwest; break; case "W": block.MetaData = (byte)MetaData.SignPost.West; break; case "NW": block.MetaData = (byte)MetaData.SignPost.Northwest; break; default: return; } base.Place(entity, block, targetIBlock, face); }
void OnTriggerEnter2D(Collider2D other) { Transform fx; if (other.gameObject.layer == LayerMask.NameToLayer("Ground") || other.gameObject.layer == LayerMask.NameToLayer("Platform")) { bounce++; if (helper != null && bounce != 1) { helper.layer = LayerMask.NameToLayer("Bounce"); } if (projectileType == ProjectileTypeEnum.PROJECTILE || (projectileType == ProjectileTypeEnum.BOUNCE && bounce > maxBound)) { if (onHitFxs != null && onHitFxs.Count > 0) { fx = Instantiate(onHitFxs[Random.Range(0, onHitFxs.Count)], transform.position, Quaternion.identity); fx.localScale = owner.transform.localScale; } Destroy(gameObject); } } LivingEntity livingEntity = other.GetComponent <LivingEntity>(); if (!livingEntity || livingEntity.GetType() == owner.GetType()) { return; } if (owner.GetType() == typeof(Player) && livingEntity.GetType() != typeof(Player)) { livingEntity.GetDamaged(new DamageInfo(owner, damage, transform.position, livingEntity.transform.position)); Destroy(gameObject); } else if (owner.GetType() != typeof(Player) && livingEntity.GetType() == typeof(Player)) { livingEntity.GetDamaged(new DamageInfo(owner, damage, transform.position, livingEntity.transform.position)); Destroy(gameObject); } if (onHitFxs == null || onHitFxs.Count <= 0) { return; } fx = Instantiate(onHitFxs[Random.Range(0, onHitFxs.Count)], transform.position, Quaternion.identity); fx.localScale = owner.transform.localScale; }
protected virtual byte GetDirection(LivingEntity living, StructBlock block, StructBlock targetBlock, BlockFace face) { byte direction = 0; switch (face) { case BlockFace.East: direction = (byte)MetaData.Container.East; break; case BlockFace.West: direction = (byte)MetaData.Container.West; break; case BlockFace.North: direction = (byte)MetaData.Container.North; break; case BlockFace.South: direction = (byte)MetaData.Container.South; break; default: switch (living.FacingDirection(4)) // Built on floor, set by facing dir { case "N": direction = (byte)MetaData.Container.North; break; case "W": direction = (byte)MetaData.Container.West; break; case "S": direction = (byte)MetaData.Container.South; break; case "E": direction = (byte)MetaData.Container.East; break; default: return(0); } break; } return(direction); }
private void Projectile_OnCollisionEnter(object otherCollider) { GameObject hitGameObject = ((BoxCollider)otherCollider).ConnectedGameObject; if ((hitGameObject is Player && !IsGood) || (hitGameObject is Enemy && IsGood)) { LivingEntity entity = hitGameObject as LivingEntity; if (!entity.invincible) { entity.HP -= Damage; if (entity.HP <= 0) { Player targetHolder = (Player)((Enemy)entity).Target; targetHolder.ComboManager(); targetHolder.Gold = targetHolder.Gold + (entity.Gold * targetHolder.combo); if (!GameManager.EnemiesP1.Remove((Enemy)entity)) { GameManager.EnemiesP2.Remove((Enemy)entity); } entity.Destroy(); } else { //switch (kbDirection) //{ // case FacingDirection.Up: // Position = new Vector2(Position.X, Position.Y - 30); // break; // case FacingDirection.Left: // Position = new Vector2(Position.X - 30, Position.Y); // break; // case FacingDirection.Right: // Position = new Vector2(Position.X + 30, Position.Y); // break; // case FacingDirection.Down: // Position = new Vector2(Position.X, Position.Y + 30); // break; //} } } Destroy(); } else if (!(hitGameObject is LivingEntity)) { Destroy(); } }
private void Awake() { pathfinder = GetComponent <NavMeshAgent>(); //DONT assume the player exists in the scene: this enemy may spawn after the player has died! if (GameObject.FindGameObjectWithTag("Player") != null) //Set up chasing code { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent <LivingEntity>(); myCollisionRadius = GetComponent <CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; } }
void Awake() { pathfinder = GetComponent<NavMeshAgent> (); // компонент NavMeshAgent present = GetComponent<Present> (); if (GameObject.FindGameObjectWithTag ("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag ("Player").transform; // находим по тегу трансформ Игрока targetEntity = target.GetComponent<LivingEntity>(); myCollisionRadius = GetComponent<CapsuleCollider> ().radius; //берем врага коллайдер.radius targetCollisionRadius = target.GetComponent<CapsuleCollider>().radius; // берем свой коллайдер.radius } }
public void finishHarvest() { LivingEntity harvestTargetLiving = this.harvestTarget.GetComponent <LivingEntity>(); if (harvestTargetLiving != null) { SoundManager.PlaySingleAt(harvestSound, transform.position); GetComponent <LivingEntity>().GainHealth(healthGainMultiplier * harvestTargetLiving.maxHealth); //ADd to score GameController.AddScore((int)(harvestTargetLiving.maxHealth * 0.1f)); } Destroy(harvestTarget); AbortHarvest(); }
private void OnTriggerEnter2D(Collider2D hitCollider) { if (hitCollider.tag == "Enemy" && hitCollider.gameObject.activeInHierarchy) { GameObject hitObject = hitCollider.gameObject; LivingEntity enemyScript = hitObject.GetComponent <LivingEntity>(); if (enemyScript != null) { enemyScript.EntityHit(attackObject); } Destroy(gameObject); } }
protected override void Process(GameSession session, Cond packet) { Character character = session.Character; Map map = character.Map; LivingEntity entity = map.GetEntity <LivingEntity>(packet.EntityType, packet.EntityId); if (entity == null) { return; } entity.Speed = packet.Speed; entity.CantAttack = packet.CantAttack; entity.CantMove = packet.CantMove; }
//"GetComponent" är bättre att ha i Awake, För i det här fallet kommer SetStatsmetoden kallas före Start() från Spawnerklassen. void Awake() //Awake körs först i klassen om klassen skulle kallas av en annan klass. Dvs Awake() körs före Start() i Unity { pathfinder = GetComponent <UnityEngine.AI.NavMeshAgent>(); if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent <LivingEntity>(); // Så Enemy transform inte kommer in i target transform position. myCollisionRadius = GetComponent <CapsuleCollider>().radius; TargetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; } }
protected override void Start() { base.Start(); pathfinder = GetComponent<NavMeshAgent>(); skinMaterial = GetComponent<Renderer>().material; originalColor = skinMaterial.color; myCollisionRadius = GetComponent<CapsuleCollider>().radius; if (GameObject.FindGameObjectWithTag("Player") != null) { currentState = State.Chasing; hasTarget = true; player = GameObject.FindGameObjectWithTag("Player").transform; targetCollisionRadius = player.GetComponent<CapsuleCollider>().radius; playerEntity = player.GetComponent<LivingEntity>(); playerEntity.OnDeath += OnPlayerDeath; StartCoroutine(UpdatePath()); } }
// Update is called once per frame void Update () { //bool walkable = !(Physics.CheckSphere(transform.position, 2, _unwalkableMask));//checks if it is walkable or not bool ableToWalkToPlayer = !(Physics.CheckSphere(player.position, 1, _unwalkableMask));//checks if player is in a walkable space float sqrDistancePlayer = (player.position - transform.position).sqrMagnitude; float sqrDistanceBase = (theBase.position - transform.position).sqrMagnitude; if (sqrDistancePlayer < Mathf.Pow(7, 2) && ableToWalkToPlayer && !_nearPlayer && !_nearBase) { // Debug.Log("follow"); float step = 15 * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, player.position, step); } if (player != null) { if (sqrDistancePlayer < Mathf.Pow(_attackRange, 2)) { targetEntity = player.GetComponent<LivingEntity>(); //_nearPlayer = true; Attack(); } else _nearPlayer = false; } if (theBase != null) { if (sqrDistanceBase < Mathf.Pow(_attackRange, 2)) { targetEntity = theBase.GetComponent<LivingEntity>(); _nearBase = true; Attack(); } else _nearBase = false; } }
// Use this for initialization protected override void Start() { base.Start(); agent = GetComponent<NavMeshAgent>(); skinMaterial = GetComponent<Renderer>().material; originColor = skinMaterial.color; GameObject playerObj = GameObject.FindGameObjectWithTag("Player"); if (playerObj) {target = playerObj.transform;} if (target != null) { currentState = State.Chasing; hasTarget = true; myCollisionRadius = GetComponent<CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent<CapsuleCollider>().radius; targetEntity = target.GetComponent<LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; StartCoroutine(UpdatePath()); } }
protected override void Start() { base.Start(); pathfinder = GetComponent<NavMeshAgent>(); skinMaterial = GetComponent<Renderer>().material; originalColor = skinMaterial.color; // pega a cor original do object if (GameObject.FindGameObjectWithTag("Player") != null) { currentState = State.Chasing; hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent<LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; myCollisionRadius = GetComponent<CapsuleCollider>().radius; //pega o raio do collider do enemy targetCollisionRadius = target.GetComponent<CapsuleCollider>().radius; // pega o collider do player StartCoroutine(UpdatePath()); } }
public override void Start() { base.Start(); skinMaterial = GetComponent<Renderer>().material; originalColor = skinMaterial.color; currState = State.Chasing; pathFinder = gameObject.GetComponent<NavMeshAgent>(); GameObject tar = GameObject.FindGameObjectWithTag("Player"); if(tar != null) { target = tar.transform; hastarget = true; livingEntity = target.GetComponent<LivingEntity>(); livingEntity.OnDeath += OnTargetDeath; myCollisionRadius = GetComponent<CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent<CapsuleCollider>().radius; StartCoroutine(UpdatePath()); } }
void Start() { tileColor = tileMaterial.color; playerEntity = FindObjectOfType<Player>(); playerTransform = playerEntity.transform; nextCampCheckTime = timeBetweenMoveCheck + Time.time; lastPlayerPosition = playerTransform.position; playerEntity.OnDeath += OnPlayerDeath; map = FindObjectOfType<MapGenerator>(); NextWave(); }
//intilization methods /* //////////////////// PATH FINDING //////////////////// */ protected override void Start() { base.Start(); pathfinder = GetComponent<NavMeshAgent>(); skinDefalt = GetComponent<Renderer>().material; defaltColor = skinDefalt.color; if (GameObject.FindGameObjectWithTag("Player") != null) { currentState = State.Chasing; hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent<LivingEntity>(); targetEntity.OnDeath += OnTargetDeath; thisColissionRadius = GetComponent<CapsuleCollider>().radius; targetColissionRadius = target.GetComponent<CapsuleCollider>().radius; StartCoroutine(UpdatePath()); } }
void Start() { playerEntiy = FindObjectOfType<Player>(); player = playerEntiy.transform; playerEntiy.OnDeath += OnPlayerDeath; nextCampCheckTime = Time.time + campCheckInterval; oldCampPosition = player.position; mapGenerator = FindObjectOfType<MapGenerator>(); OnNewWave += mapGenerator.OnNewWave; NextWave(); }
protected void Move(LivingEntity _target) { agent.destination = _target.transform.position; }
protected override void Start() { base.Start(); pathFinder = GetComponent<NavMeshAgent>(); if (type == Type.Roaming) { int r = Random.Range(0, 4); if(r == 0) transform.forward = new Vector3(0.5f, 0, 0.5f); else if(r == 1) transform.forward = new Vector3(-0.5f, 0, 0.5f); else if (r == 2) transform.forward = new Vector3(0.5f, 0, -0.5f); else transform.forward = new Vector3(-0.5f, 0, -0.5f); } if (type == Type.Boss1) { direction = Random.Range(0, 2); if (direction == 0) direction = -1; movement = Vector3.right * direction; } if (GameObject.FindGameObjectWithTag("Player") != null) { currentState = State.Chasing; hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; transform.forward = (new Vector3(target.position.x, 0, target.position.z) - new Vector3(transform.position.x, 0, transform.position.z)).normalized; targetEntity = target.GetComponent<LivingEntity>(); targetEntity.onDeath += OntargetDeath; mycollisionRadious = GetComponent<CapsuleCollider>().radius; targetCollisionRadious = target.GetComponent<CapsuleCollider>().radius; if(type == Type.Melee || type == Type.Roaming || type == Type.Ranged) StartCoroutine(UpdatePath()); onDeath += ScoreIncrease; } anim = GetComponentInChildren<Animator>(); audioSource = GetComponent<AudioSource>(); audioSource.clip = spawnSound; audioSource.Play(); }
void Start() { map = FindObjectOfType<MapGenerator>(); player = FindObjectOfType<Player>(); playerT = player.transform; player.OnDeath += OnPlayerDeath; nextCampingCheckTime = Time.time + timeBetweenCampingCheck; isCamping = false; isDisable = false; NextWave(); }
void Awake() { pathFinder = GetComponent<NavMeshAgent>(); skinMaterial = GetComponent<Renderer>().material; currentState = State.Chasing; if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetCollisionRadius = target.GetComponent<CapsuleCollider>().radius; collisionRadius = GetComponent<CapsuleCollider>().radius; targetEntity = target.GetComponent<LivingEntity>(); } }
void Start() { map = GameObject.FindGameObjectWithTag ("MapGenerator").GetComponent<MapGenerator> (); OnNewWave += map.OnNewWave; playerEntity = GameObject.FindGameObjectWithTag ("Player").GetComponent<LivingEntity> (); nextCampCheckTime = Time.time + timeBetweenCampingChecks; prevCampPos = playerEntity.transform.position; playerEntity.OnDeath += OnPlayerDeath; currentWaveNumber = -1; NextWave (); }
/* //////////////////// Decision Methods //////////////////// */ void Chase(Transform Target) { currentState = State.Chasing; hasTarget = true; switch (currentTargetType) { case targetType.Mob: target = Target; targetEntity = target.GetComponent<LivingEntity>(); //targetEntity.OnDeath += OnTargetDeath; thisColissionRadius = GetComponent<CapsuleCollider>().radius; targetColissionRadius = target.GetComponent<CapsuleCollider>().radius; transform.TransformDirection((transform.position + target.position).normalized); break; case targetType.Terra: if (currentState != State.Wondering) { isGrazing = true; target = Target; targetTerrain = target.GetComponentInParent<Terrain>(); } thisColissionRadius = GetComponent<CapsuleCollider>().radius; targetColissionRadius = Vector3.Distance(target.GetComponent<MeshCollider>().bounds.min, target.GetComponent<MeshCollider>().bounds.max); transform.TransformDirection((transform.position + target.position).normalized); break; default: Debug.Log("no valid target selected"); break; } hasTask = true; StartCoroutine(UpdatePath()); }
void Start() { playerEntity = FindObjectOfType<Player>(); playerT = playerEntity.transform; playerEntity.OnDeath += OnPlayerDeath; nextCampCheckTime = timeBetweenCampingChecks + Time.time; campPositionOld = playerT.position; map = GameObject.FindObjectOfType<MapGenerator>(); gameUI = GameObject.FindGameObjectWithTag("GameUImanager").GetComponent<GameUI>(); NextWave(); }