Commit c56b9d8c authored by czy's avatar czy

吃随机生成的食物

parent 75734bd9
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class GroundCollision : MonoBehaviour //public class GroundCollision : MonoBehaviour
{ //{
private ChainRopeView m_chainRopeView; // private ChainRopeView m_chainRopeView;
private void Start() // private void Start()
{ // {
m_chainRopeView = BattleCtrl.instance.levelManager.curLevel.chainRopeView; // m_chainRopeView = BattleCtrl.instance.levelManager.curLevel.chainRopeView;
} // }
private void OnCollisionEnter(Collision other) // private void OnCollisionEnter(Collision other)
{ // {
if (CanGetCatch(other) && m_chainRopeView.IsCatch && m_chainRopeView.CatchTouchUp) // if (CanGetCatch(other) && m_chainRopeView.IsCatch && m_chainRopeView.CatchTouchUp)
{ // {
m_chainRopeView.CatchObjEnterGround(); // m_chainRopeView.CatchObjEnterGround();
} // }
} // }
bool CanGetCatch(Collision ohter) // //bool CanGetCatch(Collision ohter)
{ // //{
return string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.firstLevelGoalName) // // return string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.firstLevelGoalName)
|| string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.secondLevelGoalName) // // || string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.secondLevelGoalName)
|| string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.thirdLevelGoalName) // // || string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.thirdLevelGoalName)
|| string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.fourthLevelGoalName) // // || string.Equals(ohter.gameObject.name, GameServices.configService.levelConfig.fourthLevelGoalName)
|| string.Equals(ohter.gameObject.name, "Claw"); // // || string.Equals(ohter.gameObject.name, "Claw");
} // //}
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class ThirdLevelBoxCollision : MonoBehaviour //public class ThirdLevelBoxCollision : MonoBehaviour
{ //{
public GameObject[] m_needRigidBody; // public GameObject[] m_needRigidBody;
public Transform m_targetTrans; // public Transform m_targetTrans;
public GameObject m_bottomObj; // public GameObject m_bottomObj;
private bool m_bIsRigid = false;//是否有刚体 // private bool m_bIsRigid = false;//是否有刚体
private bool m_bIsTrigger = false;//是否碰到了目标 // private bool m_bIsTrigger = false;//是否碰到了目标
private Vector3 m_pos = new Vector3(-0.73f, 1.19f, -2.54f); // private Vector3 m_pos = new Vector3(-0.73f, 1.19f, -2.54f);
private Quaternion m_rotation = Quaternion.Euler(0, 83.33f, 0); // private Quaternion m_rotation = Quaternion.Euler(0, 83.33f, 0);
private bool m_bControl = true; // private bool m_bControl = true;
private void OnCollisionEnter(Collision other) // private void OnCollisionEnter(Collision other)
{ // {
if (string.Equals(other.gameObject.name, "Claw")) // if (string.Equals(other.gameObject.name, "Claw"))
{ // {
m_bIsRigid = true; // m_bIsRigid = true;
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterTargerView(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterTargerView();
for(int i = 0;i< m_needRigidBody.Length;i++) // for(int i = 0;i< m_needRigidBody.Length;i++)
{ // {
m_needRigidBody[i].AddComponent<Rigidbody>(); // m_needRigidBody[i].AddComponent<Rigidbody>();
} // }
GameServices.timerServices.Push(this, 1.0f, delegate // GameServices.timerServices.Push(this, 1.0f, delegate
{ // {
for (int i = 0; i < m_needRigidBody.Length; i++) // for (int i = 0; i < m_needRigidBody.Length; i++)
{ // {
if(m_needRigidBody[i]) // if(m_needRigidBody[i])
{ // {
m_needRigidBody[i].SetActive(false); // m_needRigidBody[i].SetActive(false);
} // }
} // }
if(m_bottomObj) // if(m_bottomObj)
{ // {
m_bottomObj.SetActive(false); // m_bottomObj.SetActive(false);
} // }
}); // });
if (m_bIsTrigger && m_bIsRigid) // if (m_bIsTrigger && m_bIsRigid)
{ // {
if(m_bControl) // if(m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
} // }
//m_targetTrans.localPosition = m_pos; // //m_targetTrans.localPosition = m_pos;
//m_targetTrans.localRotation = m_rotation; // //m_targetTrans.localRotation = m_rotation;
} // }
} // }
} // }
//碰到了目标 // //碰到了目标
public void SetEnterTarget() // public void SetEnterTarget()
{ // {
m_bIsTrigger = true; // m_bIsTrigger = true;
if(m_bIsTrigger && m_bIsRigid) // if(m_bIsTrigger && m_bIsRigid)
{ // {
if (m_bControl) // if (m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
} // }
//m_targetTrans.localPosition = m_pos; // //m_targetTrans.localPosition = m_pos;
//m_targetTrans.localRotation = m_rotation; // //m_targetTrans.localRotation = m_rotation;
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class ThirdLevelBoxTarget : MonoBehaviour //public class ThirdLevelBoxTarget : MonoBehaviour
{ //{
public ThirdLevelBoxCollision m_levelBoxCollison; // public ThirdLevelBoxCollision m_levelBoxCollison;
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other != null && other.gameObject && other.gameObject.GetComponent<TargetView>() != null // if (other != null && other.gameObject && other.gameObject.GetComponent<TargetView>() != null
&& other.gameObject.GetComponent<TargetView>().parentTrans != null) // && other.gameObject.GetComponent<TargetView>().parentTrans != null)
{ // {
GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject; // GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject;
if (string.Equals(varObj.name, "Boy_01")) // if (string.Equals(varObj.name, "Boy_01"))
{ // {
TargetView varView = varObj.GetComponent<TargetView>(); // TargetView varView = varObj.GetComponent<TargetView>();
if(!varView.rigidBody) // if(!varView.rigidBody)
{ // {
return; // return;
} // }
BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget();
m_levelBoxCollison.SetEnterTarget(); // m_levelBoxCollison.SetEnterTarget();
if (varView) // if (varView)
{ // {
varView.DestroyRigidByOther(); // varView.DestroyRigidByOther();
} // }
} // }
} // }
} // }
} //}
...@@ -19,9 +19,9 @@ public class FifthLevelTrigger : MonoBehaviour ...@@ -19,9 +19,9 @@ public class FifthLevelTrigger : MonoBehaviour
private void Start() private void Start()
{ {
m_mouseRigidBody = m_mousePosTrans.gameObject.GetComponent<Rigidbody>(); m_mouseRigidBody = m_mousePosTrans.gameObject.GetComponent<Rigidbody>();
BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterTarget += onBalloonEnterTarget; //BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterTarget += onBalloonEnterTarget;
BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterGround += onBalloonEnterGround; //BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterGround += onBalloonEnterGround;
BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterSuccessTarget += onBalloonEnterSuccessTarget; //BattleCtrl.instance.levelManager.curLevel.chainRopeView.onBalloonEnterSuccessTarget += onBalloonEnterSuccessTarget;
//m_rigidBody = gameObject.GetComponentsInChildren<Rigidbody>(); //m_rigidBody = gameObject.GetComponentsInChildren<Rigidbody>();
} }
void onBalloonEnterTarget() void onBalloonEnterTarget()
......
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class FourthLevelTrigger : MonoBehaviour //public class FourthLevelTrigger : MonoBehaviour
{ //{
public Transform m_targetTrans; // public Transform m_targetTrans;
private Vector3 m_pos = new Vector3(0.21f,1.0f, -0.98f); // private Vector3 m_pos = new Vector3(0.21f,1.0f, -0.98f);
private Quaternion m_rotation = Quaternion.Euler(-14.7f, -146, -12.6f); // private Quaternion m_rotation = Quaternion.Euler(-14.7f, -146, -12.6f);
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget();
BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
m_targetTrans.localPosition = m_pos; // m_targetTrans.localPosition = m_pos;
m_targetTrans.localRotation = m_rotation; // m_targetTrans.localRotation = m_rotation;
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class LeftClawTrigger : MonoBehaviour //public class LeftClawTrigger : MonoBehaviour
{ //{
private void Awake() // private void Awake()
{ // {
//Mesh mesh = transform.GetComponent<MeshFilter>().mesh; // //Mesh mesh = transform.GetComponent<MeshFilter>().mesh;
//MeshCollider col = this.GetComponent<MeshCollider>(); // //MeshCollider col = this.GetComponent<MeshCollider>();
//col.sharedMesh = mesh; // //col.sharedMesh = mesh;
} // }
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
//特殊处理,因为碰到的骨骼可能不一样 // //特殊处理,因为碰到的骨骼可能不一样
if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelThreeIndex || // if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelThreeIndex ||
BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelFourIndex) // BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelFourIndex)
{ // {
GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject; // GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject;
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterLeftClaw(varObj); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterLeftClaw(varObj);
} // }
else // else
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterLeftClaw(other.gameObject); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterLeftClaw(other.gameObject);
} // }
} // }
} // }
private void OnTriggerExit(Collider other) // private void OnTriggerExit(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitLeftClaw(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitLeftClaw();
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class LevelLimitTrigger : MonoBehaviour //public class LevelLimitTrigger : MonoBehaviour
{ //{
private ChainRopeView m_chainRopeView; // private ChainRopeView m_chainRopeView;
private bool m_bControl = true; // private bool m_bControl = true;
private void Start() // private void Start()
{ // {
m_chainRopeView = BattleCtrl.instance.levelManager.curLevel.chainRopeView; // m_chainRopeView = BattleCtrl.instance.levelManager.curLevel.chainRopeView;
} // }
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target") && !m_chainRopeView.IsCatch && m_bControl) // if (other.gameObject.CompareTag("Target") && !m_chainRopeView.IsCatch && m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
BattleCtrl.instance.OnBattleFail(); // BattleCtrl.instance.OnBattleFail();
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class RightClawTrigger : MonoBehaviour //public class RightClawTrigger : MonoBehaviour
{ //{
private void Awake() // private void Awake()
{ // {
//Mesh mesh = transform.GetComponent<MeshFilter>().mesh; // //Mesh mesh = transform.GetComponent<MeshFilter>().mesh;
//MeshCollider col = this.GetComponent<MeshCollider>(); // //MeshCollider col = this.GetComponent<MeshCollider>();
//col.sharedMesh = mesh; // //col.sharedMesh = mesh;
} // }
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
//特殊处理,因为碰到的骨骼可能不一样 // //特殊处理,因为碰到的骨骼可能不一样
if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelThreeIndex || // if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelThreeIndex ||
BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelFourIndex) // BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelFourIndex)
{ // {
GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject; // GameObject varObj = other.gameObject.GetComponent<TargetView>().parentTrans.gameObject;
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterRightClaw(varObj); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterRightClaw(varObj);
} // }
else // else
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterRightClaw(other.gameObject); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterRightClaw(other.gameObject);
} // }
} // }
} // }
private void OnTriggerExit(Collider other) // private void OnTriggerExit(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitRightClaw(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitRightClaw();
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class SevenLevelOneTrigger : MonoBehaviour //public class SevenLevelOneTrigger : MonoBehaviour
{ //{
public SevenLevelTwoTrigger m_levelTwo; // public SevenLevelTwoTrigger m_levelTwo;
private bool m_bControl = true; // private bool m_bControl = true;
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target") && m_bControl) // if (other.gameObject.CompareTag("Target") && m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
m_levelTwo.OnTriggerOne(); // m_levelTwo.OnTriggerOne();
GameServices.timerServices.Push(this, 1.0f, delegate // GameServices.timerServices.Push(this, 1.0f, delegate
{ // {
if (m_levelTwo.Control) // if (m_levelTwo.Control)
{ // {
m_bControl = true; // m_bControl = true;
} // }
}); // });
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class SevenLevelTwoTrigger : MonoBehaviour //public class SevenLevelTwoTrigger : MonoBehaviour
{ //{
private bool m_bTriggerOne = false; // private bool m_bTriggerOne = false;
private bool m_bTriggerTwo = false; // private bool m_bTriggerTwo = false;
private bool m_bControl = true; // private bool m_bControl = true;
public bool Control => m_bControl; // public bool Control => m_bControl;
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target") && !m_bTriggerTwo) // if (other.gameObject.CompareTag("Target") && !m_bTriggerTwo)
{ // {
m_bTriggerTwo = true; // m_bTriggerTwo = true;
if (m_bTriggerTwo && m_bTriggerOne) // if (m_bTriggerTwo && m_bTriggerOne)
{ // {
if (m_bControl) // if (m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget();
} // }
} // }
GameServices.timerServices.Push(this, 1.0f, delegate // GameServices.timerServices.Push(this, 1.0f, delegate
{ // {
if (m_bControl) // if (m_bControl)
{ // {
m_bTriggerTwo = false; // m_bTriggerTwo = false;
} // }
}); // });
} // }
} // }
public void OnTriggerOne() // public void OnTriggerOne()
{ // {
m_bTriggerOne = true; // m_bTriggerOne = true;
if (m_bTriggerTwo && m_bTriggerOne) // if (m_bTriggerTwo && m_bTriggerOne)
{ // {
if (m_bControl) // if (m_bControl)
{ // {
m_bControl = false; // m_bControl = false;
BattleCtrl.instance.OnBattleWin(); // BattleCtrl.instance.OnBattleWin();
BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.CatchObjEnterTarget();
} // }
} // }
GameServices.timerServices.Push(this, 1.0f, delegate // GameServices.timerServices.Push(this, 1.0f, delegate
{ // {
if(m_bControl) // if(m_bControl)
{ // {
m_bTriggerOne = false; // m_bTriggerOne = false;
} // }
}); // });
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
//第三根爪 ////第三根爪
public class ThreeClawTrigger : MonoBehaviour //public class ThreeClawTrigger : MonoBehaviour
{ //{
private void OnTriggerEnter(Collider other) // private void OnTriggerEnter(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterThreeClaw(other.gameObject); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.EnterThreeClaw(other.gameObject);
} // }
} // }
private void OnTriggerExit(Collider other) // private void OnTriggerExit(Collider other)
{ // {
if (other.gameObject.CompareTag("Target")) // if (other.gameObject.CompareTag("Target"))
{ // {
BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitThreeClaw(); // BattleCtrl.instance.levelManager.curLevel.chainRopeView.ExitThreeClaw();
} // }
} // }
} //}
...@@ -7,8 +7,7 @@ using System; ...@@ -7,8 +7,7 @@ using System;
public class BattleUI : MonoBehaviour public class BattleUI : MonoBehaviour
{ {
public Button m_dragBtn;
public Button m_moveBtn;
public Button m_restartBtn; public Button m_restartBtn;
public Button m_nextLevelBtn; public Button m_nextLevelBtn;
public Button m_selectBtn; public Button m_selectBtn;
...@@ -74,8 +73,6 @@ public class BattleUI : MonoBehaviour ...@@ -74,8 +73,6 @@ public class BattleUI : MonoBehaviour
void Awake() void Awake()
{ {
instance = this; instance = this;
m_dragBtn.onClick.AddListener(SetDragMode);
m_moveBtn.onClick.AddListener(SetMoveMode);
m_restartBtn.onClick.AddListener(LoadCurLevel); m_restartBtn.onClick.AddListener(LoadCurLevel);
m_nextLevelBtn.onClick.AddListener(NextLevelBtnDown); m_nextLevelBtn.onClick.AddListener(NextLevelBtnDown);
m_selectBtn.onClick.AddListener(SelectLevel); m_selectBtn.onClick.AddListener(SelectLevel);
...@@ -87,17 +84,19 @@ public class BattleUI : MonoBehaviour ...@@ -87,17 +84,19 @@ public class BattleUI : MonoBehaviour
//m_fieldFarBtn.onClick.AddListener(FieldFarBtn); //m_fieldFarBtn.onClick.AddListener(FieldFarBtn);
//m_fieldNearBtn.onClick.AddListener(FieldNearBtn); //m_fieldNearBtn.onClick.AddListener(FieldNearBtn);
//m_ShowOrHideMouseText = m_ShowOrHideMouseObj.GetComponentInChildren<Text>(); //m_ShowOrHideMouseText = m_ShowOrHideMouseObj.GetComponentInChildren<Text>();
GameServices.audioServices.PlayBgm(GameServices.configService.audioConfig.GameBgm);
GameServices.configService.playerConfig.ClawMoveSpeed = 0.4f;//开始默认值 //GameServices.audioServices.PlayBgm(GameServices.configService.audioConfig.GameBgm);
BattleCtrl.instance.updateScore += UpdateScore; //GameServices.configService.playerConfig.ClawMoveSpeed = 0.4f;//开始默认值
BattleCtrl.instance.updateRanking += UpdateRanking;
BattleCtrl.instance.turnNextLevel += NextLevel;
} }
private void Start() private void Start()
{ {
m_boomBtn.interactable = false; m_boomBtn.interactable = false;
m_joystickImage = GameServices.inputService.joyStick.GetComponent<Image>(); m_joystickImage = GameServices.inputService.joyStick.GetComponent<Image>();
m_thumbImage = GameServices.inputService.joyStick.thumb.GetComponent<Image>(); m_thumbImage = GameServices.inputService.joyStick.thumb.GetComponent<Image>();
BattleCtrl.instance.updateScore += UpdateScore;
BattleCtrl.instance.updateRanking += UpdateRanking;
BattleCtrl.instance.turnNextLevel += NextLevel;
} }
private void Update() private void Update()
{ {
...@@ -114,14 +113,14 @@ public class BattleUI : MonoBehaviour ...@@ -114,14 +113,14 @@ public class BattleUI : MonoBehaviour
//print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle); //print("游戏是否开始:"+ BattleCtrl.instance.isStartBattle);
//print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle); //print("游戏是否结束:"+ BattleCtrl.instance.isEndBattle);
} }
void SetDragMode() //void SetDragMode()
{ //{
BattleCtrl.instance.levelManager.curLevel.chainView.SetDragMode(true); // BattleCtrl.instance.levelManager.curLevel.chainView.SetDragMode(true);
} //}
void SetMoveMode() //void SetMoveMode()
{ //{
BattleCtrl.instance.levelManager.curLevel.chainView.SetDragMode(false); // BattleCtrl.instance.levelManager.curLevel.chainView.SetDragMode(false);
} //}
// 当前关卡再来一次 // 当前关卡再来一次
void LoadCurLevel() void LoadCurLevel()
{ {
...@@ -178,6 +177,7 @@ public class BattleUI : MonoBehaviour ...@@ -178,6 +177,7 @@ public class BattleUI : MonoBehaviour
//开始游戏 //开始游戏
void StartBtn() void StartBtn()
{ {
print("点击开始按钮");
onStartBtn?.Invoke(); onStartBtn?.Invoke();
//m_startBtn.gameObject.SetActive(false); //m_startBtn.gameObject.SetActive(false);
m_startLogoObj.SetActive(false); m_startLogoObj.SetActive(false);
...@@ -234,19 +234,19 @@ public class BattleUI : MonoBehaviour ...@@ -234,19 +234,19 @@ public class BattleUI : MonoBehaviour
m_cameraFieldView.text = string.Format("fieldView{0:f1}", varCam.fieldOfView); m_cameraFieldView.text = string.Format("fieldView{0:f1}", varCam.fieldOfView);
} }
} }
//爪子移动速度增加 ////爪子移动速度增加
public void ClawMoveSpeedAddBtn() //public void ClawMoveSpeedAddBtn()
{ //{
onClawMoveSpeedAddBtn?.Invoke(); // onClawMoveSpeedAddBtn?.Invoke();
m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed); // m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed);
} //}
//爪子移动速度减少 ////爪子移动速度减少
public void ClawMoveSpeedDownBtn() //public void ClawMoveSpeedDownBtn()
{ //{
onClawMoveSpeedDownBtn?.Invoke(); // onClawMoveSpeedDownBtn?.Invoke();
m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed); // m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed);
} //}
//胜利 //胜利
public void OnBattleWin() public void OnBattleWin()
{ {
...@@ -335,7 +335,7 @@ public class BattleUI : MonoBehaviour ...@@ -335,7 +335,7 @@ public class BattleUI : MonoBehaviour
} }
GameServices.timerServices.Push(this, 1, delegate GameServices.timerServices.Push(this, 1, delegate
{ {
m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed); //m_clawMoveSpeed.text = string.Format("系数越小,越快\n{0:f3}", GameServices.configService.playerConfig.ClawMoveSpeed);
}); });
//开始---------------- //开始----------------
//TinySauce.OnGameStarted(string.Format("{0:d}", (BattleCtrl.instance.levelManager.CurLevelIndex + 1))); //TinySauce.OnGameStarted(string.Format("{0:d}", (BattleCtrl.instance.levelManager.CurLevelIndex + 1)));
...@@ -409,15 +409,15 @@ public class BattleUI : MonoBehaviour ...@@ -409,15 +409,15 @@ public class BattleUI : MonoBehaviour
public void ShowJoystick() public void ShowJoystick()
{ {
print("显示摇杆"); print("显示摇杆");
//m_joystickImage.color = Color.white; m_joystickImage.color = Color.white;
//m_thumbImage.color = Color.white; m_thumbImage.color = Color.white;
} }
//摇杆图标隐藏 //摇杆图标隐藏
public void HideJoystick() public void HideJoystick()
{ {
print("隐藏摇杆"); print("隐藏摇杆");
//m_joystickImage.color = Color.clear; m_joystickImage.color = Color.clear;
//m_thumbImage.color = Color.clear; m_thumbImage.color = Color.clear;
} }
public void UpdateScore() public void UpdateScore()
{ {
......
...@@ -74,7 +74,7 @@ public class SettingPanel : MonoBehaviour ...@@ -74,7 +74,7 @@ public class SettingPanel : MonoBehaviour
} }
else else
{ {
GameServices.audioServices.PlayBgm(GameServices.configService.audioConfig.GameBgm); // GameServices.audioServices.PlayBgm(GameServices.configService.audioConfig.GameBgm);
} }
} }
public void OnCloseClick() public void OnCloseClick()
......
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class ChainDragView : MonoBehaviour //public class ChainDragView : MonoBehaviour
{ //{
public Transform m_topTrans; // public Transform m_topTrans;
private float m_topPosY; // private float m_topPosY;
private void Start() // private void Start()
{ // {
m_topPosY = m_topTrans.position.y; // m_topPosY = m_topTrans.position.y;
GameServices.inputService.pad.onMoveVec3 += OnMove; // GameServices.inputService.pad.onMoveVec3 += OnMove;
} // }
//移动 // //移动
void OnMove(Vector3 dir) // void OnMove(Vector3 dir)
{ // {
float varParamDis = Screen.width * 0.8f / 2;//参数距离 // float varParamDis = Screen.width * 0.8f / 2;//参数距离
Vector3 varPos = m_topTrans.position; // Vector3 varPos = m_topTrans.position;
//向左滑 // //向左滑
if (dir.x > 0) // if (dir.x > 0)
{ // {
varPos.x -= dir.x / varParamDis * GameServices.configService.playerConfig.xDirMaxDis; // varPos.x -= dir.x / varParamDis * GameServices.configService.playerConfig.xDirMaxDis;
} // }
//向右滑 // //向右滑
if (dir.x < 0) // if (dir.x < 0)
{ // {
varPos.x += dir.x / varParamDis * GameServices.configService.playerConfig.xDirMinDis; // varPos.x += dir.x / varParamDis * GameServices.configService.playerConfig.xDirMinDis;
} // }
//向上滑 // //向上滑
if (dir.y < 0) // if (dir.y < 0)
{ // {
varPos.z += dir.y / varParamDis * GameServices.configService.playerConfig.yDirMinDis; // varPos.z += dir.y / varParamDis * GameServices.configService.playerConfig.yDirMinDis;
} // }
//向下滑 // //向下滑
if (dir.y > 0) // if (dir.y > 0)
{ // {
varPos.z -= dir.y / varParamDis * GameServices.configService.playerConfig.yDirMaxDis; // varPos.z -= dir.y / varParamDis * GameServices.configService.playerConfig.yDirMaxDis;
} // }
varPos.y = m_topPosY; // varPos.y = m_topPosY;
m_topTrans.position = varPos; // m_topTrans.position = varPos;
} // }
private void OnDestroy() // private void OnDestroy()
{ // {
if (GameServices.inputService != null) // if (GameServices.inputService != null)
{ // {
GameServices.inputService.pad.onMoveVec3 -= OnMove; // GameServices.inputService.pad.onMoveVec3 -= OnMove;
} // }
} // }
} //}
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
public class CameraMove : MonoBehaviour //public class CameraMove : MonoBehaviour
{ //{
private float m_PosY; // private float m_PosY;
private float m_FieldView; // private float m_FieldView;
private Camera m_camera; // private Camera m_camera;
// Start is called before the first frame update // // Start is called before the first frame update
void Start() // void Start()
{ // {
m_camera = gameObject.GetComponent<Camera>(); // m_camera = gameObject.GetComponent<Camera>();
m_PosY = transform.position.y; // m_PosY = transform.position.y;
m_FieldView = m_camera.fieldOfView; // m_FieldView = m_camera.fieldOfView;
BattleCtrl.instance.battleUI.onPosUpBtn = CameraPosUp; // BattleCtrl.instance.battleUI.onPosUpBtn = CameraPosUp;
BattleCtrl.instance.battleUI.onPosDownBtn = CameraPosDown; // BattleCtrl.instance.battleUI.onPosDownBtn = CameraPosDown;
BattleCtrl.instance.battleUI.onFieldFarBtn = CameraFieldFar; // BattleCtrl.instance.battleUI.onFieldFarBtn = CameraFieldFar;
BattleCtrl.instance.battleUI.onFieldNearBtn = CameraFieldNear; // BattleCtrl.instance.battleUI.onFieldNearBtn = CameraFieldNear;
} // }
//镜头拉上 // //镜头拉上
void CameraPosUp() // void CameraPosUp()
{ // {
Vector3 varVec = transform.position; // Vector3 varVec = transform.position;
varVec.y += Time.deltaTime * GameServices.configService.playerConfig.cameraMoveSpeed; // varVec.y += Time.deltaTime * GameServices.configService.playerConfig.cameraMoveSpeed;
transform.position = varVec; // transform.position = varVec;
} // }
//镜头拉下 // //镜头拉下
void CameraPosDown() // void CameraPosDown()
{ // {
Vector3 varVec = transform.position; // Vector3 varVec = transform.position;
varVec.y -= Time.deltaTime * GameServices.configService.playerConfig.cameraMoveSpeed; // varVec.y -= Time.deltaTime * GameServices.configService.playerConfig.cameraMoveSpeed;
transform.position = varVec; // transform.position = varVec;
} // }
//镜头拉远 // //镜头拉远
void CameraFieldFar() // void CameraFieldFar()
{ // {
m_camera.fieldOfView += Time.deltaTime * GameServices.configService.playerConfig.cameraFieldSpeed; // m_camera.fieldOfView += Time.deltaTime * GameServices.configService.playerConfig.cameraFieldSpeed;
} // }
//镜头拉近 // //镜头拉近
void CameraFieldNear() // void CameraFieldNear()
{ // {
m_camera.fieldOfView -= Time.deltaTime * GameServices.configService.playerConfig.cameraFieldSpeed; // m_camera.fieldOfView -= Time.deltaTime * GameServices.configService.playerConfig.cameraFieldSpeed;
} // }
} //}
...@@ -10,14 +10,14 @@ using UnityEngine.Profiling; ...@@ -10,14 +10,14 @@ using UnityEngine.Profiling;
public class LevelCtrl : MonoBehaviour public class LevelCtrl : MonoBehaviour
{ {
public ChainView m_chainView;//爪钩view //public ChainView m_chainView;//爪钩view
public ChainRopeView m_chainRopeView;//娃娃机爪钩 //public ChainRopeView m_chainRopeView;//娃娃机爪钩
public Camera m_camera; public Camera m_camera;
public BombView m_bombView;//炸弹view public BombView m_bombView;//炸弹view
public CarView m_carView;//车 public CarView m_carView;//车
//public TargetView m_targetView;//触发器 //public TargetView m_targetView;//触发器
public ChainView chainView => m_chainView; //public ChainView chainView => m_chainView;
public ChainRopeView chainRopeView => m_chainRopeView; //public ChainRopeView chainRopeView => m_chainRopeView;
public Camera cam => m_camera; public Camera cam => m_camera;
public BombView bombView => m_bombView; public BombView bombView => m_bombView;
public CarView carView => m_carView; public CarView carView => m_carView;
......
...@@ -112,52 +112,52 @@ public class AudioServices : MonoBehaviour ...@@ -112,52 +112,52 @@ public class AudioServices : MonoBehaviour
} }
} }
public void PlayAudio(AudioClip clip, bool isLoop = false, Action onPlayEnd = null) //public void PlayAudio(AudioClip clip, bool isLoop = false, Action onPlayEnd = null)
{ //{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0) // if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{ // {
return; // return;
} // }
AudioSource source = GetSource(); // AudioSource source = GetSource();
source.clip = clip; // source.clip = clip;
source.loop = isLoop; // source.loop = isLoop;
source.volume = GlobalConfig.isEnableSound ? 1 : 0; //根据全局配置设置音量 // source.volume = GlobalConfig.isEnableSound ? 1 : 0; //根据全局配置设置音量
source.Play(); // source.Play();
GameServices.timerServices.Push(this, source.clip.length, delegate { // GameServices.timerServices.Push(this, source.clip.length, delegate {
RecycleSource(source); // RecycleSource(source);
onPlayEnd?.Invoke(); // onPlayEnd?.Invoke();
}); // });
} //}
public AudioSource GetPlayAudioSource(AudioClip clip) //public AudioSource GetPlayAudioSource(AudioClip clip)
{ //{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0) // if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{ // {
return null; // return null;
} // }
AudioSource source = GetSource(); // AudioSource source = GetSource();
source.clip = clip; // source.clip = clip;
source.loop = true; // source.loop = true;
source.volume = GlobalConfig.isEnableSound ? 1 : 0; //根据全局配置设置音量 // source.volume = GlobalConfig.isEnableSound ? 1 : 0; //根据全局配置设置音量
source.Play(); // source.Play();
return source; // return source;
} //}
public void AudioPlayFinished(AudioSource source) //public void AudioPlayFinished(AudioSource source)
{ //{
if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0) // if (LocalRecord.HasKey(GlobalConfig.SoundKey) && LocalRecord.GetIntRecord(GlobalConfig.SoundKey) == 0)
{ // {
return; // return;
} // }
RecycleSource(source); // RecycleSource(source);
} //}
private IEnumerator AudioPlayFinished(AudioSource source, float time, Action callback) //private IEnumerator AudioPlayFinished(AudioSource source, float time, Action callback)
{ //{
yield return new WaitForSeconds(time); // yield return new WaitForSeconds(time);
RecycleSource(source); // RecycleSource(source);
callback?.Invoke(); // callback?.Invoke();
} //}
private void OnDestroy() private void OnDestroy()
{ {
......
using System.Collections; //using System.Collections;
using System.Collections.Generic; //using System.Collections.Generic;
using UnityEngine; //using UnityEngine;
using System; //using System;
#if UNITY_EDITOR //#if UNITY_EDITOR
using UnityEditor; //using UnityEditor;
#endif //#endif
public class BattleConfig : ScriptableObject //public class BattleConfig : ScriptableObject
{ //{
public PlayerConfig playerConfig; // public PlayerConfig playerConfig;
public LevelConfig levelConfig; // public LevelConfig levelConfig;
public AudioConfig audioConfig; // public AudioConfig audioConfig;
#if UNITY_EDITOR //#if UNITY_EDITOR
[MenuItem("Tools/Rope/生成战斗配置")] // [MenuItem("Tools/Rope/生成战斗配置")]
public static void GenBattleConfig() // public static void GenBattleConfig()
{ // {
string savePath = @"Assets/Resources/BattleConfig.asset"; // string savePath = @"Assets/Resources/BattleConfig.asset";
var data = ScriptableObject.CreateInstance("BattleConfig"); // var data = ScriptableObject.CreateInstance("BattleConfig");
AssetDatabase.CreateAsset(data, savePath); // AssetDatabase.CreateAsset(data, savePath);
} // }
#endif //#endif
/// <summary> // /// <summary>
/// 加载配置 // /// 加载配置
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
public static BattleConfig LoadConfig() // public static BattleConfig LoadConfig()
{ // {
return Resources.Load<BattleConfig>("BattleConfig"); // return Resources.Load<BattleConfig>("BattleConfig");
} // }
} //}
[Serializable] //[Serializable]
public class PlayerConfig //public class PlayerConfig
{ //{
[Header("手移动的速度")] // [Header("手移动的速度")]
public float moveSpeed = 6; // public float moveSpeed = 6;
[Header("X方向最小距离")] // [Header("X方向最小距离")]
public float xDirMinDis = -5; // public float xDirMinDis = -5;
[Header("X方向最大距离")] // [Header("X方向最大距离")]
public float xDirMaxDis = 5; // public float xDirMaxDis = 5;
[Header("Z方向最小距离")] // [Header("Z方向最小距离")]
public float yDirMinDis = -5; // public float yDirMinDis = -5;
[Header("Z方向最大距离")] // [Header("Z方向最大距离")]
public float yDirMaxDis = 5; // public float yDirMaxDis = 5;
[Header("爪的最大角度")] // [Header("爪的最大角度")]
public float clawMaxAngle = 30.0f; // public float clawMaxAngle = 30.0f;
[Header("爪的旋转速度")] // [Header("爪的旋转速度")]
public float clawRotateSpeed = 20.0f; // public float clawRotateSpeed = 20.0f;
[Header("绳子缩减的速度")] // [Header("绳子缩减的速度")]
public float ropeReduceSpeed = 2.0f; // public float ropeReduceSpeed = 2.0f;
[Header("绳子伸长的速度")] // [Header("绳子伸长的速度")]
public float ropeExtendSpeed = 3.0f; // public float ropeExtendSpeed = 3.0f;
[Header("爪身的旋转速度")] // [Header("爪身的旋转速度")]
public float clawBodyRotateSpeed = 2.0f; // public float clawBodyRotateSpeed = 2.0f;
[Header("镜头移动速度")] // [Header("镜头移动速度")]
public float cameraMoveSpeed = 2; // public float cameraMoveSpeed = 2;
[Header("镜头远近速度")] // [Header("镜头远近速度")]
public float cameraFieldSpeed = 2; // public float cameraFieldSpeed = 2;
//爪子移动速度 // //爪子移动速度
public float ClawMoveSpeed { get; set; } // public float ClawMoveSpeed { get; set; }
} //}
[Serializable] //[Serializable]
public class LevelConfig //public class LevelConfig
{ //{
[Header("关卡3的地面位置")] // [Header("关卡3的地面位置")]
public float landPosY = 1.9f; // public float landPosY = 1.9f;
[Header("第一关目标名称")] // [Header("第一关目标名称")]
public string firstLevelGoalName = "Tree_Star"; // public string firstLevelGoalName = "Tree_Star";
[Header("第二关目标名称")] // [Header("第二关目标名称")]
public string secondLevelGoalName = "Boy_01"; // public string secondLevelGoalName = "Boy_01";
[Header("第三关目标名称")] // [Header("第三关目标名称")]
public string thirdLevelGoalName = "Boy_02"; // public string thirdLevelGoalName = "Boy_02";
[Header("第四关目标名称")] // [Header("第四关目标名称")]
public string fourthLevelGoalName = "SM_Prop_Crate_03 (2)"; // public string fourthLevelGoalName = "SM_Prop_Crate_03 (2)";
[Header("第五关目标名称")] // [Header("第五关目标名称")]
public string fifthLevelGoalName1 = "BlueDark_BunnyBalloon"; // public string fifthLevelGoalName1 = "BlueDark_BunnyBalloon";
public string fifthLevelGoalName2 = "SM_Icon_Sword_01"; // public string fifthLevelGoalName2 = "SM_Icon_Sword_01";
public string fifthLevelGoalName3 = "SM_Primitive_Sphere_02"; // public string fifthLevelGoalName3 = "SM_Primitive_Sphere_02";
[Header("第六关目标名称")] // [Header("第六关目标名称")]
public string sixthLevelGoalName = "SM_Primitive_Pyramid_01"; // public string sixthLevelGoalName = "SM_Primitive_Pyramid_01";
[Header("第七关目标名称")] // [Header("第七关目标名称")]
public string seventhLevelGoalName = "SM_Primitive_Cube_04 (1)"; // public string seventhLevelGoalName = "SM_Primitive_Cube_04 (1)";
} //}
[Serializable] //[Serializable]
public class AudioConfig //public class AudioConfig
{ //{
[Header("失败音效列表")] // [Header("失败音效列表")]
public List<AudioClip> failList; // public List<AudioClip> failList;
[Header("游戏bmg")] // [Header("游戏bmg")]
public AudioClip GameBgm; // public AudioClip GameBgm;
[Header("胜利")] // [Header("胜利")]
public AudioClip Success; // public AudioClip Success;
[Header("爪子下降或者上升")] // [Header("爪子下降或者上升")]
public AudioClip clawDownOrUp; // public AudioClip clawDownOrUp;
/// <summary> // /// <summary>
/// 获取随机一个失败叫声 // /// 获取随机一个失败叫声
/// </summary> // /// </summary>
/// <returns></returns> // /// <returns></returns>
public AudioClip GetFail() // public AudioClip GetFail()
{ // {
int index = UnityEngine.Random.Range(0, failList.Count); // int index = UnityEngine.Random.Range(0, failList.Count);
return failList[index]; // return failList[index];
} // }
} //}
...@@ -5,12 +5,12 @@ using UnityEngine; ...@@ -5,12 +5,12 @@ using UnityEngine;
public class ConfigServices : BaseServices public class ConfigServices : BaseServices
{ {
public BattleConfig config; //public BattleConfig config;
public override void OnStart() public override void OnStart()
{ {
base.OnStart(); base.OnStart();
config = BattleConfig.LoadConfig(); //config = BattleConfig.LoadConfig();
servicesEnable = true; servicesEnable = true;
} }
} }
\ No newline at end of file
...@@ -21,7 +21,7 @@ public class GameServices : MonoBehaviour ...@@ -21,7 +21,7 @@ public class GameServices : MonoBehaviour
/// <summary> /// <summary>
/// 战斗配置服务 /// 战斗配置服务
/// </summary> /// </summary>
public static BattleConfig configService => _ConfigService.config; //public static BattleConfig configService => _ConfigService.config;
/// <summary> /// <summary>
/// 计时器服务 /// 计时器服务
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 988d4f82fb2c0ee49af6836de40fd04f guid: 317d19313d1d7204e9bbc37122116e7f
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 911c6a0aabc57ab4280dfa49390aaf69 guid: ca40beb7fc6998f40a6e15a59c6ab599
folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: d967723201452894680314048a609a92 guid: 325c11e064841204bbd6de7c85bebef6
folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 31e6a095f36d9344dafe30febb77c5ef guid: aa43ce62596b0784081ec9bd0abc8516
NativeFormatImporter: folderAsset: yes
DefaultImporter:
externalObjects: {} externalObjects: {}
mainObjectFileID: 0
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
fileFormatVersion: 2
guid: 2e117c0bfc6741e4ebc4a8c8aebc0b8a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 55c4962f2a6593c4b9c1bb6003b1ff08
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
...@@ -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:
......
...@@ -19,8 +19,7 @@ public class AIMove : MonoBehaviour ...@@ -19,8 +19,7 @@ public class AIMove : MonoBehaviour
public float HSpeed = 10.0f; public float HSpeed = 10.0f;
public int SpeedLevel = 1; public int SpeedLevel = 1;
public float AddSpeed = 10.0f; public float AddSpeed = 10.0f;
[Tooltip("AI移动方式")]
public MoveType moveType = MoveType.MoveType3;
[Tooltip("游戏结束每秒减少的速度")] [Tooltip("游戏结束每秒减少的速度")]
public float deceleration = 15; public float deceleration = 15;
...@@ -453,25 +452,8 @@ public class AIMove : MonoBehaviour ...@@ -453,25 +452,8 @@ public class AIMove : MonoBehaviour
void UpdateJoystick() void UpdateJoystick()
{ {
print("摇杆控制左右"); print("摇杆控制左右");
switch (moveType)
{ MoveType3(); //比较生硬的形式
case MoveType.MoveType1:
MoveType1(); //阻尼的形式
break;
case MoveType.MoveType2:
MoveType2(); //乱飘的形式
break;
case MoveType.MoveType3:
MoveType3(); //比较生硬的形式
break;
default:
MoveType3(); //比较生硬的形式
break;
}
//MoveType1(); //阻尼的形式
//MoveType2(); //乱飘的形式
//MoveType3(); //比较生硬的形式
} }
public void MoveType1() public void MoveType1()
......
fileFormatVersion: 2
guid: 181349c69b40ac84eb8897eebf413d78
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomFood : MonoBehaviour
{
public int foodNumber = 10;
public List<Transform> foodPoint;
public List<GameObject> foods;
void Start()
{
GenerateRandomFood(10);
}
// Update is called once per frame
void Update()
{
GameObject[] currFoods= GameObject.FindGameObjectsWithTag("Food");
if (currFoods.Length == 0)
{
GenerateRandomFood(10);
}
}
/// <summary>
/// 生成number个随机食物
/// </summary>
/// <param name="number"></param>
public void GenerateRandomFood(int number)
{
for (int i = 0; i < number; i++)
{
GameObject obj = getRandomFoodObj();
Transform foodParent = getRandomPos();
Instantiate(obj, foodParent.position, foodParent.rotation, foodParent);
}
}
private Transform getRandomPos()
{
return foodPoint[Random.Range(0, foodPoint.Count)];
}
private GameObject getRandomFoodObj()
{
return foods[Random.Range(0, foods.Count)];
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 302f094fe9e75cb4cbc0ebddc6c24c98 guid: 88224c51f1a97cf40895dff846d2a5b3
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
...@@ -72,10 +72,10 @@ public class Enemy_Vertigo : MonoBehaviour ...@@ -72,10 +72,10 @@ public class Enemy_Vertigo : MonoBehaviour
if (hit.collider.tag == "Player") if (hit.collider.tag == "Player")
{ {
life--; life--;
hit.gameObject.GetComponent<PlayerMove>().Vertigo(VertigoTime);//眩晕1秒 //hit.gameObject.GetComponent<PlayerMove>().Vertigo(VertigoTime);//眩晕1秒
//hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevel(-1); //等级降低一级 //hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevel(-1); //等级降低一级
//print("减速前:"+ hit.gameObject.GetComponent<PlayerMove>().SpeedLevel); //print("减速前:"+ hit.gameObject.GetComponent<PlayerMove>().SpeedLevel);
hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevelToPrevMaxLevelAndChangeModel(); //等级降低到上一级 // hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevelToPrevMaxLevelAndChangeModel(); //等级降低到上一级
//print("减速后:" + hit.gameObject.GetComponent<PlayerMove>().SpeedLevel); //print("减速后:" + hit.gameObject.GetComponent<PlayerMove>().SpeedLevel);
Destroy(gameObject); Destroy(gameObject);
} }
......
...@@ -48,10 +48,10 @@ public class GiantRock : MonoBehaviour ...@@ -48,10 +48,10 @@ public class GiantRock : MonoBehaviour
if (hit.collider.tag == "Player") if (hit.collider.tag == "Player")
{ {
life--; life--;
hit.gameObject.GetComponent<PlayerMove>().Vertigo(VertigoTime);//眩晕1秒 //hit.gameObject.GetComponent<PlayerMove>().Vertigo(VertigoTime);//眩晕1秒
//hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevel(-1); //等级降低一级 //hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevel(-1); //等级降低一级
//print("减速前:"+ hit.gameObject.GetComponent<PlayerMove>().SpeedLevel); //print("减速前:"+ hit.gameObject.GetComponent<PlayerMove>().SpeedLevel);
hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevelToPrevMaxLevelAndChangeModel(); //等级降低到上一级 //hit.gameObject.GetComponent<PlayerMove>().ChangeSpeedLevelToPrevMaxLevelAndChangeModel(); //等级降低到上一级
//print("减速后:" + hit.gameObject.GetComponent<PlayerMove>().SpeedLevel); //print("减速后:" + hit.gameObject.GetComponent<PlayerMove>().SpeedLevel);
Destroy(gameObject); Destroy(gameObject);
} }
......
This diff is collapsed.
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
/// <summary>
/// 模拟轨迹
/// </summary>
public class TestChinarForece : MonoBehaviour
{
public Transform DirectionBall; //指向方向的球
public Transform TrackBallTransform; //轨迹球
private Rigidbody trackBallRigidbody; //
public Slider VelocitySlider; //力度值 滑动器
public Slider AngleSlider; //角度值
private PhysicsScene physicsScene; //物理场景
public GameObject[] OtherGameObjects; //所有小球
public int TrackFrames = 80; //轨迹帧率
private int ICount; //对象计数
private float timer;
/// <summary>
/// 对象池字典
/// </summary>
private readonly Dictionary<int, Transform> goDict = new Dictionary<int, Transform>();
void Start()
{
AngleSlider.onValueChanged.AddListener(OnValueChanged);
trackBallRigidbody = TrackBallTransform.GetComponent<Rigidbody>(); //TrackBall 有rigibody
Physics.autoSimulation = false;
CreatePhysicsScene(); //该脚本只实例化一次。
GeneratePool();
}
/// <summary>
/// 创建一个用于模拟的场景
/// </summary>
private void CreatePhysicsScene()
{
print("创建指向模拟场景");
var scene = SceneManager.CreateScene("指向模拟场景");
physicsScene = scene.GetPhysicsScene();
SceneManager.MoveGameObjectToScene(DirectionBall.parent.gameObject, scene); //DirBall 有parent
for (int i = 3; i < OtherGameObjects.Length; i++)
{
SceneManager.MoveGameObjectToScene(OtherGameObjects[i], scene);
}
}
/// <summary>
/// 生成池子
/// 轨迹球 重复利用
/// </summary>
private void GeneratePool()
{
var GoPoolPos = new Vector3(100, 100, 100);
for (int i = 0; i < TrackFrames; i++)
{
var iclone = Instantiate(TrackBallTransform); //TrackBallTransform
iclone.position = GoPoolPos;
iclone.localScale = Vector3.one * 0.5f;
goDict.Add(i, iclone);
}
}
/// <summary>
/// 重置球位置
/// 其他球要隐形的
/// </summary>
private void resetOtherBall()
{
for (int i = 0; i < 3; i++)
{
OtherGameObjects[i + 3].transform.position = OtherGameObjects[i].transform.position;
}
}
/// <summary>
/// 角度发生改变时
/// </summary>
public void OnValueChanged(float value)
{
Physics.autoSimulation = false; //关闭 物理模拟
TrackBallTransform.position = transform.position;
trackBallRigidbody.velocity = Vector3.zero;
DirectionBall.parent.rotation = Quaternion.Euler(0, value, 0);
Vector3 vector3 = DirectionBall.position - transform.position;
trackBallRigidbody.AddForce(vector3 * VelocitySlider.value);
for (int i = 0; i < TrackFrames; i++)
{
physicsScene.Simulate(0.02f);
GoPool().position = TrackBallTransform.position;
}
}
/// <summary>
/// 简化版对象池
/// 每次调用返回一个新对象
/// </summary>
private Transform GoPool()
{
ICount++;
if (ICount == TrackFrames - 1)
{
ICount = 0;
}
return goDict[ICount];
}
void Update()
{
if (!EventSystem.current.IsPointerOverGameObject())
{
if (Input.GetMouseButtonUp(0))
{
Physics.autoSimulation = true;
Vector3 vector3 = DirectionBall.position - transform.position;
GetComponent<Rigidbody>().AddForce(vector3 * VelocitySlider.value); //当前脚本挂着物体有rigibody
}
}
}
}
fileFormatVersion: 2
guid: b916ff68118d37146a6621eeaf667437
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
This diff is collapsed.
fileFormatVersion: 2
guid: 45b864dd5621c044d92aa9ab676979d3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestTrigger : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
print(111);
}
private void OnTriggerEnter(Collider other)
{
print(other);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
C:\Program Files\Java\jre1.8.0_74\bin>keytool -exportcert -alias androiddebugkey -keystore D:\Android_keystore\user.keystore | C:\openss1-0.9.8k_X64\bin\openssl shal -binary |C:\openssl-0.9.8k_X64\bin\openssl base64
mBiKXr2MyG2TrTkTYfnKF/eLFuM=
com.facebook.unity.FBUnityDeepLinkingActivity
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