123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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);
- var localCockActionComp = localCock.GetComponent<CockActionComp>();
- localCockActionComp.cockId = _gameCore.localPlayer.cockId;
- var antiCockActionComp = antiCock.GetComponent<CockActionComp>();
- antiCockActionComp.cockId = _gameCore.antiPlayer.cockId;
- localCockActionComp.playerId = _gameCore.localPlayer.playerId;
- antiCockActionComp.playerId = _gameCore.antiPlayer.playerId;
- _gameCore.cockDict.Add(_gameCore.localPlayer.playerId, localCockActionComp);
- _gameCore.cockDict.Add(_gameCore.antiPlayer.playerId, antiCockActionComp);
- localCock.GetComponent<SoundCtrl>().Tag = "player-" + _gameCore.localPlayer.playerId;
- antiCock.GetComponent<SoundCtrl>().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<GameObject>("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<MasterActionComp>();
- localMasterActionComp.playerId = _gameCore.localPlayer.playerId;
- var antiMasterActionComp = antiMaster.GetComponent<MasterActionComp>();
- 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)
- {
- }
- }
- }
|