//--------------------------------------------------- // AddAISystem //--------------------------------------------------- public void AddAISystem(Define.Battle.TEAM_TYPE type, BaseBattleAISystem aiSystem, string name) { _AISystemList.Add(type, aiSystem); _TeamNameList.Add(type, name); _observable.PushEvent("EVENT_SetTeamName", Common.CreateHashTable("teamType", type, "name", name)); }
//--------------------------------------------------- // Initialize //--------------------------------------------------- public void Initialize(int characterId, Define.Battle.TEAM_TYPE teamId, Vector3 pos) { CharacterData.CharacterDataList data = ApplicationManager.Instance.Master.CharacterData.GetData(characterId); _characterModel.MaxHp = data.Hp; _characterModel.Hp = _characterModel.MaxHp; _characterModel.Speed = data.MoveSpeed; _characterModel.TeamId = teamId; _characterModel.AttackPowerBias = data.AttackPowerBias; transform.position = pos + data.InitCorrectionPos; _characterModel.Direction = transform.forward; _characterModel.TargetPos = transform.position; _actionManager = gameObject.AddComponent <ActionManager>(); _characterModel.Basedata = data; _actionManager.Initialize(this); GameObject view = new GameObject("CharacterView"); view.transform.SetParent(gameObject.transform, false); _characterView = view.AddComponent <CharacterView>(); _characterView.SetTeamId(teamId); _characterView.SetAvatar(data.ViewPrefabPath); InitializeObderver(); Initialize(Define.ActorType.CHARACTER, _characterModel, _characterView); _characterModel.SetActorId(_characterModel.ActorId); }
//--------------------------------------------------- // CreateCharacter //--------------------------------------------------- public void CreateCharacter(Define.Battle.TEAM_TYPE type, int id) { Character character = (GameObject.Instantiate(Resources.Load("Prefabs/Character/Character")) as GameObject).GetComponent <Character>(); character.Initialize(id, type, this.StageManager.GetStartPosition(type)); _battleModel.AddCharacter(type, character); }
//--------------------------------------------------- // Initilaize //--------------------------------------------------- public void Initilaize(int id, Define.Battle.TEAM_TYPE teamId, Vector3 pos, Vector3 moveVec, float damageBias) { BulletData.BulletDataList data = ApplicationManager.Instance.Master.BulletData.GetData(id); _bulletModel.Speed = data.Speed; _bulletModel.LifeFrameCount = data.LifeFrameCount; _bulletModel.RangeBlock = data.RangeBlock; _bulletModel.AttackPower = data.AttackPower; _bulletModel.DamageType = data.DamageType; _bulletModel.MoveVec = moveVec; transform.position = pos; _bulletModel.TeamId = teamId; _bulletModel.AttackPowerBias = damageBias; _battleSystem = ApplicationManager.Instance.Battlesystem; GameObject view = new GameObject("BulletView"); view.transform.SetParent(gameObject.transform, false); _bulletView = view.AddComponent <BulletView>(); _bulletView.Initialize(data); if (data.ViewPrefabPath != "") { _bulletView.SetAvatar(data.ViewPrefabPath); } base.Initialize(Define.ActorType.BULLET, _bulletModel, _bulletView); }
//--------------------------------------------------- // CreateDamageObject //--------------------------------------------------- public void CreateDamageObject(Define.Battle.TEAM_TYPE type, Vector3 pos, Vector3 range, int attackFrame, float attackPower) { DamageObject damageObj = Instantiate(_damageObjectPrefab).GetComponent <DamageObject>(); damageObj.Initialize(type, pos, range, attackFrame, attackPower); damageObj.AttackHitDelegate += AttackHitCallBack; }
//--------------------------------------------------- // CreateResultScore //--------------------------------------------------- public int CreateResultScore(Define.Battle.TEAM_TYPE playerTeamType, Define.Battle.TEAM_TYPE enemyTeamType) { int playerScoreHp = (int)_battleModel.TotalHp[playerTeamType]; int playerScoreAlive = 0; int enemyScoreHp = (int)_battleModel.TotalHp[enemyTeamType]; int playerScoreKill = 0; int playerAliveCount = 0; for (int i = 0; i < _battleModel.TeamCharacterList[playerTeamType].Count; i++) { if (_battleModel.TeamCharacterList[playerTeamType][i].CharacterModel.Hp > 0) { playerAliveCount++; } } int enemyKillCount = 0; for (int i = 0; i < _battleModel.TeamCharacterList[enemyTeamType].Count; i++) { if (_battleModel.TeamCharacterList[enemyTeamType][i].CharacterModel.Hp <= 0) { enemyKillCount++; } } //係数計算 playerScoreHp = playerScoreHp * 1; playerScoreAlive = playerAliveCount * 500; playerScoreKill = enemyKillCount * 500; enemyScoreHp = enemyScoreHp * 1; return(playerScoreHp + playerScoreAlive + playerScoreKill - enemyScoreHp); }
//--------------------------------------------------- // EVENT_TeamId //--------------------------------------------------- public void SetTeamId(Define.Battle.TEAM_TYPE teamId) { _teamMaker = Instantiate(Resources.Load("Prefabs/Character/Hud") as GameObject); _teamMaker.transform.position = Vector3.up; _teamMaker.transform.SetParent(this.transform, false); _teamMaker.GetComponent <HudView>().SetTeamMarker(teamId); }
/// <summary> /// 初期化 /// 継承先では呼ばないこと /// </summary> /// <remarks> /// 外部呼び出しのみ /// </remarks> /// <param name="teamType">AIが動かすごとができるチームタイプ</param> /// <param name="battleSystem">保持するバトルロジッククラス</param> public void Initialize(Define.Battle.TEAM_TYPE teamType, BattleSystem battleSystem) { _teamType = teamType; _enemyTeam = GetEnemyTeamType(_teamType).Value; _actorManager = ApplicationManager.Instance.ActorManager; _battleSystem = battleSystem; _battleSystem.ItemManager.ItenSpawnCallBackDelegate += ItemSpawnCallback; }
/// <summary> /// 初期化コンストラクタ /// </summary> public Data(int id, Define.Battle.TEAM_TYPE type, float hp, float maxHp, Vector3 forward, Vector2 blockPos, bool isMoveEnable) { this.ActorId = id; this.TeamType = type; this.Hp = hp; this.MaxHp = maxHp; this.BlockPos = blockPos; this.IsMoveEnable = isMoveEnable; this.Forward = forward; }
//--------------------------------------------------- // SetTeam //--------------------------------------------------- private void SetTeam(Define.Battle.TEAM_TYPE type, InternSetting data) { UnityEngine.SceneManagement.Scene scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene(BattleScenePath); GameObject go = AssetDatabase.LoadAssetAtPath <GameObject>(WritePath + data.AiClassName + ".prefab"); GameObject.Find("BattleMain").GetComponent <BattleSystem>().AISystemList[(int)type] = go; GameObject.Find("BattleMain").GetComponent <BattleSystem>().TeamNameList[(int)type] = data.TeamName; UnityEditor.SceneManagement.EditorSceneManager.SaveScene(scene); UnityEditor.SceneManagement.EditorSceneManager.OpenScene(TitleScenePath); }
//--------------------------------------------------- // EVENT_Hp //--------------------------------------------------- public void EVENT_Hp(Hashtable table) { if (table.ContainsKey("diff") && table.ContainsKey("teamId")) { float diff = (float)table["diff"]; Define.Battle.TEAM_TYPE type = (Define.Battle.TEAM_TYPE)table["teamId"]; _battleModel.SetTotalHp(type, diff); } }
//--------------------------------------------------- // CreateAISystem //--------------------------------------------------- void CreateAISystem() { for (int i = 0; i < _AISystemList.Count; i++) { Define.Battle.TEAM_TYPE teamType = (Define.Battle.TEAM_TYPE)i; BaseBattleAISystem system = Instantiate(_AISystemList[i]).GetComponent <BaseBattleAISystem>(); system.Initialize(teamType, this); _battleModel.AddAISystem(teamType, system, TeamNameList[i]); } }
public void SetTeamMarker(Define.Battle.TEAM_TYPE teamId) { if (teamId == Define.Battle.TEAM_TYPE.ALPHA) { _markMeshRenderer.material = _markMaterial[0]; } else if (teamId == Define.Battle.TEAM_TYPE.BRAVO) { _markMeshRenderer.material = _markMaterial[1]; } }
//--------------------------------------------------- // Initialize //--------------------------------------------------- public void Initialize(Define.Battle.TEAM_TYPE teamType, Vector3 pos, Vector3 range, int attackFrame, float attackPower) { _teamType = teamType; _boxCollider.size = range; _actorManager = ApplicationManager.Instance.ActorManager; _attackPower = attackPower; _endFrameCount = attackFrame; gameObject.transform.position = pos; _isInitilaize = true; }
/// <summary> /// 敵のチームタイプ取得 /// </summary> /// <returns>敵のチームタイプ</returns> /// <param name="type">自分のチームタイプ</param> Define.Battle.TEAM_TYPE?GetEnemyTeamType(Define.Battle.TEAM_TYPE type) { switch (type) { case Define.Battle.TEAM_TYPE.ALPHA: return(Define.Battle.TEAM_TYPE.BRAVO); case Define.Battle.TEAM_TYPE.BRAVO: return(Define.Battle.TEAM_TYPE.ALPHA); } return(null); }
//--------------------------------------------------- // GetStartPosition //--------------------------------------------------- public Vector3 GetStartPosition(Define.Battle.TEAM_TYPE type) { if (type == Define.Battle.TEAM_TYPE.ALPHA) { return(GetBlockPosition(0, 0)); } else if (type == Define.Battle.TEAM_TYPE.BRAVO) { return(GetBlockPosition(_horizontalBlockNum - 1, _verticalBlockNum - 1)); } return(GetBlockPosition(0, 0)); }
//--------------------------------------------------- // SetTotalHp //--------------------------------------------------- public void SetTotalHp(Define.Battle.TEAM_TYPE type, float hp) { if (_totalHpList.ContainsKey(type)) { _totalHpList[type] += hp; } else { _totalHpList.Add(type, hp); } _observable.PushEvent("EVENT_SetTotalHp", Common.CreateHashTable("teamType", type, "hp", _totalHpList[type])); }
//--------------------------------------------------- // EVENT_SetTotalHp //--------------------------------------------------- void EVENT_SetTotalHp(Hashtable table) { Define.Battle.TEAM_TYPE teamId = (Define.Battle.TEAM_TYPE)table["teamType"]; float totalHp = (float)table["hp"]; if (teamId == Define.Battle.TEAM_TYPE.ALPHA) { _playerTotalHpSlider.value = totalHp; } else if (teamId == Define.Battle.TEAM_TYPE.BRAVO) { _enemyTotalHpSlider.value = totalHp; } }
//--------------------------------------------------- // EVENT_SetTeamName //--------------------------------------------------- void EVENT_SetTeamName(Hashtable table) { Define.Battle.TEAM_TYPE teamId = (Define.Battle.TEAM_TYPE)table["teamType"]; string teamName = (string)table["name"]; if (teamId == Define.Battle.TEAM_TYPE.ALPHA) { _playerTeamName.text = teamName; } else if (teamId == Define.Battle.TEAM_TYPE.BRAVO) { _enemyTeamName.text = teamName; } }
//--------------------------------------------------- // AddCharacter //--------------------------------------------------- public void AddCharacter(Define.Battle.TEAM_TYPE type, Character character) { if (_teamCharacterList.ContainsKey(type)) { _teamCharacterList[type].Add(character); _teamCharacterDataList[type].Add(character.CharacterModel.PublicCharacterData); } else { List <Character> list = new List <Character>(); list.Add(character); _teamCharacterList.Add(type, list); List <CharacterModel.Data> dataList = new List <CharacterModel.Data>(); dataList.Add(character.CharacterModel.PublicCharacterData); _teamCharacterDataList.Add(type, dataList); } }