/// <summary> /// Player移动到指定位置 /// </summary> /// <param name="msg"></param> /// <returns></returns> private bool OnPlayerMove(OnPlayerMoveMsg msg) { isSuccess = false; canTurnInfinite = MissionData.GetLevelTurnInfinite(MissionManager.Instance.mCurLevel, MissionManager.Instance.mCurSubLevel); mInitialPosition = msg.mTargetPos; if (msg.isMoveDirectly) { gameObject.transform.position = msg.mTargetPos; } else { SetPlayerAngle(msg.mTargetPos - gameObject.transform.position, true); gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); gameObject.transform.Find("Particle System").transform.gameObject.SetActive(true); gameObject.transform.DOMove(msg.mTargetPos, 4.0f).OnComplete(() => { gameObject.GetComponent <BoxCollider2D>().enabled = true; isMoveable = true; mTurnCount = mInitinalTurnCount; UIManager.Instance.SetTurnCountText(mTurnCount - 1); canCountDownTurn = true; canPlayMoveSound = true; canDoSuccess = true; canMove = true; canDreaseTurnCount = false; this.transform.eulerAngles = new Vector3(0, 0, 0); isFlying = false; StartCoroutine(CheckAndShowGuidePanel(MissionManager.Instance.mCurSubLevel, 3.0f)); }); } //小球的初始化位置变为下一个位置 return(false); }
public void Startup() { mStatus = ManagerStatus.Started; //TODO :这里的数据需要从存储里面读取,因为还没做,所以先放这里 MissionData.LoadMissionData(); PlayerProgress.Instance.Reload(); LoadMissionProgress(); mMaxLevel = MissionData.GetMaxLevel(); mMaxSubLevel = MissionData.GetMaxSubLevel(mCurLevel); }
void Start() { mRg2D = GetComponent <Rigidbody2D>(); mInitialPosition = transform.position; mInitialRotation = transform.rotation; mInitialSpeed = mMoveSpeed; canTurnInfinite = MissionData.GetLevelTurnInfinite(MissionManager.Instance.mCurLevel, MissionManager.Instance.mCurSubLevel); isSuccess = false; StartCoroutine(ShowGamePanel()); //if (MissionManager.Instance.mCurLevel == 1 && MissionManager.Instance.mCurSubLevel == 1) //{ StartCoroutine(CheckAndShowGuidePanel(MissionManager.Instance.mCurSubLevel, 3.0f)); //} }
/// <summary> /// 进入下一个小关卡 /// </summary> public void GoToNextSubLevel() { if (mCurSubLevel < mMaxSubLevel) { UpdateMissionLevel(mCurLevel, mCurSubLevel + 1); //不移动镜头的做法 //SceneManager.LoadSceneAsync("Level" + mCurLevel + "-" + mCurSubLevel); //移动镜头的做法 MessageBus.Send(new OnCameraMoveMsg(MissionData.GetCameraPosition(mCurLevel, mCurSubLevel), false)); MessageBus.Send(new OnPlayerMoveMsg(MissionData.GetPlayerPosition(mCurLevel, mCurSubLevel), false)); } else { //这里应该是跳转到某个大关卡过关完的连成星座并展示星座图的画面 MessageBus.Send(new OnLevelCompleteMsg()); } }
private IEnumerator FlyStoneAndFade() { isAniComplete = false; //这里播放特效 UFO.SetActive(true); //播放音乐 AudioManager.Instance.PlayOneShotIndex(4); Animator animator = UFO.GetComponent <Animator>(); animator.enabled = true; animator.Play("UFOAni", -1, 0.0f); yield return(new WaitForSeconds(1.5f)); List <GameObject> stoneList = StoneManager.Instance.GetRadomStoneTrasform(); for (int i = 0; i < stoneList.Count; i++) { GameObject stone = stoneList[i]; Vector3 initinalStonePosition = stone.gameObject.transform.position; Color initinalStoneColor = stone.GetComponent <SpriteRenderer>().color; Vector3 targetPosition = MissionData.GetCameraPosition(MissionManager.Instance.mCurLevel, MissionManager.Instance.mCurSubLevel); targetPosition.y += 6.5f; //stone.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), 1.0f); //石头要变成Trigger,不然在飞行的过程中撞到Player会导致Player死亡 stone.gameObject.GetComponent <PolygonCollider2D>().isTrigger = true; stone.gameObject.transform.DOMove(targetPosition, 1.0f).OnComplete(() => { stone.gameObject.SetActive(false); stone.gameObject.GetComponent <PolygonCollider2D>().isTrigger = false; stone.gameObject.transform.position = initinalStonePosition; stone.GetComponent <SpriteRenderer>().color = initinalStoneColor; //这里要播放炸掉石头的特效 }); } yield return(new WaitForSeconds(2.5f)); isAniComplete = true; animator.enabled = false; UFO.SetActive(false); }
/// <summary> /// 进入下一个大关卡 /// </summary> public void GoToNextLevel() { //首先要将小关卡重置为1 // mCurSubLevel = 1; var subLv = 1; if (mCurLevel < mMaxLevel) { UpdateMissionLevel(mCurLevel + 1, 1); //将下一大关的小关卡重置 mMaxSubLevel = MissionData.GetMaxSubLevel(mCurLevel); SceneManager.LoadSceneAsync("Level" + mCurLevel + "-" + mCurSubLevel); } else { Debug.Log("Last level"); PlayerProgress.Instance.SubmitNewProgress(1, 1); //发送消息,游戏已经到最后一关了,到这里整个游戏通关了 MessageBus.Send(new OnGameCompleteMsg()); } }
public void UpdateMissionLevel(int currentLevel, int currentSubLevel) { PlayerProgress.Instance.SubmitNewProgress(currentLevel, currentSubLevel); mMaxSubLevel = MissionData.GetMaxSubLevel(mCurLevel); }
/// <summary> /// 获得相机初始位置 /// </summary> public Vector3 GetCameraStartPos() { return(MissionData.GetCameraPosition(mCurLevel, mCurSubLevel)); }
/// <summary> /// 获得Player初始位置 /// </summary> public Vector3 GetPlayerStartPos() { return(MissionData.GetPlayerPosition(mCurLevel, mCurSubLevel)); }