public virtual void CommenceFiring(Enemy en) { cooldown = sec_to_cooldown * 0.5f; foreach (CombinerEnemy e in squad) e.ute = true; }
protected override void OnHit(Shooting shooting, Enemy enemy, Vector3 contactPoint) { var level = shooting.CrossLevel; enemy.Health -= Power[Math.Min(level - 1, 2)]; if (LockedTo != null) LockedTo.LockedOn = false; var dead = enemy.Health <= 0; if (dead && !enemy.Dead) { var xploGo = (GameObject)Instantiate(Shooting.ExplosionTemplate); xploGo.transform.position = enemy.transform.position; xploGo.transform.rotation = Random.rotation; if (enemy is SingleShotBehaviour && (enemy as SingleShotBehaviour).invertColors) xploGo.renderer.material = ColorShifting.Materials["clr_Red"]; else xploGo.renderer.material = ColorShifting.Materials[ColorShifting.EnemyMaterials[enemy.GetType()]]; } base.OnHit(shooting, enemy, contactPoint); Destroy(gameObject); }
protected virtual void Gather(Enemy en = null) { Vector3 avg = Vector3.zero; foreach (Enemy e in this) avg += e.Destination; avg /= NumMembers; avg.z = -50f; int mod = 0; foreach (CombinerEnemy e in this) { e.DestinationReached -= Gather; e.ute = false; Vector3 dest = avg; if (mod == 0) { e.Destination = avg; avg = e.Destination; e.destination.rotation = Quaternion.identity; e.focus = true; e.DestinationReached += e.CommenceFiring; } else { dest += new Vector3(15f - 15f * (mod - 1), 0f, -15f); e.Destination = dest; e.destination.rotation = Quaternion.LookRotation(avg - e.Destination, e.transform.up); e.focus = false; } mod++; } }
// Use this for initialization void Start() { pool = GameObject.FindGameObjectWithTag("DungeonManager").GetComponent<DungeonManager>().getPool(); enemyList = new List<Enemy>(); string path = Application.dataPath + @"/Resources/XML/EnemyList.xml"; XmlReader xmlReader = XmlReader.Create(path); while(xmlReader.Read ()) { if((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "Enemy")) { if(xmlReader.HasAttributes) { if (xmlReader.GetAttribute("pool") == pool) { Enemy tempEnemy = new Enemy(); tempEnemy.charName = xmlReader.GetAttribute("name"); //tempEnemy. = xmlReader.GetAttribute("desc"); tempEnemy.health = int.Parse(xmlReader.GetAttribute("health")); tempEnemy.strength = int.Parse(xmlReader.GetAttribute("str")); tempEnemy.endurance = int.Parse(xmlReader.GetAttribute("end")); tempEnemy.agility = int.Parse(xmlReader.GetAttribute("agi")); tempEnemy.magicSkill = int.Parse(xmlReader.GetAttribute("mag")); tempEnemy.luck = int.Parse(xmlReader.GetAttribute("luck")); tempEnemy.range = int.Parse(xmlReader.GetAttribute("range")); tempEnemy.drop = xmlReader.GetAttribute("drop"); tempEnemy.image = xmlReader.GetAttribute("image"); enemyList.Add(tempEnemy); } } } } //Debug.Log("Possible enemies: " + enemyList.Count); populateFloor(); }
public Vector3 getPosInEnemyBody(Enemy enemy) { BoxCollider bc = enemy.collider as BoxCollider; float randomX = UnityEngine.Random.Range(bc.bounds.min.x,bc.bounds.max.x); float randomY = UnityEngine.Random.Range(bc.bounds.min.y,bc.bounds.max.y); return new Vector3(randomX, randomY,0); }
// Use this for initialization void Start() { mainObject = transform.parent.GetComponent<Enemy>(); sightRadius = GetComponent<CircleCollider2D>().radius; layerMask = ~Game.nodeMask; }
public void ShowEffect(Enemy enemy) { if(Effectt_Prb == null) { Effectt_Prb = Resources.Load("eft/Gamora/SkillEft_GAMORA30AB") as GameObject; } GameObject front = Instantiate(Effectt_Prb) as GameObject; front.transform.parent = enemy.transform; front.transform.localPosition = new Vector3(0,500,-15); GameObject behind = Instantiate(Effectt_Prb) as GameObject; behind.transform.parent = enemy.transform; behind.transform.localPosition = new Vector3(0,500,100); effects.Add(front); effects.Add(behind); if (targets.ContainsKey(enemy.getID())){ targets[enemy.getID()] = effects.Count-2; } else{ targets.Add(enemy.getID(), effects.Count-2); } PackedSprite ps = front.GetComponent<PackedSprite>(); ps.Color = new Color(ps.Color.r, ps.Color.g,ps.Color.b,0.5f); }
public void _KillEnemy(Enemy _enemy) { GameObject _clone = Instantiate(_enemy.deathParticles, _enemy.transform.position, Quaternion.identity) as GameObject; Destroy(_clone, 5f); cameraShake.Shake(_enemy.shakeAmt, _enemy.shakeLength); Destroy(_enemy.gameObject); }
static void Main(String[] args) { string[] inputs; // game loop while (true) { int count = int.Parse(Console.ReadLine()); // The number of current enemy ships within range Console.Error.WriteLine("Count:" + count); Enemy[] enemys = new Enemy[count]; for (int i = 0; i < count; i++) { inputs = Console.ReadLine().Split(' '); enemys[i] = new Enemy(inputs[0], int.Parse(inputs[1])); } Array.Sort(enemys, delegate(Enemy en1, Enemy en2) { return en1.Dist.CompareTo(en2.Dist); }); Console.WriteLine(enemys[0].Name); } }
// TODO : rename private void killEnemyPlusEffect(Enemy enemy) { Transform deathParticles = Instantiate(enemy.deathParticles, enemy.transform.position, Quaternion.identity) as Transform; Destroy(deathParticles.gameObject, 2f); camerashake.shake(enemy.shakeAmt, enemy.shakeLenght); Destroy(enemy.gameObject); }
// Use this for initialization IEnumerator Start() { spaceship = GetComponent<Spaceship> (); common = GetComponent<EnemyCommon>(); enemy = GetComponent<Enemy>(); common.Init(); //SE関係 audioSource = gameObject.GetComponent<AudioSource>(); audioSource.clip = shootSE; // s2 = common.CreateShotPosition(); pt = FindObjectOfType<Party>().transform; //FindObjectOfType<MessageWindow>().showMessage("メテオ"); yield return new WaitForEndOfFrame(); //StartCoroutine("Stop"); StartCoroutine("Attack1"); yield break; }
// Update is called from enemy once per frame public EnemyTask.State Update() { if (_myEnemy == null) return EnemyTask.State.ENEMY_DEAD; if (_myTask == null) { _myEnemy.DoNothing(); return EnemyTask.State.COMPLETE; } switch (_myEnemy.CurrentState) { case Enemy.EnemyState.OK: return _myTask.DoTask(); case Enemy.EnemyState.HIT: return EnemyTask.State.FAILED; // this is because may have been knocked off course and need to recalculate paths etc case Enemy.EnemyState.DEAD: _myEnemy = null; return EnemyTask.State.ENEMY_DEAD; } return EnemyTask.State.ONGOING; }
/// <summary> /// Load graphics content for the game. /// </summary> public override void Activate(bool instancePreserved) { if (!instancePreserved) { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); gameFont = content.Load<SpriteFont>(@"Game\gamefont"); // La map //Texture2D grassTexture = content.Load<Texture2D>("grass"); //Texture2D pathTexture = content.Load<Texture2D>("path"); level.AddTexture(content.Load<Texture2D>(@"Game\Levels\grass")); level.AddTexture(content.Load<Texture2D>(@"Game\Levels\path")); // Enemy //Texture2D enemyTexture = content.Load<Texture2D>("enemy"); enemy = new Enemy(content.Load<Texture2D>(@"Game\Enemies\enemy"), Vector2.Zero, 100, 10, 0.5f); enemy.SetWaypoints(level.Waypoints); // Player //Texture2D towerTexture = content.Load<Texture2D>("ARROW"); player1 = new Player(this.level, content.Load<Texture2D>(@"Game\Towers\arrow")); // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); } }
public void DropLoot(Enemy enemy) { string enemyName = enemy.enemyName; if (lootTables.ContainsKey (enemyName)) { LootTable lootTable = lootTables [enemyName]; foreach (Loot loot in lootTable.loots) { for (int i = 0; i < loot.amount; i++) { int roll = UnityEngine.Random.Range (1, 1001); if (roll <= loot.dropRate) { switch (loot.type) { case LootType.SWORD: if (weaponPrefabs.ContainsKey (loot.id)) Instantiate (weaponPrefabs [loot.id], enemy.transform.position, Quaternion.Euler (90.0f, 0.0f, 0.0f)); break; case LootType.POTION: if (potionPrefabs.ContainsKey (loot.id)) Instantiate (potionPrefabs [loot.id], enemy.transform.position, Quaternion.identity); break; } } } } } }
public EnemyAggro(Enemy enemy, Transform target) : base(enemy) { this.target = target; enemy.navMeshAgent.SetDestination (target.position); enemy.navMeshAgent.Resume (); Begin(); }
public override void Attack(Player player,Direction to,Map map,Enemy[] enemy,int cnt) { int x=player.X; int y=player.Y; int dx = 0, dy = 0; switch (to) { case Direction.Up: dx=-1; break; case Direction.Down: dx=1; break; case Direction.Left: dy=-1; break; case Direction.Right: dy=1; break; } while (x >= 0 && x < map.X && y >= 0 && y < map.Y) { x += dx; y += dy; for (int i = 0; i < cnt; ++i) if (enemy[i].X == x && enemy[i].Y == y && enemy[i].Alive) { enemy[i].Beaten(ATK, map); spark[0].X0 = player.X; spark[0].Y0 = player.Y; spark[0].X = x; spark[0].Y = y; return; } } spark[0].X0 = player.X; spark[0].Y0 = player.Y; spark[0].X = x; spark[0].Y = y; }
public void PlayerEnemyCollide(Player player, Enemy enemy) { Rectangle playerBox = player.state.GetBoundingBox(player.position); Rectangle enemyBox = enemy.state.GetBoundingBox(enemy.position); Rectangle intersection = Rectangle.Intersect(playerBox, enemyBox); player.interactable = true; player.interactEnemy = enemy; if (intersection.Height > intersection.Width) { if (playerBox.Right > enemyBox.Left && playerBox.Right < enemyBox.Right) { player.position.X -= intersection.Width; // left } else { player.position.X += intersection.Width; // right } } else if (intersection.Height < intersection.Width) { if (playerBox.Bottom > enemyBox.Top && playerBox.Bottom < enemyBox.Bottom) { player.position.Y -= intersection.Height; // up } else { player.position.Y += intersection.Height; // down } } }
void Start () { // initialize enemy's attribute enemy = GameObject.FindGameObjectWithTag("Enemy"); // find enemy gameobject int the scene enemyAttribute = enemy.GetComponent<Enemy> (); enemyScore = enemy.GetComponent<EnemyScore> (); enemyAttack = enemy.GetComponent<EnemyAttack> (); }
public PatrolBehaviour(Enemy enemy, GameObject bounds) : base() { this.enemy = enemy; this.bounds = bounds; boundSize = bounds.GetComponent<SpriteRenderer> ().bounds.size.y / 2; }
public AttackingEnemyState(Enemy enemy, Player player) { this.enemy = enemy; enemyRigidbody = enemy.GetComponent<Rigidbody>(); this.player = player; randomMoveDelay = Random.Range(1f, 2f); }
public void setUI(Enemy e) { pName.text = e.Name; HealthText.text = "Health: " + e.Health.ToString() + "/" + e.HealthTotal.ToString(); float hRatio = (float)e.Health / (float)e.HealthTotal; HealthBar.rectTransform.sizeDelta = new Vector2(HealthSize.x * hRatio, HealthSize.y); }
public void SetEnemyValues( Enemy other ) { this.health = other.health; this.movement = other.movement; this.enemySprite = other.enemySprite; this.enemyName = other.enemyName; }
public override Status e_Visit(Enemy en) { if (e_Predicate(en)) return Status.Success; else return Status.Fail; }
public CatWolfAI(Enemy catwolf) : base(catwolf) { viewRange = 15f; distantToPlayer = 1.3f; person = (CatWolf)_person; }
// ���ҵ��� void FindEnemy() { m_targetEnemy = null; int lastlife = 0; foreach (Enemy enemy in GameManager.Instance.m_EnemyList) { if (enemy.m_life == 0) continue; Vector3 pos1 = this.transform.position; Vector3 pos2 = enemy.transform.position; float dist=Vector2.Distance(new Vector2(pos1.x, pos1.z), new Vector2(pos2.x, pos2.z)); if (dist > m_attackArea) continue; if (lastlife == 0 || lastlife > enemy.m_life) { m_targetEnemy = enemy; lastlife = enemy.m_life; } } }
public RotopollyAI(Enemy c) : base(c) { viewRange = 20f; person = (Rotopolly)_person; comboChance = person.setting.runComboChance; }
public void addThreat(CRController source, float threat) { int i=0; for (; i<_enemies.Count; i++) { Enemy enemy = _enemies[i]; if (enemy.controller == source) { enemy.threat = enemy.threat + threat; _enemies[i] = enemy; break; } } if (i >= _enemies.Count) { Enemy enemy = new Enemy(); enemy.controller = source; enemy.threat = threat; _enemies.Add(enemy); } else { if (i > 0 && _enemies[i].threat > _enemies[i-1].threat) { Enemy tmp = _enemies[i]; _enemies[i] = _enemies[i-1]; _enemies[i-1] = tmp; } } updateTarget(); }
// update enemy kill counter public void EnemyDie(Enemy enemy) { // update kill amount KillCountAmount (); // add gold amount GoldCountAmount (enemy.gold); }
void OnEnemyInstantiate(Enemy enemy) { _enemies[_index++] = enemy; enemy.name = pfEnemy.name; enemy.spawner = this; enemy.Respawn(); }
// Update is called once per frame void Update() { while (fuel > 0) { Vector2 vector = transform.forward; float distance = 1000; Vector2 target = Vector2.zero; foreach (FallingBody b in Universe.world.characters) { if (b is Enemy) { float delta = Vector2.Distance(transform.position, b.transform.position); if (delta < 1) Detonate(); if (delta < distance) { target = b.transform.position; } } } if (distance < 1000) { vector += (target - (Vector2) transform.position) * .1f; } velocity += (new Vector2d(vector.x, vector.y).normalized)* Time.deltaTime * missileForce; fuel -= Time.deltaTime; } time -= Time.deltaTime; transform.position = Universe.WorldToView(position); if (time < 0) Detonate(); }
// upper half of the screen is dedicated to enemies void GenerateEnemies(bool randomizeHealth, bool randomizeBonuses) { float enemyCurrProbability = 0; GObject entity = null; ReturnOldObjectsToPool(); float worldSizeX = m_WorldBounds.x * 2; float worldSizeY = m_WorldBounds.y; //possible num of enemies in matrix taking into account gaps between and screen size float enemiesOnXTotalWidth = Mathf.Floor(worldSizeX); float enemiesOnYTotalHeight = Mathf.Floor(worldSizeY); float borderX = worldSizeX - enemiesOnXTotalWidth; float borderY = worldSizeY - enemiesOnYTotalHeight; float enemySpaceX = (enemiesOnXTotalWidth - m_EnemyGapTotal) / Enemy.WIDTH; float enemySpaceY = (enemiesOnYTotalHeight - m_EnemyGapTotal) / Enemy.HEIGHT; float enemiesOnX = Mathf.Floor(enemySpaceX); float enemiesOnY = Mathf.Floor(enemySpaceY); borderX += (enemySpaceX - enemiesOnX); borderY += (enemySpaceY - enemiesOnY); float gapX = m_EnemyGapTotal / (enemiesOnX - 1); float gapY = m_EnemyGapTotal / (enemiesOnY - 1); // Debug.Log("worldSizeX " + worldSizeX + " enemiesOnX " + enemiesOnX + " borderX " + borderX); // Debug.Log("worldSizeY " + worldSizeY + " enemiesOnY " + enemiesOnY + " borderY " + borderY); // Debug.Log("gapX " + gapX + " enemiesOnXTotalWidth " + enemiesOnXTotalWidth); // Debug.Log("gapY " + gapX + " enemiesOnYTotalHeight " + enemiesOnYTotalHeight); for (int i = 0; i < enemiesOnX; i++) { for (int j = 0; j < enemiesOnY; j++) { // if (j>0) break; // test enemyCurrProbability = UnityEngine.Random.Range(0f, 1f); if (enemyCurrProbability <= c_EnemyProbability) { entity = MainLogic.GetMainLogic().GetEntityManager().GetEntity(GObject.ObjectType.Enemy); // Debug.Log("put enemy " + entity); if (entity != null) { m_VcTemp.x = borderX / 2 + gapX * i + Enemy.WIDTH * i + Enemy.WIDTH / 2 - m_WorldBounds.x; m_VcTemp.y = (-1) * (borderY / 2 + gapY * j + Enemy.HEIGHT * j + Enemy.HEIGHT / 2) + m_WorldBounds.y; entity.Put(m_VcTemp.x, m_VcTemp.y); entity.m_Transform.SetParent(m_TrsLevelObjects); m_AllEnemies.Add(entity); Enemy enemy = entity as Enemy; enemy.Reset(); enemy.AddDieListener(OnEnemyDie); if (randomizeHealth) { enemy.RandomizeHealth(); } else { enemy.SetDefaultHealth(); } if (randomizeBonuses) { enemy.RandomizeBonus(); } } } } } m_TotalEnemiesOnLevel = m_AllEnemies.Count; }
public void RemoveActiveEnemy(Enemy enemy) { }
//Call this to add the passed in Enemy to the List of Enemy objects. public void AddEnemyToList(Enemy script) { //Add Enemy to List enemies. enemies.Add(script); }
public override void Act(Enemy enemy) { roBear = (RoBear2)enemy; BuildCycle(); Animate(); }
public void function(Enemy self) { self.moveCharacter(-self.getTargetVector()); }
public void AddEnemyToList(Enemy script) { enemies.Add(script); }
private void Awake() { health = GetComponent <Health>(); enemy = GetComponent <Enemy>(); }
private void OnEnemyDead(Enemy enemy) { enemy.EnemyDead -= OnEnemyDead; enemies.Remove(enemy); }
public void Add(Enemy enemy) { enemies.Add(enemy); }
public ScytheSpin(Enemy enemy, EnemyHealth bossHealth) : base(enemy, bossHealth) { _originalPosition = _transform.position; }
public override void dealtDamage(int damageDealt, Enemy enemy) { summonLightning(enemy); }
private void Awake() { trans = transform; enemy = GetComponentInParent <Enemy>() as Enemy; }
public override void PerformAction() { Enemy.StartAction(new NoAction(), true, null); }
IEnumerator delayUntilClear(Enemy enemy) { yield return(new WaitForSeconds(1f)); enemyList.Remove(enemy); }
void Start() { enemy = this.gameObject.GetComponent <Enemy> (); enemy.description("This spider just wants a little bite."); }
public void Enter(Enemy enemy) { this.enemy = enemy; }
// Manage enemies private void RegisterEnemy(Enemy enemy) { enemyList.Add(enemy); }
void OnTriggerStay2D(Collider2D other) { if (!ready) { return; } //check if ready to arc first. Saves a bit of cpu. if (other.gameObject.tag == "Enemy" || other.gameObject.tag == "Boss") { lr.enabled = true; lr.positionCount = 2; Vector3 surfaceTarget = other.gameObject.GetComponent <Collider2D> ().bounds.ClosestPoint(transform.position); //hopefully targets the outer part of the collider. lr.SetPosition(0, transform.position); //from inside of ball to lr.SetPosition(1, surfaceTarget); //enemy's collider edge. audioManager.PlaySound("Zap1"); damageCountdown = damageInterval; //we're about to hit an enemy. this will keep us from hitting another enemy for 0.1s ready = false; if (other.gameObject.tag == "Enemy") //if it's a regular enemy { Enemy targetScript = other.GetComponent <Enemy> (); //get the enemy script targetScript.health -= arcDamage; //damage it. hopefully. targetScript.HitFeedback(); } if (other.CompareTag("Boss")) { if (other.GetComponent <Stage1Boss> ()) { other.GetComponent <Stage1Boss> ().DamageEnemy(damage, UID); } else if (other.GetComponent <SnekSegment> ()) { other.GetComponent <SnekSegment> ().DamageEnemy(damage, UID); } else if (other.GetComponent <SnekHead> ()) { other.GetComponent <SnekHead> ().DamageEnemy(damage, UID); } else if (other.GetComponent <Stage2Boss> ()) { other.GetComponent <Stage2Boss> ().DamageEnemy(damage, UID); } else if (other.GetComponent <Stage3BossPart> ()) { other.GetComponent <Stage3BossPart> ().DamageEnemy(damage, UID); } else if (other.GetComponent <Stage5Boss> ()) { other.GetComponent <Stage5Boss> ().DamageEnemy(damage, UID); } else if (other.GetComponent <BossaCoreScript> ()) { other.GetComponent <BossaCoreScript> ().DamageEnemy(damage, UID); } else if (other.GetComponent <WeakBoss1> ()) { other.GetComponent <WeakBoss1> ().DamageEnemy(damage, UID); } else if (other.GetComponent <WeakBoss4> ()) { other.GetComponent <WeakBoss4> ().DamageEnemy(damage, UID); } else if (other.GetComponent <WeakBoss5> ()) { other.GetComponent <WeakBoss5> ().DamageEnemy(damage, UID); } else if (other.transform.parent != null) { if (other.transform.parent.GetComponent <Stage3Boss>()) { other.transform.parent.GetComponent <Stage3Boss>().DamageEnemy(damage, UID); } if (other.transform.parent.GetComponent <WeakBoss2>()) { other.transform.parent.GetComponent <WeakBoss2>().DamageEnemy(damage, UID); } if (other.transform.parent.GetComponent <Stage6Boss>()) { other.transform.parent.GetComponent <Stage6Boss>().DamageEnemy(damage, UID); } } } } }
/// <summary> /// Enemy's damage box /// </summary> public void GetParameters(int damage, Element element, Vector2 position, Vector2 colliderSize, float lifeTime, AudioClip impactClip, int targetLayer, float dazedTime, Vector2 repulseVector, Enemy enemyParent) { this.damage = damage; this.element = element; this.position = position; this.colliderSize = colliderSize; this.lifeTime = lifeTime + Time.time; this.impactClip = impactClip; this.targetLayer = targetLayer; this.dazedTime = dazedTime; this.repulseVector = repulseVector; this.enemyParent = enemyParent; damageType = DamageTypes.Slash; }
public void UnregisterEnemy(Enemy enemy) { enemyList.Remove(enemy); enemy.Agent.enabled = false; KillEnemy(enemy); }
override public void Effect(Player player, Enemy enemy) { enemy.GetDMG(dmgValue + player.CurrentStr); player.CurrentPO += defValue + player.CurrentDex; }
private void Start() { enemy = GetComponent <Enemy>(); }
public override void tookDamage(int amountDamage, Enemy enemy) { StartCoroutine(delayStasisPeriod()); }
public IdleState(Enemy enemy, Searchable searchable) : base(enemy, searchable) { CurrentState = "Idle"; }
/// <summary> /// Initializes a new instance of the <see cref="SpawnEnemyArgs"/> class. /// </summary> /// <param name="enemy"> /// The enemy. /// </param> public SpawnEnemyArgs(Enemy enemy) { this.Enemy = enemy; }
internal void CustomStart() { enemy = GetComponent <Enemy>(); }
//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) { Enemy enemy = animator.GetComponent <Enemy>(); enemy.attacking = true; }
public SprintAction(Enemy target) : base(target) { }
public EnemyShootingState(Enemy agent, StateMachine stateMachine) : base(agent, stateMachine) { }
void Start() { source = gameObject.GetComponentInParent <AudioSource>(); enemy = gameObject.GetComponentInParent <Enemy>(); gameObject.GetComponent <CircleCollider2D>().radius = range; }