public EnemyCharacter[] CreateUniqueCharacters() { EnemyCharacter[] retValue = new EnemyCharacter[characterConfigs.Length]; Dictionary<string, int> nameCountMap = new Dictionary<string, int>(); Dictionary<string, char> namePrefixMap = new Dictionary<string, char>(); // generate unique enemy characters and populate our duplicate name maps for(int i=0; i < characterConfigs.Length; i++) { // first copy over the NPC into the same spot so they are unique retValue[i] = (EnemyCharacter) Character.CreateFromConfig(characterConfigs[i]); EnemyCharacter enemy = retValue[i]; // store count of name appearance // if we've seen it more than once, increment the count and prefix map if(nameCountMap.ContainsKey(enemy.displayName)) { nameCountMap[enemy.displayName] = nameCountMap[enemy.displayName] + 1; namePrefixMap[enemy.displayName] = 'A'; // set the first letter of multiple enmies to be 'A' } else { nameCountMap[enemy.displayName] = 1; } } // clean up any duplicate names for(int i=0; i < retValue.Length; i++) { EnemyCharacter enemy = retValue[i]; string origName = enemy.displayName; if(namePrefixMap.ContainsKey(origName)) { enemy.displayName = origName + " " + namePrefixMap[origName]; namePrefixMap[origName] = namePrefixMap[origName]++; } } return retValue; }
public GameApi() { this.shop = new Shop(this); this.camera = new Camera(this); this.chat = new Chat(this); this.player = new MainPlayer(this); this.allyMinion = new AllyMinion(this); this.enemyMinion = new EnemyMinion(this); this.allyCharacter = new AllyCharacter(this); this.enemyCharacter = new EnemyCharacter(this); }
public void GenerateEnemy(List <EncountEnemy> enemies) { List <Vector2> enemyPos = new List <Vector2>() { Vector2Int.zero, new Vector2Int(5, 0), new Vector2Int(-5, 0) }; for (int i = 0; i < enemies.Count; i++) { GameObject enemy = Instantiate(enemyEntity); enemy.transform.position = enemyPos[i]; //グラフィックの設定 SpriteRenderer sprite = enemy.GetComponent <SpriteRenderer>(); sprite.sprite = enemies[i].enemy.graphic; //ステータスの設定 EnemyCharacter enemyCharacter = enemy.GetComponent <EnemyCharacter>(); //EnemyDataの値を書き換えないようにするためコピーしたものを使います enemyCharacter.enemyData = ScriptableObject.Instantiate(enemies[i].enemy); enemyCharacter.status = enemyCharacter.enemyData.status; //名前の設定 enemyCharacter.gameObject.name = enemyCharacter.CharacterName; enemyCharacter.gameObject.transform.SetParent(gameObject.transform); enemyCharacters.Add(enemyCharacter); } //同じ名前の敵が2体以上存在する時、識別のためにアルファベットを付け足します //同じな名前の敵でグルーピングします var enemyGroup = enemyCharacters.GroupBy(x => new { Name = x.CharacterName }); foreach (var group in enemyGroup) { if (group.Count() >= 2) { //同じ名前の敵が2体以上格納されているListです var groupEnemy = group.ToList(); //ASCIIコード65はAです int ASCII_Code = 65; for (int i = 0; i < groupEnemy.Count; i++) { string newName = groupEnemy[i].CharacterName + (char)ASCII_Code++; groupEnemy[i].CharacterName = newName; groupEnemy[i].gameObject.name = newName; } } } }
public List <EnemyCharacter> AssembleBossEnemyCharacter(int id) { List <EnemyCharacter> list = new List <EnemyCharacter>(); EnemyCharacter enemy = new EnemyCharacter(enemyBossData[id]); //rand.Next(0, enemyBasicData.Count) enemy.CharacterStatus = new CharacterStatus(enemy.CharacterStats); list.Add(enemy); return(list); }
public override AIBase fixedLogicTick() { EnemyCharacter e = queryInRange <EnemyCharacter>(); if (e != null) { return(new AttackingAI(e)); } return(null); }
// some characteristics about the enemy to start void Start() { enemyHealth = this.GetOrAddComponent <EnemyHealth> (); enemyAttack = this.GetOrAddComponent <EnemyAttack> (); enemyCharacter = this.GetOrAddComponent <EnemyCharacter> (); enemyAttack.attackDamage = baseDamage + weaponDamage; enemyHealth.currentHealth = enemyCurrentHealth; enemyHealth.maxHealth = enemyMaxHealth; enemyCharacter.gameObjectPlayerName = enemyName; }
public void SetUpEnemyTurn() { EnemyCharacter[] e = GameObject.FindObjectsOfType <EnemyCharacter>(); foreach (EnemyCharacter eC in e) { EvilDoerStack.Push(eC); } if (EvilDoerStack.Count > 0) { activeCharacter = EvilDoerStack.Pop(); } }
// Update is called once per frame void Update() { if (gameState != EGameState.victoryScreen || gameState != EGameState.failureScreen) { if (Input.GetKeyUp(KeyCode.LeftBracket)) // For Debug purposes. { KillAllPlayers(); } else if (Input.GetKeyUp(KeyCode.RightBracket)) // For Debug purposes. { KillAllEnemies(); } if (gameState == EGameState.playerTurn) { if (Input.GetKeyUp(KeyCode.LeftAlt)) { for (int i = 0; i < playerContainer.transform.childCount; i++) { GameObject obj = playerContainer.transform.GetChild(i).gameObject; PlayerCharacter pc = obj.GetComponent <PlayerCharacter>(); pc.actionPips = 0; ProcessGameState(); } } } if (gameState == EGameState.enemyTurn) { if (Input.GetKeyUp(KeyCode.RightAlt)) { for (int i = 0; i < enemyContainer.transform.childCount; i++) { GameObject obj = enemyContainer.transform.GetChild(i).gameObject; EnemyCharacter ec = obj.GetComponent <EnemyCharacter>(); ec.actionPips = 0; ProcessGameState(); } } } PlayerDeathCheck(); EnemyDeathCheck(); } if (gameState == EGameState.movement) { EnemyManager enemyManager = GameObject.FindObjectOfType <EnemyManager>(); PlayerManager playerManager = GameObject.FindObjectOfType <PlayerManager>(); activeCharacter = enemyManager.activeCharacter != null ? (CharacterBase)enemyManager.activeCharacter : playerManager.selectedPlayer.GetComponent <CharacterBase>(); activeCharacter.MoveCharacterAlongTilePath(); playerManager.SetupCameraPosition(); } }
public void DecreaseEnemyCount(EnemyCharacter enemy) { enemyValue--; for (int i = 0; i < enemies.Count; i++) { if (enemies.Contains(enemy)) { enemies.Remove(enemy); break; } } }
public IEnumerator StartFightCoroutine(PlayerCharacter characterA, EnemyCharacter characterB) { if (isFighting) { yield break; } isFighting = true; canvas.SetActive(true); previousMusic = music.clip; music.clip = battleMusic; music.Play(); talkTier = 0; player = characterA; enemy = characterB; egoText.text = player.ego.ToString(); egoEnemyText.text = enemy.ego.ToString(); DisplayItems(player); enemyImage.sprite = enemy.texture; GameObject panel = abilityMenuObject.GetComponentInChildren <GridLayoutGroup> ().gameObject; foreach (ItemType ability in player.abilityList) { GameObject go = Instantiate(buttonPrefab); go.transform.SetParent(panel.transform); ButtonController bc = go.GetComponent <ButtonController> (); bc.InitButton(ability.ToString(), ability, this); } //textObject.text = string.Format ("You pick a fight with {0}!", enemy.characterName); textDisplayObject.SetText(string.Format("You pick a fight with {0}!", enemy.characterName)); if (OpenSound != null) { AudioSource.PlayClipAtPoint(OpenSound, Camera.main.transform.position); } Fader.FadeIn(Color.black, fadeInTime); yield return(WaitForInput()); //new WaitForSeconds (2f); yield return(StartCoroutine(textDisplayObject.DisplayTextCoroutine(enemy.data.intros, enemy.color))); DisplayFightMenu(); }
// 增加客户的人物模组 private EnemyCharacter AddEnemyCharacter(int id) { GameObject p = GameObject.Instantiate(mEnemyCharacter); EnemyCharacter ec = p.GetComponent <EnemyCharacter>(); // 修改ID ec.SetID(id); // 加入到哈希表 _htEnemies.Add(id, ec); return(ec); }
private void ShowEnemyDamage(string damage, EnemyCharacter enemy) { TextBlock txtBlk = null; var i = App.charactersLists.EnemyList.IndexOf(enemy); var canvas = (Canvas)MonsterField.Children[i]; var grid = (Grid)canvas.Children[1]; txtBlk = (TextBlock)grid.Children[0]; txtBlk.Text = damage; damageInfo.SetTickTimer(txtBlk, BattleTimer); }
public void EnemyCollisionWithMusicInstrumentCase(InGameMazeTile tile, EnemyCharacter enemy, MusicInstrumentCase musicInstrumentCase) { if (GameRules.GamePlayerType == GamePlayerType.SinglePlayer || GameRules.GamePlayerType == GamePlayerType.SplitScreenMultiplayer) { musicInstrumentCase.EnemyCollisinOnTile(enemy); } else // network multiplayer { EnemyCollidesWithMusicInstrumentCaseEvent enemyCollidesWithMusicInstrumentCaseEvent = new EnemyCollidesWithMusicInstrumentCaseEvent(); enemyCollidesWithMusicInstrumentCaseEvent.SendEnemyCollidesWithMusicInstrumentCaseEvent(tile.GridLocation, enemy); } }
public void ModifyHealth(EnemyCharacter ec, int value) { int index = enemyStats.FindIndex(x => x.ec == ec); if (index != -1) { EnemyStats es = enemyStats[index]; //print("Original health: " + es.Health); es.Health += value; //ec.SetHealth(es.Health); print(ec.gameObject.name + " Enemy health changed " + value + "!"); } }
private void RandomEnemyCharacterMake() { if (enemyValue < 5) { int randomEnemyValue = Random.Range(0, enemyCharacter.Length); int randomPositionValue = Random.Range(1, enemyCreatePosition.transform.childCount - 1); GameObject tmpCivil = Instantiate(enemyCharacter[randomEnemyValue], enemyCreatePosition.transform.GetChild(randomPositionValue).position, Quaternion.identity); EnemyCharacter enemy = tmpCivil.GetComponent <EnemyCharacter>(); enemy.SetEnemyCharacterManager(this); enemies.Add(enemy); enemyValue++; enemies[enemyValue - 1].Init(enemyCreatePosition, randomPositionValue); } }
private void InstantiateEnemies() { m_enemies = new List <EnemyCharacter>(); for (int i = 0, count = m_level.Data.Enemies.Count; i < count; i++) { if (i < m_levelEntity.EnemySpawnPoints.Count) { var newEnemy = new EnemyCharacter(m_level.Data.Enemies[i], this); newEnemy.CreateEntity(m_levelEntity.EnemySpawnPoints[i].SpawnPosition.position); newEnemy.Entity.SetDirection(CharacterEntity.EDirection.Left); m_enemies.Add(newEnemy); } } }
// Start is called before the first frame update void Start() { behaviorTree = gameObject.GetComponent <BehaviorTree>(); if (!behaviorTree) { print("Error, can't find BT"); } character = gameObject.GetComponent <EnemyCharacter>(); if (!character) { print(gameObject.name + "doesn't has EnemyCharacter.cs"); Destroy(gameObject); } }
float distance; // void Start() { enemy = GetComponentInParent <EnemyCharacter>(); healthSlider = GetComponentInChildren <Slider>(); rectTran = healthSlider.GetComponent <RectTransform>(); var headPos = new Vector3(enemy.gameObject.transform.position.x, enemy.gameObject.transform.position.y + height, enemy.gameObject.transform.position.z); distance = Vector3.Distance(headPos, Camera.main.transform.position); fillImage = gameObject.transform.Find("Sld_Health/Fill Area/Fill").GetComponent <Image>(); foreColor = fillImage.color; this.gameObject.SetActive(false); }
void BattleWithTarget(GameObject enemy) { EnemyCharacter enemyChar = enemy.GetComponent <EnemyCharacter>(); UIManager.Instance.UpdateTargetEnemyInfo(enemyChar); foreach (PlayerCharacter pc in PartyManager.Instance.playerPartyList) { pc.State = Character.CharacterState.BATTLE; } enemyChar.EnterBattle(); //enemy.GetComponent<EnemyCharacter>().State = Character.CharacterState.BATTLE; }
private void OnSpawnedEnemyDeath(Character ch) { EnemyCharacter enemy = ch as EnemyCharacter; if (enemy == null) { return; } enemiesAlive.Remove(enemy); if (enemiesAlive.Count == 0) { Terminate(); } }
void DrawEnemySetting(EnemyCharacter enemy) { GUILayout.Label("Custom Enemy", EditorStyles.boldLabel); GUILayout.Space(5f); enemy.prefab = SetObject("BaseModel", enemy.prefab); GUILayout.Space(5f); enemy.enemyName = EditorGUILayout.TextField("Object Name", enemy.enemyName); GUILayout.Space(5f); enemy.startSpeed = SetFloat("StartSpeed", enemy.startSpeed); GUILayout.Space(5f); enemy.totalHealth = SetFloat("TotalHealth", enemy.totalHealth); GUILayout.Space(5f); enemy.turnSpeed = SetFloat("TurnSpeed", enemy.turnSpeed); GUILayout.Space(5f); enemy.color = EditorGUILayout.ColorField("Color", enemy.color); GUILayout.Space(5f); enemy.mesh = SetMesh("Mesh", enemy.mesh); GUILayout.Space(5f); enemy.dieEffect = SetObject("Die Effect", enemy.dieEffect); GUILayout.Space(5f); enemy.material = setMaterial("Material", enemy.material); GUILayout.Space(10f); if (enemy.prefab == null) { EditorGUILayout.HelpBox("This enemy needs a [BaseModel] before it can be created.", MessageType.Warning); } else if (enemy.enemyName == null || enemy.enemyName.Length < 1) { EditorGUILayout.HelpBox("This enemy needs a [Name] before it can be created.", MessageType.Warning); } else if (GUILayout.Button("SAVE", GUILayout.Height(30))) { SaveData(); window.Close(); lazer = false; } }
/// <summary> /// This adds an enemy to the list. /// </summary> /// <param name="enemy">The enemy to add, of type EnemyCharacter</param> public void AddEnemy(EnemyCharacter enemy) { if (!enemy.IsDead) // Condition to add if enemy is not dead { _enemies.Add(enemy); // adding enemy // Checking if only 1 enemy is added then making the bot to // follow the first and only enemy if (_enemies.Count == 1) { BotState = CharacterState.MoveToEnemy; } } }
/// <summary> /// CharaClass,PlayerCharacter(EnemyCharacter)をアタッチ /// </summary> private void SetCharacter() { if (this.gameObject.CompareTag("Player")) { this.playerClass = GetComponent <PlayerCharacter>(); this.charaClass = PC.CharaClass; } else { this.enemyClass = GetComponent <EnemyCharacter>(); this.charaClass = EC.CharaClass; this.IsEnemy = true; } }
protected bool rotated = false; //check if rotation was set somewhere else void Start() { /**Gets called by unity when the script is initialized * */ anim = GetComponent <Animator>(); character = gameObject.GetComponent <EnemyCharacter> (); logic = gameObject.GetComponent <AI_Logic> (); agent = gameObject.GetComponent <NavMeshAgent> (); time = 0.0f; shootTimeOut = 0.0f; agent.stoppingDistance = character.stoppingRange; rand = new System.Random(); }
// Use this for initialization void Start() { string[] enemyTypes = transform.tag.Split('-'); //first index is enemy type, second index is enemy color if (enemyTypes[0].Equals("Slime")) { if (enemyTypes[1].Equals("Red")) { enemyCharacter = new EnemyCharacter(2, Character.Weapon.SWORD, EnemyCharacter.EnemyType.SLIME, EnemyCharacter.ColorType.RED); } else if (enemyTypes[1].Equals("Green")) { enemyCharacter = new EnemyCharacter(2, Character.Weapon.SWORD, EnemyCharacter.EnemyType.SLIME, EnemyCharacter.ColorType.GREEN); } else { enemyCharacter = new EnemyCharacter(2, Character.Weapon.SWORD, EnemyCharacter.EnemyType.SLIME, EnemyCharacter.ColorType.BLUE); } } else if (enemyTypes[0].Equals("Bat")) { if (enemyTypes[1].Equals("Red")) { enemyCharacter = new EnemyCharacter(1, Character.Weapon.BOW, EnemyCharacter.EnemyType.BAT, EnemyCharacter.ColorType.RED); } else if (enemyTypes[1].Equals("Green")) { enemyCharacter = new EnemyCharacter(1, Character.Weapon.BOW, EnemyCharacter.EnemyType.BAT, EnemyCharacter.ColorType.GREEN); } else { enemyCharacter = new EnemyCharacter(1, Character.Weapon.BOW, EnemyCharacter.EnemyType.BAT, EnemyCharacter.ColorType.BLUE); } } else if (enemyTypes[0].Equals("Skeleton")) { if (enemyTypes[1].Equals("Red")) { enemyCharacter = new EnemyCharacter(2, Character.Weapon.LANCE, EnemyCharacter.EnemyType.SKELETON, EnemyCharacter.ColorType.RED); } else if (enemyTypes[1].Equals("Green")) { enemyCharacter = new EnemyCharacter(2, Character.Weapon.LANCE, EnemyCharacter.EnemyType.SKELETON, EnemyCharacter.ColorType.GREEN); } else { enemyCharacter = new EnemyCharacter(2, Character.Weapon.LANCE, EnemyCharacter.EnemyType.SKELETON, EnemyCharacter.ColorType.BLUE); } } }
private void OnTriggerEnter(Collider other) { PlayerCharacter player = other.GetComponent <PlayerCharacter> (); EnemyCharacter enemy = other.GetComponent <EnemyCharacter> (); if (player != null) { player.Hurt(damage); } else if (enemy != null) { enemy.ReactToHit(); } Destroy(gameObject); }
public List <EnemyCharacter> AssembleEnemyCharacter() { List <EnemyCharacter> list = new List <EnemyCharacter>(); Random rand = new Random(); for (int i = 0; i < rand.Next(1, 2); i++) //rand.Next(1,7) { EnemyCharacter enemy = new EnemyCharacter(enemyBasicData[rand.Next(0, 2)]); //rand.Next(0, enemyBasicData.Count) enemy.CharacterStatus = new CharacterStatus(enemy.CharacterStats); list.Add(enemy); } return(list); }
public IEnumerator SeeAnotherEnemy(EnemyCharacter enemy) { yield return(new WaitForSeconds(anim.GetCurrentAnimatorClipInfo(0).Length)); Destroy(Instantiate(bullet[1], enemy.transform.position + Vector3.up * 0.8f, shootTransform.rotation), 1); enemy.GetAnimator().SetBool("isDie", true); anim.SetBool("isShoot", false); anim.SetBool("isStandBy", true); yield return(new WaitForSeconds(enemy.GetAnimator().GetCurrentAnimatorClipInfo(0).Length)); Destroy(enemy.gameObject); anim.SetBool("isStandBy", false); transform.tag = "Enemy"; RestartFollowPoint(); }
//Take damage and get knocked back. For when you touched an enemy private void TakeTouchDamage(EnemyCharacter enemy) { if (!damaged && enemy.CanDealDamage()) { //Knockback physicsObject.grounded = false; physicsObject.SetVelY(0f); Vector2 knockbackForce = Vector2.up * PlayerCharacter.Instance.MoveSpeed * Time.fixedDeltaTime / 3.0f; knockbackForce.x = -Vector2.right.x * PlayerCharacter.Instance.MoveSpeed * Time.fixedDeltaTime / 3.0f; physicsObject.AddForce(knockbackForce); PlayerCharacter.Instance.TakeDamage(enemy.TouchDamage); damaged = true; } }
//void OnTriggerEnter2D(Collider2D other) { void OnTriggerStay2D(Collider2D other) { PlayerCharacter player = other.transform.root.GetComponent <PlayerCharacter>(); if (player != null) { player.Hurt(damage); } EnemyCharacter enemy = other.transform.root.GetComponent <EnemyCharacter>(); if (enemy != null) { enemy.Hurt(damage); } }
private void OnTriggerStay(Collider other) { if (other.tag == "RunningNPC") { NonPlayerCharacter nonPlayer = other.gameObject.GetComponent <NonPlayerCharacter>(); other.gameObject.tag = "EscapeNPC"; StartCoroutine(nonPlayer.ChangeState()); } if (other.tag == "Enemy") { EnemyCharacter nonPlayer = other.gameObject.GetComponent <EnemyCharacter>(); other.gameObject.tag = "AttackEnemy"; nonPlayer.ChangeState(playHitPoint); } }
internal void UnregisterEnemy(EnemyCharacter a_enemy) { enemyList.Remove (a_enemy); }
internal void RegisterEnemy(EnemyCharacter a_enemy) { enemyList.Add (a_enemy); }
public static Character GetEnemyCharacter(CharacterType characterType, MonsterController controller) { Character character = new EnemyCharacter(characterType, controller); return character; }
// Use this for initialization public override void Start() { if(ImmunityCombatManager.instance.stage_name.Equals("stomach")) level = new StomachLevel(); else if(ImmunityCombatManager.instance.stage_name.Equals("lung")) level = new LungLevel(); else level = new BrainLevel(); AddChild(level); FSoundManager.StopMusic(); FSoundManager.UnloadAllSoundsAndMusic(); FSoundManager.PlayMusic("battle_music", .204f); FSprite enemy_headshot = new FSprite("punchy_headshot"); enemy_headshot.x = Futile.screen.halfWidth - enemy_headshot.width/2.0f - 50.0f; enemy_headshot.y = Futile.screen.halfHeight - enemy_headshot.height/2.0f - 50.0f; enemy_healthbar_ = new HealthBar(); enemy_healthbar_.scaleX = -.8f; enemy_healthbar_.x = enemy_headshot.x - enemy_headshot.width/2.0f - 25.0f; enemy_healthbar_.y = enemy_headshot.y; enemy_ = new EnemyCharacter(enemy_healthbar_); if(ImmunityCombatManager.instance.stage_name.Equals("lung") || ImmunityCombatManager.instance.stage_name.Equals("brain")) enemy_.y = -Futile.screen.halfHeight*.27f; AddChild(enemy_); FSprite player_headshot = new FSprite("hero_headshot"); player_headshot.scale = .2f; player_headshot.x = -Futile.screen.halfWidth + player_headshot.width/2.0f + 50.0f; player_headshot.y = Futile.screen.halfHeight - player_headshot.height/2.0f - 50.0f; player_healthbar = new HealthBar(); player_healthbar.scaleX = .8f; player_healthbar.x = player_headshot.x + player_headshot.width/2.0f + 25.0f; player_healthbar.y = player_headshot.y; player_ = new PlayerCharacter(player_healthbar); if(ImmunityCombatManager.instance.stage_name.Equals("lung") || ImmunityCombatManager.instance.stage_name.Equals("brain")) player_.y = -Futile.screen.halfHeight*.5f; playerContainer = new FContainer(); //Debug.Log ("the player is at " + playerPosition.x + "," + playerPosition.y); playerContainer.AddChild (player_); AddChild(playerContainer); bacteriaContainer_ = new FContainer(); AddChild(bacteriaContainer_); bubbleContainer_ = new FContainer(); AddChild(bubbleContainer_); dyingBacteriaHolder_ = new FContainer(); AddChild(dyingBacteriaHolder_); ImmunityCombatManager.instance.camera_.follow(playerContainer); AddChild(player_headshot); AddChild(player_healthbar); AddChild(enemy_headshot); AddChild(enemy_healthbar_); level_bounding_box = new Rect(-Futile.screen.halfWidth*.9f, Futile.screen.halfHeight*.9f, Futile.screen.halfWidth*1.8f, Futile.screen.halfHeight*1.8f); }
// setup variables public EnemyBattleEntity(EnemyCharacter character, BattleEntityDelegate listener) : base(character, listener) { }