void SpawnBig() { GameObject bigInst = Instantiate(m_BigEnemy, new Vector3(0, 9, 0), Quaternion.identity) as GameObject; EnemyControl bigControl = bigInst.GetComponent <EnemyControl>(); bigControl.m_ShootSpeed = shootspeed; }
void Start() { if (GameController.mapIsDone == true) { TM = GameObject.FindGameObjectWithTag("TileMap").GetComponent <TileMap>(); //Get the loaded enemylist from resources EnemyList eList = EnemyList.GetEnemyList(); // Randomise enemies EnemyControl.Randomise(); if (eList != null) { GameObject SelectedModel = eList.GetRelevantModel(EnemyControl.enemyClass); if (SelectedModel != null) { Vector3 NewPos = transform.position + transform.up * (transform.lossyScale.y * 0.5f); selectedEnemy = GameObject.Instantiate(SelectedModel, NewPos, transform.rotation) as GameObject; if (selectedEnemy != null) { if (selectedEnemy.GetComponent <EnemyUnit>() != null) { selectedEnemy.GetComponent <EnemyUnit>().map = TM; float PositionOffset = TM.tileSize / 2.0f; selectedEnemy.GetComponent <EnemyUnit>().SetSpawnLocation((int)((NewPos.x - PositionOffset) / TM.tileSize), (int)((NewPos.z - PositionOffset) / TM.tileSize)); } //if } //if } //if } //if } //if } //Start
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Enemy") { EnemyControl ec = collision.gameObject.GetComponent <EnemyControl>(); //print("transform.position="+ transform.position.x); //print("collision.position=" + collision.transform.position.x); if (rb.velocity.y < 0 && groundCheck.position.y > collision.transform.position.y) { anim.SetBool("jumping", true); anim.SetBool("falling", false); rb.velocity = new Vector2(rb.velocity.x, jumpForce); //Destroy(collision.gameObject); //jumpAudio.Play(); ec.JumpOn(); } else if (transform.position.x <= collision.transform.position.x) { hitAudio.Play(); //GetComponent<CircleCollider2D>().sharedMaterial.friction = 10f; isHurt = true; rb.velocity = new Vector2(-5f, 0); //print("1111111111111"); } else if (transform.position.x > collision.transform.position.x) { hitAudio.Play(); //GetComponent<CircleCollider2D>().sharedMaterial.friction = 10f; isHurt = true; rb.velocity = new Vector2(5f, 0); //print("2222222222222"); } } }
void Start() { health = 100; enControl = GetComponent <EnemyControl>(); enAI = GetComponent <EnemyAI>(); }
public void GoalSelection(EnemyControl enemy, string name) { if (_listHero.Count <= 0) { StaticLevelManager.IsGameFlove = false; return; } HeroControl hero; if (name == "ground") { hero = GetNearestHero(enemy.HexagonMain()); } else { hero = GetNearestHeroMag(enemy.HexagonMain()); } if (hero == null) { Debug.LogError("No free hero"); return; } hero.AddNewEnemy(enemy); enemy.HeroTarget = hero; enemy.StartWay(hero); }
private void Start() { EnemyControl = GameObject.Find("enemy_spaceship").GetComponentInChildren <EnemyControl>(); SetCooling(Random.Range(0.5f, 1.7f)); SetGravityBullet(Random.Range(0.8f, 1.5f)); SetSkinLaser(Random.Range(0, Skins.skin_laseru.Length)); }
public void SpawnEnemy() { EnemyControl newEnemy = CheckForAvailableGarbageEnemy(); UnitStatsUI newEnemyUI = CheckForAvailableGarbageEnemyUI(); Transform spawnPoint = FindFurthestSpawnPoint(); if (newEnemy == null) { //Instantiate. newEnemy = Instantiate(prefabEnemy, spawnPoint.position, spawnPoint.rotation); newEnemyUI = Instantiate(prefabEnemyStatUI, Vector3.zero, Quaternion.identity); newEnemyUI.transform.SetParent(prefabEnemyStatUI.transform.parent, true); newEnemyUI.transform.localScale = Vector3.one; RectTransform rtUI = newEnemyUI.transform as RectTransform; rtUI.SetAsFirstSibling(); listGarbageEnemies.Add(newEnemy); listGarbageEnemyUIs.Add(newEnemyUI); } else { newEnemy.transform.position = spawnPoint.position; } newEnemy.gameObject.SetActive(true); //Pair UI and unit. newEnemyUI.tUnit = newEnemy.transform; newEnemy.statsUI = newEnemyUI; newEnemyUI.gameObject.SetActive(true); newEnemy.Init(); }
void Start() { physic = GetComponent <Rigidbody2D>(); enemy = GameObject.FindGameObjectWithTag("enemy"); enemyControl = enemy.GetComponent <EnemyControl>(); physic.AddForce(EnemyControl.getDirection() * 1000); }
internal void makeVisible() { if (!isVisible) { isVisible = true; switch (thisIs) { case Immovables.Wall: GameObject.Instantiate(GameManagerScript.Wall, myPosition, Quaternion.identity); break; case Immovables.Space: GameObject.Instantiate(GameManagerScript.Wall, myPosition + Vector3.down, Quaternion.identity); break; } generateItemGOHere(GameManagerScript.items); if ((EnemyHere != null) && !EnemyHere.GOCreated) { EnemyControl newMonster = MonsterManager.create(EnemyHere); newMonster.transform.position = myPosition; } } }
private void SpawnEnemies() { Dictionary <string, float> dictionary = EnemyControl.Spawn(enemy, amount, spawnTime, timer); timer = dictionary["timer"]; amount = System.Convert.ToInt32(dictionary["amount"]); }
public void SetUp(EnemyControl control, Player player, BulletManager bulletManager) { _enemyControl = control; _player = player; _bulletManager = bulletManager; rb = GetComponent <Rigidbody>(); }
void Start() { control = GetComponentInParent<EnemyControl>(); sprite = GetComponent<SpriteRenderer>(); dmgMotionColor = new Color(1.0f, 0.2f, 0.2f, 0.8f); dmgMotionTimer = 0; }
void Start() { scaleX = transform.localScale.x; scaleY = transform.localScale.y; ps = GetComponent <EnemyControl> (); }
void Throw() { isHolding = false; enemyControl.transform.parent = null; enemyControl.GetComponent <Rigidbody> ().AddForce(transform.forward * throwStrength, ForceMode.Impulse); enemyControl = null; }
IEnumerator StartCheck() { WaitForSeconds cd = new WaitForSeconds(coolDown); EnemyInfor infor = new EnemyInfor(); infor.hp = Mathf.RoundToInt(control.inforEnemy.hp / hpFactor); infor.duplicate = null; infor.isDuplicate = false; infor.spawnBuffDebuff = false; infor.sizeScale = 1; infor.coinAmount = 0; yield return(new WaitForSeconds(coolDown / 2)); while (true) { float startAngle = UnityEngine.Random.Range(0, 360); for (int i = 0; i < numberOfShoot; i++) { EnemyControl enemyControl = EnemyFactory.instance.CreateEnemy(prefab.gameObject); enemyControl.transform.position = transform.position; enemyControl.Setup(infor, false, false); enemyControl.SetDirection(startAngle); startAngle = startAngle.NextAngle(360 / numberOfShoot); } yield return(cd); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.transform.CompareTag("Wall")) { Destroy(gameObject); Explosion(); } //if (coll.transform.CompareTag("Block")) //{ // Destroy(coll.transform.gameObject); // Destroy(gameObject); //} if (coll.transform.CompareTag("Enemy")) { EnemyControl enemy = coll.transform.GetComponent <EnemyControl>(); enemy.HP -= damage; Destroy(gameObject); Explosion(); } if (coll.transform.CompareTag("Player")) { PlayerControler player = coll.transform.GetComponent <PlayerControler>(); player.HP -= damage; Destroy(gameObject); Explosion(); } if (coll.transform.CompareTag("Base")) { Destroy(gameObject); Explosion(); GameControl.Base_HP -= damage; } }
void AlertAlliesInRadius(float radius, bool onlyIfVisible = true) { if (radius <= 0.0f) { return; } Collider[] colliders = Physics.OverlapCapsule(transform.position, transform.position + new Vector3(0, 5, 0), radius); foreach (Collider c in colliders) { EnemyControl ally = c.GetComponent <EnemyControl>(); if (ally == null) { continue; } if (c.gameObject == gameObject) { continue; } if (onlyIfVisible) { if (!IsVisible(c.bounds.center)) { continue; } } ally.Alert(targetEnemy); } }
// Start is called before the first frame update void Start() { ratController = GetComponent <CharacterController>(); ratCollider = GetComponent <BoxCollider>(); Player = GameObject.Find("Player"); enemyControl = FindObjectOfType <EnemyControl>(); }
public static GameObject GetTargetedEnemy(GameObject turret, float range) { // Get all enemies in range // List<GameObject> enemiesInRange = (from enemy in GameObject.FindGameObjectsWithTag("Enemy") // where Vector3.Distance(turret.transform.position, enemy.transform.position) <= range // select enemy).ToList(); // // // Sort by relative distance // enemiesInRange.Sort((e1, e2) => DistanceBetween(turret.transform, e1.transform).CompareTo(DistanceBetween(turret.transform, e2.transform))); // // // Return the closest one // return enemiesInRange.Count > 0 ? enemiesInRange[0] : null; GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); float maxPriority = 0; GameObject target = null; foreach (GameObject i in enemies) { EnemyControl enemyScript = i.GetComponent <EnemyControl>(); if (enemyScript != null) { if ((enemyScript.GetPriority() > maxPriority) && (range > DistanceBetween(turret.transform, i.transform))) { target = i; maxPriority = enemyScript.GetPriority(); } } } return(target); }
/*private void OnTriggerEnter2D(Collider2D other) redundant code * { * if (other.gameObject.tag=="Destructable") * { * hits = true; * objectHealth = 1; * } * if (other.gameObject.tag == "Enemy") * { * hits = true; * objectHealth = 2; * * } * * }*/ void Shoot() { Vector2 mousePosition = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y); Vector2 firePointPosition = new Vector2(firePoint.position.x, firePoint.position.y); RaycastHit2D hit = Physics2D.Raycast(firePointPosition, mousePosition - firePointPosition, 100, notToHit); Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition) * 100, Color.white); if (hit.collider != null) { EnemyControl enemy = hit.transform.GetComponent <EnemyControl>(); dWall weakWall = hit.transform.GetComponent <dWall>(); Debug.DrawLine(firePointPosition, hit.point, Color.red); Debug.Log("We hit " + hit.collider.name + " and did " + Damage + " damage."); if (hit.collider.tag == "Destructable") { weakWall.WallHit(); } else if (hit.collider.tag == "Enemy") { enemy.EnemyHit(); } } ; }
void OnTriggerEnter2D(Collider2D coll) { if (!coll.isTrigger) { if (coll.transform.CompareTag("Wall")) { Destroy(gameObject); } if (coll.transform.CompareTag("Block")) { Destroy(coll.transform.gameObject); Destroy(gameObject); } if (!isEnemy) { if (coll.transform.CompareTag("Enemy")) { EnemyControl enemy = coll.transform.GetComponent <EnemyControl>(); enemy.HP -= damage; Destroy(gameObject); } } else { if (coll.transform.CompareTag("Player")) { PlayerControl player = coll.transform.GetComponent <PlayerControl>(); player.HP -= damage; Destroy(gameObject); } } } }
// Use this for initialization void Start() { pc = FindObjectOfType <PlayerControl>(); ec = FindObjectOfType <EnemyControl>(); cm = FindObjectOfType <ConnectionManager>(); hpt = new Texture2D(2, 2); }
// 공격범위 및 판정 함수 private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Enemy") { ControllerScript _player = GameObject.FindWithTag("Player").GetComponent <ControllerScript>(); EnemyControl enemyCtrl = other.gameObject.GetComponent <EnemyControl>(); // 충돌한 오브젝트의 스크립트 받음 float damage = 0; if (gameObject.name == "FAttackBound") { damage = _player.attackDamage[0]; } else if (gameObject.name == "SAttackBound") { damage = _player.attackDamage[1]; } else if (gameObject.name == "TAttackBound") { damage = _player.attackDamage[2]; } else { damage = 0f; } enemyCtrl.HP -= damage; } }
void Update() { //***Saliendo del juego*** if (Input.GetKeyDown(KeyCode.Escape)) { if (Application.platform == RuntimePlatform.Android) { AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity"); activity.Call <bool>("moveTaskToBack", true); } else { Application.Quit(); } } //***Finalizando juego - Ya no hay enemigos*** enemyCtr = FindObjectOfType <EnemyControl>(); if (enemyCtr == null) { //***Ganó el juego*** ProjectVars.Instance.tiempoGanador = TiempoEscena; //***Tiempo que tomó en ganar*** finJuego(true); } //***Actualizando el tiempo restante*** ActualizarTiempo(); }
public void SpawnEnemy(GameObject GO, Vector3 Loc, float Speed, int Angle) { EnemyControl Temp = Object.Instantiate(GO, Loc, Quaternion.identity).GetComponent <EnemyControl>(); Temp.SetSpeed(Speed); Temp.SetFacing(Angle); }
// Increment player score void addPoints() { // Find the enemy that was killed, and add the points value to the player score EnemyControl enemy = FindObjectOfType <EnemyControl>(); GameControl.control.score += enemy.points; }
private void create(Creature creature) { GameObject itemGO = (GameObject)Instantiate(Resources.Load(creature.modelFilename)); EnemyControl newMonster = itemGO.AddComponent <EnemyControl>(); newMonster.youAreA(creature); }
void Send() { foreach (Transform firepoint in firepoints) { GameObject bullet = Instantiate(enemyPrefab, firepoint.position, firepoint.rotation); EnemyControl Ai = bullet.GetComponent <EnemyControl>(); if (Ai != null && target != null) { Ai.setTarget(target); Ai.setMultiplier(dificultyMultiplier); } DropReward Rw = bullet.GetComponentInChildren <DropReward>(); if (Rw != null) { Rw.control = control; } Bullet Bll = bullet.GetComponent <Bullet>(); if (Bll != null) { Bll.damage = (int)(Bll.damage * dificultyMultiplier); } Spawn Sp = bullet.GetComponentInChildren <Spawn>(); if (Sp != null) { Sp.control = control; } Rigidbody Rb = bullet.GetComponent <Rigidbody>(); if (Rb != null) { Rb.AddForce(firepoint.forward * sendForce, ForceMode.Impulse); } } }
// Constructor which initializes static cell information and calculates static score public FactoryCellInfo(int cellNum, GameObject[] cellArray, float[][] distanceArray) { enemyControl = GameObject.Find("Level Control").GetComponent <EnemyControl>(); // Store static cell info factoryCellGameObject = cellArray[cellNum]; cellControlScript = factoryCellGameObject.transform.GetComponent <FactoryCellControl> (); cellFaction = cellControlScript.faction; maxNumDrones = cellControlScript.maxNumDrones; produceDroneNumTicks = cellControlScript.produceDroneNumTicks; // Set playerFaction bonus weight when cell faction is player if (cellFaction == Faction.Player) { playerFactionBonus = enemyControl.enemyFactionWeight; } // Set isPlayerFaction to give no bonus weight when cell not player else { playerFactionBonus = 1; } // Calculate static cell value cellValue = playerFactionBonus * (((maxNumDrones * enemyControl.droneCapacityWeight / 10f) + (enemyControl.droneProductionWeight * 200f / produceDroneNumTicks))) / 2; // Store distance array of distances between this cell and all others distanceFromThisCellArray = distanceArray [cellNum]; }
private void Shoot() { Vector3 placeExpl = new Vector3(); StartCoroutine(ShowShoot()); Ray ray = new Ray(shootAncor.position, shootAncor.forward); RaycastHit[] raycastHits = Physics.SphereCastAll(ray, radiusOFShoot, maxDistanceOfShoot, shootLayerMask); foreach (RaycastHit hit in raycastHits) { EnemyControl curEnemyControl = hit.collider.GetComponent <EnemyControl>(); if (curEnemyControl) { if (placeExpl == default) { placeExpl = hit.collider.transform.position; } curEnemyControl.DestroyObj(); gameBuilder.IncreaseEnemyHealth(); } } if (placeExpl != Vector3.zero) { exposion.SetActive(true); exposion.transform.position = placeExpl; //exposion.transform.position = transform.position; exposion.transform.rotation = transform.rotation; pSexposion.Play(); StartCoroutine(StopExplotion()); } //Debug.DrawRay(shootAncor.position, shootAncor.forward * maxDistanceOfShoot, Color.red, 1000f); }
// Use this for initialization void Start() { playerControl = GetComponent<PlayerControl>(); playerTransform = gameObject.transform; enemy = GameObject.FindGameObjectWithTag("Enemy"); path = enemy.GetComponent<AIPath>(); enemyControl = enemy.GetComponent<EnemyControl>(); duration = gem.duration; startTime = Time.time + 2; check = true; }
// ================================================================ // // 방해 캐릭터에 닿았을 때 호출된다. public void onTouchEnemy(EnemyControl enemy) { do{ if(this.step == STEP.TOUCH_ENEMY) break; if(this.step == STEP.MISS) break; if(this.step == STEP.OUT) break; this.next_step = STEP.TOUCH_ENEMY; Debug.Log("miss"); }while(false); }
void Start() { anim = GetComponent<Animator>(); enemy = GameObject.FindGameObjectWithTag ("Enemy").GetComponent<EnemyControl>(); }
public void EnemyDied(EnemyControl who) { enemies.Remove(who); checkEnemies(); }