Commit e426b9f4 authored by czy's avatar czy

自动进入下一关

parent d7046574
...@@ -1680,6 +1680,8 @@ MonoBehaviour: ...@@ -1680,6 +1680,8 @@ MonoBehaviour:
GoldName: Egg GoldName: Egg
IsScoreSettlementStatus: 0 IsScoreSettlementStatus: 0
IsWin: 0 IsWin: 0
Magnification: 1
targetScore: 0
--- !u!1 &895813958 --- !u!1 &895813958
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -4317,5 +4319,15 @@ PrefabInstance: ...@@ -4317,5 +4319,15 @@ PrefabInstance:
propertyPath: m_Mesh propertyPath: m_Mesh
value: value:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 9084503724270250775, guid: e808ab909854dca4dba20c69399d6a13,
type: 3}
propertyPath: m_text
value: x8
objectReference: {fileID: 0}
- target: {fileID: 9084503724270250775, guid: e808ab909854dca4dba20c69399d6a13,
type: 3}
propertyPath: m_textInfo.characterCount
value: 3
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e808ab909854dca4dba20c69399d6a13, type: 3} m_SourcePrefab: {fileID: 100100000, guid: e808ab909854dca4dba20c69399d6a13, type: 3}
...@@ -47,8 +47,9 @@ public class BattleCtrl : MonoBehaviour ...@@ -47,8 +47,9 @@ public class BattleCtrl : MonoBehaviour
public bool IsScoreSettlementStatus=false; //是否是分数结算状态 public bool IsScoreSettlementStatus=false; //是否是分数结算状态
public bool IsWin=false; //是否胜利 public bool IsWin=false; //是否胜利
public int Magnification=1;//倍率
public int targetScore = 1;
//更新分数 //更新分数
public delegate void UpdateScoreDe(); public delegate void UpdateScoreDe();
...@@ -65,6 +66,10 @@ public class BattleCtrl : MonoBehaviour ...@@ -65,6 +66,10 @@ public class BattleCtrl : MonoBehaviour
//游戏胜利 //游戏胜利
public delegate void GameWin(); public delegate void GameWin();
public GameWin gameWin; public GameWin gameWin;
//进入下一关委托
public delegate void TurnNextLevel();
public TurnNextLevel turnNextLevel;
private void Awake() private void Awake()
...@@ -80,9 +85,16 @@ public class BattleCtrl : MonoBehaviour ...@@ -80,9 +85,16 @@ public class BattleCtrl : MonoBehaviour
void Start() void Start()
{ {
battleUI.onStartBtn += StartBattle; battleUI.onStartBtn += StartBattle;
} turnNextLevel += UpdateTargetScore;
UpdateTargetScore();
}
public void UpdateTargetScore()
{
targetScore = Score * Magnification;
}
void InitServices() void InitServices()
{ {
...@@ -265,6 +277,7 @@ public class BattleCtrl : MonoBehaviour ...@@ -265,6 +277,7 @@ public class BattleCtrl : MonoBehaviour
m_levelManager.onBeforeLoadLevel -= OnBeforeLoadLevel; m_levelManager.onBeforeLoadLevel -= OnBeforeLoadLevel;
m_levelManager.onAfterLoadLevel -= OnAfterLoadLevel; m_levelManager.onAfterLoadLevel -= OnAfterLoadLevel;
battleUI.onStartBtn -= StartBattle; battleUI.onStartBtn -= StartBattle;
turnNextLevel -= UpdateTargetScore;
//battleUI.onStartBtn = null; //battleUI.onStartBtn = null;
_GameServices.OnDisponse(); _GameServices.OnDisponse();
_GameServices = null; _GameServices = null;
......
...@@ -77,7 +77,7 @@ public class BattleUI : MonoBehaviour ...@@ -77,7 +77,7 @@ public class BattleUI : MonoBehaviour
m_dragBtn.onClick.AddListener(SetDragMode); m_dragBtn.onClick.AddListener(SetDragMode);
m_moveBtn.onClick.AddListener(SetMoveMode); m_moveBtn.onClick.AddListener(SetMoveMode);
m_restartBtn.onClick.AddListener(LoadCurLevel); m_restartBtn.onClick.AddListener(LoadCurLevel);
m_nextLevelBtn.onClick.AddListener(NextLevel); m_nextLevelBtn.onClick.AddListener(NextLevelBtnDown);
m_selectBtn.onClick.AddListener(SelectLevel); m_selectBtn.onClick.AddListener(SelectLevel);
m_tryAgain.onClick.AddListener(TryAgainLevel); m_tryAgain.onClick.AddListener(TryAgainLevel);
m_startBtn.onClick.AddListener(StartBtn); m_startBtn.onClick.AddListener(StartBtn);
...@@ -91,6 +91,7 @@ public class BattleUI : MonoBehaviour ...@@ -91,6 +91,7 @@ public class BattleUI : MonoBehaviour
GameServices.configService.playerConfig.ClawMoveSpeed = 0.4f;//开始默认值 GameServices.configService.playerConfig.ClawMoveSpeed = 0.4f;//开始默认值
BattleCtrl.instance.updateScore += UpdateScore; BattleCtrl.instance.updateScore += UpdateScore;
BattleCtrl.instance.updateRanking += UpdateRanking; BattleCtrl.instance.updateRanking += UpdateRanking;
BattleCtrl.instance.turnNextLevel += NextLevel;
} }
private void Start() private void Start()
{ {
...@@ -149,6 +150,10 @@ public class BattleUI : MonoBehaviour ...@@ -149,6 +150,10 @@ public class BattleUI : MonoBehaviour
} }
// 进入下一关卡 // 进入下一关卡
public void NextLevelBtnDown()
{
BattleCtrl.instance.turnNextLevel?.Invoke();
}
public void NextLevel() public void NextLevel()
{ {
m_successObj.SetActive(false); m_successObj.SetActive(false);
...@@ -441,5 +446,6 @@ public class BattleUI : MonoBehaviour ...@@ -441,5 +446,6 @@ public class BattleUI : MonoBehaviour
{ {
BattleCtrl.instance.updateScore -= UpdateScore; BattleCtrl.instance.updateScore -= UpdateScore;
BattleCtrl.instance.updateRanking -= UpdateRanking; BattleCtrl.instance.updateRanking -= UpdateRanking;
BattleCtrl.instance.turnNextLevel -= NextLevel;
} }
} }
...@@ -1306,6 +1306,7 @@ GameObject: ...@@ -1306,6 +1306,7 @@ GameObject:
- component: {fileID: 1338799328} - component: {fileID: 1338799328}
- component: {fileID: 1338799327} - component: {fileID: 1338799327}
- component: {fileID: 1338799326} - component: {fileID: 1338799326}
- component: {fileID: 1338799329}
m_Layer: 5 m_Layer: 5
m_Name: PurseImage m_Name: PurseImage
m_TagString: Untagged m_TagString: Untagged
...@@ -1371,6 +1372,18 @@ MonoBehaviour: ...@@ -1371,6 +1372,18 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!114 &1338799329
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1338799325}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ff94815dcde40a4f9fcd7c7fea2d493, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1529647316 --- !u!1 &1529647316
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -40,7 +40,7 @@ Material: ...@@ -40,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MainTex: - _MainTex:
m_Texture: {fileID: 2800000, guid: 86cb957541c7c8542a6306ffb82e6833, type: 3} m_Texture: {fileID: 2800000, guid: e6bcefb2a2fea3442809925e5d4fe224, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _MetallicGlossMap: - _MetallicGlossMap:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PurseImage : MonoBehaviour
{
private RectTransform recTransform;
private float Speed = 5f;
private Vector3 beginPos;
private Vector3 targetPos;
private int targetScoreNumber;
void Start()
{
recTransform = GetComponent<RectTransform>();
beginPos = recTransform.localPosition;
//targetPos = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0)); //有问题
targetPos =Camera.main.ScreenToViewportPoint(Vector3.one * 0.5f);
//print(targetPos);
}
// Update is called once per frame
void Update()
{
if (BattleCtrl.instance.isEndBattle)
{
recTransform.localPosition = Vector3.Lerp(recTransform.localPosition, targetPos, Speed * Time.deltaTime);
//recTransform.localPosition=Camera.main.ScreenToViewportPoint(Vector3.one * 0.5f);
if(Vector3.Distance(recTransform.localPosition, targetPos) < 10)
{
print(BattleCtrl.instance.Score+"--"+BattleCtrl.instance.targetScore);
BattleCtrl.instance.Score = (int)Mathf.Lerp(BattleCtrl.instance.Score, BattleCtrl.instance.targetScore, 5f*Time.deltaTime);
BattleCtrl.instance.updateScore?.Invoke();
//自动进入下一关
if (BattleCtrl.instance.targetScore - BattleCtrl.instance.Score < 100)
{
BattleCtrl.instance.Score = BattleCtrl.instance.targetScore;
BattleCtrl.instance.updateScore?.Invoke();
//进入下一关
print("进入下一关");
BattleCtrl.instance.turnNextLevel?.Invoke();
}
}
}
else
{
recTransform.localPosition = beginPos;
}
}
}
fileFormatVersion: 2
guid: 8ff94815dcde40a4f9fcd7c7fea2d493
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,16 +5,33 @@ using UnityEngine; ...@@ -5,16 +5,33 @@ using UnityEngine;
public class UITextToPurse : MonoBehaviour public class UITextToPurse : MonoBehaviour
{ {
public int value = 100; public int value = 100;
private float DeltaTime=1.0f;//停留1秒
private float timer=0;
private RectTransform recTransform;
private float Speed = 0f;
void Start() void Start()
{ {
recTransform = GetComponent<RectTransform>();
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
GetComponent<RectTransform>().localPosition= Vector3.Lerp(GetComponent<RectTransform>().localPosition, new Vector3(0, 0, 0), 0.3f); //停留1秒
if(Vector3.Distance(GetComponent<RectTransform>().localPosition,new Vector3(0, 0, 0)) < 5) timer += Time.deltaTime;
if(timer< DeltaTime)
{
return;
//Speed = Mathf.Lerp(Speed,2.0f,1f * Time.deltaTime);
}
else
{
Speed = Mathf.Lerp(Speed, 10.0f, 1f * Time.deltaTime);
}
//移动向父节点,localposition 0 0 0 .
recTransform.localPosition= Vector3.Lerp(recTransform.localPosition, new Vector3(0, 0, 0), Speed*Time.deltaTime);
if(Vector3.Distance(recTransform.localPosition,new Vector3(0, 0, 0)) < 10)
{ {
this.gameObject.SetActive(false); this.gameObject.SetActive(false);
BattleCtrl.instance.Score+= value; BattleCtrl.instance.Score+= value;
......
...@@ -4,6 +4,8 @@ using UnityEngine; ...@@ -4,6 +4,8 @@ using UnityEngine;
using DG.Tweening; using DG.Tweening;
using DG.Tweening.Core; using DG.Tweening.Core;
using HedgehogTeam.EasyTouch; using HedgehogTeam.EasyTouch;
using TMPro;
using System;
public enum MoveType public enum MoveType
{ {
...@@ -335,6 +337,18 @@ public class PlayerMove : MonoBehaviour ...@@ -335,6 +337,18 @@ public class PlayerMove : MonoBehaviour
{ {
//print("滑行结束"); //print("滑行结束");
BattleCtrl.instance.ExitScoreSettlementStatus(); BattleCtrl.instance.ExitScoreSettlementStatus();
Physics.Raycast(transform.position, -transform.up, out hit, 30);
//print(hit.collider.name);
if (hit.collider.gameObject.GetComponent<TextMeshPro>() == null)
{
BattleCtrl.instance.Magnification = 1;
}
else
{
string magnificationStr = hit.collider.gameObject.GetComponent<TextMeshPro>().text.Replace("x", "");
BattleCtrl.instance.Magnification = Convert.ToInt32(magnificationStr);
}
BattleCtrl.instance.UpdateTargetScore();
} }
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment