148 lines
4.1 KiB
C#
148 lines
4.1 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2020-09-02
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "UI_InRide" company="Kimch"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace G
|
|||
|
{
|
|||
|
public class UI_InRide : MonoBehaviour
|
|||
|
{
|
|||
|
private Transform _cha1;
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
public static UI_InRide Instance;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
var canvas = GetComponent<Canvas>();
|
|||
|
canvas.worldCamera = KUIRoot.RootCamera;
|
|||
|
var canvasScaler = GetComponent<UnityEngine.UI.CanvasScaler>();
|
|||
|
canvasScaler.matchWidthOrHeight = KUIRoot.RootCanvas.GetComponent<UnityEngine.UI.CanvasScaler>().matchWidthOrHeight;
|
|||
|
|
|||
|
_cha1 = GameObject.FindWithTag("Player").transform;
|
|||
|
}
|
|||
|
|
|||
|
private void OnApplicationPause(bool pocus)
|
|||
|
{
|
|||
|
if (pocus)
|
|||
|
{
|
|||
|
//PauseOn();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Field
|
|||
|
|
|||
|
private int _killerNumber;
|
|||
|
private int _rewardNumber;
|
|||
|
private int _injuredNumver;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
/// <summary>
|
|||
|
/// 显示数量增加
|
|||
|
/// </summary>
|
|||
|
public void DamagedAdd(int damage)
|
|||
|
{
|
|||
|
var board = BoardManager.Instance.CreateDamageBoard("DamageBoard3");
|
|||
|
board.SetValue(damage, DamageBoardType.TYPE_COPY_PORP);
|
|||
|
board.SetPosition(_cha1.position + new Vector3(0f, 0.2f, 0f));
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 显示数量减少
|
|||
|
/// </summary>
|
|||
|
public void DamagedReduce(int damage)
|
|||
|
{
|
|||
|
var board = BoardManager.Instance.CreateDamageBoard("DamageBoard4");
|
|||
|
board.SetValue(damage, DamageBoardType.PLAYER_HP_SUB);
|
|||
|
board.SetPosition(_cha1.position + new Vector3(0f, 0.2f, 0f));
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 获得道具
|
|||
|
/// </summary>
|
|||
|
public void GainProp(int id, int amount)
|
|||
|
{
|
|||
|
if (id == 3001)
|
|||
|
{
|
|||
|
DamagedAdd(1);
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_PROP, amount);
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 击杀敌人
|
|||
|
/// </summary>
|
|||
|
public void GainKiller(int id, int amount, int a)
|
|||
|
{
|
|||
|
DamagedAdd(a);
|
|||
|
//_killerNumber = amount;
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_KILLER, a, id.ToString());
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 受到伤害
|
|||
|
/// </summary>
|
|||
|
public void GainAttacked(int amount, int a)
|
|||
|
{
|
|||
|
DamagedReduce(-1);
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_INJURED, amount);
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 进度条
|
|||
|
/// </summary>
|
|||
|
public void GainComplete(float complete)
|
|||
|
{
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_COMPLETE, Mathf.Clamp01(complete));
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 游戏结束
|
|||
|
/// </summary>
|
|||
|
public void GameOver() //结束
|
|||
|
{
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_END);
|
|||
|
//ResetViewData();
|
|||
|
}
|
|||
|
|
|||
|
public void PauseOn() //暂停
|
|||
|
{
|
|||
|
Time.timeScale = 0f;
|
|||
|
}
|
|||
|
|
|||
|
public void OnClickContinue() //继续
|
|||
|
{
|
|||
|
Time.timeScale = 1f;
|
|||
|
}
|
|||
|
public void OnClickQuit()//退出
|
|||
|
{
|
|||
|
//Time.timeScale = 1f;
|
|||
|
GlobalNotifier.PostNotification(GlobalDefine.EVENT_COPY_END);
|
|||
|
//ResetViewData();
|
|||
|
}
|
|||
|
|
|||
|
private void ResetViewData()
|
|||
|
{
|
|||
|
_killerNumber = 0;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|