using Comp; using Sound; using UnityEngine; namespace Game { public class GamePendingState : GameState { private const float CockInitialX = 2f; private const float StaticOffset = -2.534481f; private const float MastInitialX = 6f; public override void PlayBattle() { Debug.Log("play battle"); _gameCore.GetController(_gameCore.localPlayer).Run(); _gameCore.GetController(_gameCore.antiPlayer).Run(); } public override void BattleStart() { _gameCore.TransitionToState(_gameCore.battleState); _gameCore.GetCurState().BattleStart(); } public override void LiftCock() { // 啥都不做 } public override void ExitBattle() { } public override void EndBattle() { // 啥都不做 } public override void EnterState() { Debug.Log("enter pending state"); // 处理鸡模型 var localCockPrefab = CockFactory.Instance.GenerateCockPrefab(_gameCore.localPlayer.cockId); var antiCockPrefab = CockFactory.Instance.GenerateCockPrefab(_gameCore.antiPlayer.cockId); var localCock = Object.Instantiate(localCockPrefab); var antiCock = Object.Instantiate(antiCockPrefab); // 处理鸡Hp组件 var localCockHpComp = localCock.GetComponent(); var antiCockHpComp = antiCock.GetComponent(); localCockHpComp.MaxHp = _gameCore.localPlayer.hp; antiCockHpComp.MaxHp = _gameCore.antiPlayer.hp; _gameCore.cockHpComps.Add(_gameCore.localPlayer.playerId, localCockHpComp); _gameCore.cockHpComps.Add(_gameCore.antiPlayer.playerId, antiCockHpComp); // 处理鸡动作组件 var localCockActionComp = localCock.GetComponent(); var antiCockActionComp = antiCock.GetComponent(); localCockActionComp.cockId = _gameCore.localPlayer.cockId; antiCockActionComp.cockId = _gameCore.antiPlayer.cockId; localCockActionComp.gameObject.GetComponent().cockId = _gameCore.localPlayer.cockId; antiCockActionComp.gameObject.GetComponent().cockId = _gameCore.antiPlayer.cockId; localCockActionComp.playerId = _gameCore.localPlayer.playerId; antiCockActionComp.playerId = _gameCore.antiPlayer.playerId; _gameCore.cockActionComps.Add(_gameCore.localPlayer.playerId, localCockActionComp); _gameCore.cockActionComps.Add(_gameCore.antiPlayer.playerId, antiCockActionComp); // 处理声音组件 localCock.GetComponent().Tag = "player-" + _gameCore.localPlayer.playerId; antiCock.GetComponent().Tag = "player-" + _gameCore.antiPlayer.playerId; // 处理方向位置 localCock.transform.eulerAngles = new Vector3(0, 90, 0); antiCock.transform.eulerAngles = new Vector3(0, -90, 0); localCock.transform.position = new Vector3(-CockInitialX - StaticOffset, localCock.transform.position.y, localCock.transform.position.z); antiCock.transform.position = new Vector3(CockInitialX - StaticOffset, antiCock.transform.position.y, antiCock.transform.position.z); localCock.transform.parent = _gameCore.parent.transform; antiCock.transform.parent = _gameCore.parent.transform; // 处理主人模型 var masterPrefab = Resources.Load("Human/prefab_master"); var localMaster = Object.Instantiate(masterPrefab); var antiMaster = Object.Instantiate(masterPrefab); localMaster.transform.position = new Vector3(-MastInitialX - StaticOffset, localMaster.transform.position.y, localMaster.transform.position.z); antiMaster.transform.position = new Vector3(MastInitialX - StaticOffset, antiMaster.transform.position.y, antiMaster.transform.position.z); antiMaster.transform.eulerAngles = new Vector3(0, -90f, 0); localMaster.transform.parent = _gameCore.parent.transform; antiMaster.transform.parent = _gameCore.parent.transform; var localMasterActionComp = localMaster.GetComponent(); localMasterActionComp.playerId = _gameCore.localPlayer.playerId; var antiMasterActionComp = antiMaster.GetComponent(); antiMasterActionComp.playerId = _gameCore.antiPlayer.playerId; _gameCore.masterDict.Add(_gameCore.localPlayer.playerId, localMasterActionComp); _gameCore.masterDict.Add(_gameCore.antiPlayer.playerId, antiMasterActionComp); SoundCore.Instance.PlaySound(SoundType.BattleBgmStart, SoundCtrl.BattleEnvPlayer); Debug.Log("enter pending state finish"); } public override void ExitState() { // 啥都不做 } public GamePendingState(GameCore gameCore) : base(gameCore) { } } }