private void OnBecameVisible() { boxCollider.isTrigger = false; if (GameController.Instance.getSpeed() <= -3.3f) { typeEnemyIndex = Random.Range(0, 3); } else if (GameController.Instance.getSpeed() <= -3.15f) { typeEnemyIndex = Random.Range(0, 2); } else { typeEnemyIndex = 0; } typeEnemy = (TypeEnemy)typeEnemyIndex; switch (typeEnemy) { case TypeEnemy.Melee: StartCoroutine("CheckDistance", new Vector2(10f, 10f)); break; case TypeEnemy.Attack: StartCoroutine("CheckDistance", new Vector2(2.5f, 0.5f)); break; case TypeEnemy.Ranged: StartCoroutine("CheckDistance", new Vector2(8f, 5f)); break; } }
public Enemy(TypeEnemy type) { this.type = type; x = rn.Next(0, Convert.ToInt32(Form1.window.Size.X)); y = rn.Next(0, 100); r = 5; //Resources.Loadfield(); //color1 = Color.Red; switch (type) { case TypeEnemy.HITHER: rectangleShape = new RectangleShape(new SFML.System.Vector2f(50, 50)); rectangleShape.Texture = Resources.en_texture; hp = 2; break; case TypeEnemy.DISTANT: rectangleShape = new RectangleShape(new SFML.System.Vector2f(50, 50)); rectangleShape.Texture = Resources.en1_texture; hp = 2; break; } }
void Start() { if (transform.childCount > 0) { this.m_TypeEnemy = TypeEnemy.RockCrack; } }
public EnemyIndex(string[] data) { this.id = int.Parse(data[0]); this.type = data[1]; this.typeEnemy = GetPlayerTypeByString(type); this.speed = float.Parse(data[2]); this.level = int.Parse(data[3]); this.hp = float.Parse(data[4]); this.damge = float.Parse(data[5]); }
public TypeEnemy Choose() { TypeEnemy typeEnemy = 0; int randValue = Random.Range(0, maxProbability); while (lootProbabilities [(int)typeEnemy] <= randValue) { typeEnemy++; } return(typeEnemy); }
public void SpawnEnemy(TypeEnemy typeEnemy) { EnemyController controller; EnemyModel model; EnemyView view; int numPrefab = Convert.ToInt32(typeEnemy); _enemySpawnManager.SpawnEnemy(_enemyDatas[numPrefab], _enemyPrefabs[numPrefab], _fieldBoundary, out controller, out model, out view); controller.Destroy += DestroyEnemy; _controllerModelPairs.Add(controller, model); _viewModelPairs.Add(view, model); _enemyModels.Add(model); }
public void ApplyBehaviourGoBack(TypeEnemy whatType) { switch (whatType) { case TypeEnemy.Ghost: Vector3 dir02 = transform.position - playerPos.transform.position; transform.Translate(dir02.normalized * speedEnemy * Time.deltaTime, Space.World); break; case TypeEnemy.Bomb: CleanBomb(); break; } }
public void CheckBehaivourTypeEnemy(States whatState, TypeEnemy whatType) { switch (whatState) { case States.Idle: ApplyBehaviourIdle(whatType); break; case States.Attack: ApplyBehaviourAttack(whatType); break; case States.GoBack: ApplyBehaviourGoBack(whatType); break; } }
public void SetEnemyData(EnemyData enemyData, int level) { if (enemyData == null) { return; } _name = enemyData.Name; _typeEnemy = enemyData.TypeEnemy; _lifePoints = enemyData.Stats.Constitution + Mathf.RoundToInt(enemyData.Stats.Constitution * enemyData.IncreaseByLevel[0] * level); _actualLifePoints = _lifePoints; _damage = enemyData.Stats.Strength + Mathf.RoundToInt(enemyData.Stats.Strength * enemyData.IncreaseByLevel[1]); _damageReduction = Mathf.RoundToInt(Mathf.Clamp(enemyData.Stats.Defense + Mathf.RoundToInt(enemyData.Stats.Defense * enemyData.IncreaseByLevel[2]), 0f, 45f)); _criticChance = Mathf.RoundToInt(Mathf.Clamp(enemyData.Stats.Luck + Mathf.RoundToInt(enemyData.Stats.Luck * enemyData.IncreaseByLevel[3]), 0f, 50f)); _animator = gameObject.GetComponent <Animator>(); _animator.runtimeAnimatorController = enemyData.AnimatorController; _sprite = Resources.Load(ControlManager.Instance.PathToEnemySprites + enemyData.SpriteName, typeof(Sprite)) as Sprite; gameObject.GetComponent <Image>().sprite = _sprite; gameObject.GetComponent <Image>().color = new Color(255f, 255f, 255f, 1f); }
public EnemiesController GetPooledEnemy(TypeEnemy typeEnemy) // выдергиваем нужный на объект по типу (допустим нам нужен слон) { for (int i = 0; i < enemiesByTypes.Count; i++) // пробегаемся по списку создаанных объектов разного типа { if (enemiesByTypes[i].typeEnemy == typeEnemy) // и если это слон { for (int j = 0; j < enemiesByTypes[i].enemiesControllers.Count; j++) // проходим по листу слонов { if (!enemiesByTypes[i].enemiesControllers[j].gameObject.activeSelf) { return(enemiesByTypes[i].enemiesControllers[j]); // вернуть первого слона из списка объектов(контроллеров) типа слона } } EnemiesController enemiesController = Instantiate(enemyInfo[i].enemyPrefab, enemyInfo[i].spawnPoint.position, Quaternion.identity, enemiesParent); enemiesController.gameObject.SetActive(false); enemiesController.Init(playerController, OnEnemyDieHandler); enemiesByTypes[i].enemiesControllers.Add(enemiesController); return(enemiesController); } } return(null); }
public void ApplyBehaviourIdle(TypeEnemy whatType) { switch (whatType) { case TypeEnemy.Ghost: if (timerMoveErra <= timeUntilMoveErractically) { timerMoveErra += Time.deltaTime; } else if (timerMoveErra >= timeUntilMoveErractically) { ApplyMoveErratically(); } break; case TypeEnemy.Bomb: if (Physics.CheckSphere(transform.position, radiusDetectPlayer, player) && !timeToExplode) { myCurrentState = States.Attack; } break; } }
public GameObjectAnimeEnemy(TypeEnemy typeEnemy) { estVivant = true; //tabEnemy[i].direction = Vector2.Zero; switch (typeEnemy) { case TypeEnemy.RedMoblin: //Enemy imgEnemy = "Images\\Enemy_RedMoblin.png"; vitesse = 2; secondeAttente = rnd.Next(0, 5); etat = (Etat)rnd.Next(0, 6); // Missile arme = new GameObjectAnime_Missile(); //InitializeArme(2, 3); imgMissile = "Images\\Enemy_Missile.png"; //InitializeArme(2, 3); break; case TypeEnemy.BlueMoblin: //Enemy imgEnemy = "Images\\Enemy_BlueMoblin.png"; vitesse = 1; secondeAttente = rnd.Next(0, 3); etat = (Etat)rnd.Next(0, 6); // Missile arme = new GameObjectAnime_Missile(); //InitializeArme(4, 1); imgMissile = "Images\\Enemy_Missile.png"; //InitializeArme(4, 1); break; default: break; } }
// // // public void SpawnEnemy(int roomLvl, Vector2 location, TypeEnemy type) {//Instantiate the Enemy(ies), add him to the collection, then add effects(sounds, ...) Enemy es; switch (type) { case TypeEnemy.BOW: es = GameObject.Instantiate(Resources.Load <EnemyBow>(PrefabsDir.enemyBDir)).GetComponent <Enemy>(); break; case TypeEnemy.SWORD: es = GameObject.Instantiate(Resources.Load <EnemySword>(PrefabsDir.enemyDir)).GetComponent <Enemy>(); break; default: Debug.LogError("Unhandled switch : " + type); goto case TypeEnemy.BOW; } es.transform.position = location; es.Init(); AddEnemy(es); }
//private object random; public void Update(TypeEnemy type) { switch (type) { case TypeEnemy.HITHER: break; case TypeEnemy.DISTANT: if (Position.Y >= 550) { text3.Font = Resources.font; text3.DisplayedString = "Поражение"; text3.CharacterSize = 34; text3.Color = Color.White; text3.Position = new Vector2f(Form1.window.Size.X / 2 - 50, Form1.window.Size.Y / 2); Form1.PlayGame = false; Game.xmldocwrie(); } UpdPhysic(); Position = new Vector2f(Position.X, enemyPos.Y); break; } }
void CreateEntity(TypeEnemy type) { GameObject newEnemy; switch (type) { case TypeEnemy.loulpe: newEnemy = Instantiate(loulpe, EnemiesParent) as GameObject; break; case TypeEnemy.castureuil: newEnemy = Instantiate(castureuil, EnemiesParent) as GameObject; break; case TypeEnemy.cerfbourse: newEnemy = Instantiate(cerfbourse, EnemiesParent) as GameObject; break; default: newEnemy = Instantiate(loulpe, EnemiesParent) as GameObject; break; } newEnemy.transform.position = CalNewPos(); }
public List <EnemiesController> enemiesControllers; // лист(пул) этих врагов public EnemiesByType(TypeEnemy typeEnemy) { this.typeEnemy = typeEnemy; enemiesControllers = new List <EnemiesController>(); }
public void SetPosition(TypeEnemy type, int i) { enemies[i] = new Enemy(type); enemies[i].Position = new Vector2f(random.Next(0, Convert.ToInt32(Form1.window.Size.X) - 50), random.Next(0, Convert.ToInt32(Form1.window.Size.Y) - 400)); }
public void ApplyBehaviourAttack(TypeEnemy whatType) { switch (whatType) { case TypeEnemy.Ghost: if (lookedThePlayer) { if (transform.position == posToChaseAndAttack) { if (Vector3.Distance(transform.position, playerPos.transform.position) >= minimumDistanceToChase) { lookedThePlayer = false; myCurrentState = States.Idle; } else { alreadyPlaceTheTarget = false; } } if (!alreadyPlaceTheTarget) { float posX = playerPos.gameObject.transform.position.x - playerPos.gameObject.transform.localScale.x; float posZ = playerPos.gameObject.transform.position.z - playerPos.gameObject.transform.localScale.z; posToChaseAndAttack = new Vector3(posX, 0, posZ); posToChaseAndAttack.y = gameObject.transform.localScale.y + theTerrain.SampleHeight(posToChaseAndAttack); alreadyPlaceTheTarget = true; } transform.position = Vector3.MoveTowards(transform.position, posToChaseAndAttack, speedEnemy * Time.deltaTime); transform.LookAt(posToChaseAndAttack, Vector3.up); Debug.Log("Distancia enemigo player = " + Vector3.Distance(transform.position, playerPos.transform.position)); if (Vector3.Distance(transform.position, playerPos.transform.position) <= 1.5f) { alreadyPlaceTheTarget = false; lookedThePlayer = false; myCurrentState = States.GoBack; } } else { randomPosCreated = false; } break; case TypeEnemy.Bomb: if (Physics.CheckSphere(transform.position, radiusDetectPlayer, player)) { timeToExplode = true; playerEscapes = false; } else { playerEscapes = true; } if (timeToExplode) { if (timerToExplode <= timeUntilExplode) { timerToExplode += Time.deltaTime; } else { CreateExplosion(); if (!playerEscapes) { AttackPlayer(); } } } break; } }