255 lines
4.4 KiB
Plaintext
255 lines
4.4 KiB
Plaintext
|
using Sirenix.OdinInspector;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.Events;
|
|||
|
|
|||
|
[System.Serializable]
|
|||
|
public struct WeaponDirection
|
|||
|
{
|
|||
|
[Range(0f, Mathf.PI * 2.0f)]
|
|||
|
public float Direction;
|
|||
|
}
|
|||
|
|
|||
|
public class PHomeWeapon : MonoBehaviour
|
|||
|
{
|
|||
|
[SerializeField]
|
|||
|
private string m_description;
|
|||
|
public string Description
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_description;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// ÿ<>η<EFBFBD><CEB7><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ɵ<EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
//[SerializeField]
|
|||
|
//protected int m_projectileCount;
|
|||
|
//public int ProjectileCount
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// return m_projectileCount;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
protected string m_weaponName;
|
|||
|
public string WeaponName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_weaponName;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
|||
|
/// </summary>
|
|||
|
[SerializeField]
|
|||
|
protected float m_fireRate;
|
|||
|
public float FireRate
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_fireRate;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
m_fireRate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
[SerializeField]
|
|||
|
protected int m_shootCount;
|
|||
|
public int ShootCount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_shootCount;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
m_shootCount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
protected Sprite m_desImage;
|
|||
|
public Sprite DesImage
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_desImage;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
protected int m_level;
|
|||
|
public int Level
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_level;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
m_level = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//[SerializeField]
|
|||
|
//protected bool m_circlePos;
|
|||
|
//public bool CirclePos
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// return m_circlePos;
|
|||
|
// }
|
|||
|
// set
|
|||
|
// {
|
|||
|
// m_circlePos = value;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//[SerializeField]
|
|||
|
//protected bool m_onCircle;
|
|||
|
//public bool OnCircle
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// return m_onCircle;
|
|||
|
// }
|
|||
|
// set
|
|||
|
// {
|
|||
|
// m_onCircle = value;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//[SerializeField]
|
|||
|
//protected float m_pointRandomDis;
|
|||
|
//public float PointRandomDis
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// return m_pointRandomDis;
|
|||
|
// }
|
|||
|
// set
|
|||
|
// {
|
|||
|
// m_pointRandomDis = value;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
protected List<WeaponLevelConfig> m_levelConfig;
|
|||
|
public List<WeaponLevelConfig> LevelConfig
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_levelConfig;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected PHomeUnit m_unit;
|
|||
|
public PHomeUnit Unit
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_unit;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[BoxGroup("Debug")]
|
|||
|
[SerializeField]
|
|||
|
protected float m_coolDownTimer;
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
public UnityEvent OnWeaponStartFiring;
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
public UnityEvent OnAfterWeaponFired;
|
|||
|
|
|||
|
private PHomeFirer m_firer;
|
|||
|
protected PHomeFirer Firer
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (m_firer == null)
|
|||
|
{
|
|||
|
m_firer = GetComponent<PHomeFirer>();
|
|||
|
}
|
|||
|
|
|||
|
return m_firer;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void Virtual_Update()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void Init(PHomeUnit unit)
|
|||
|
{
|
|||
|
m_unit = unit;
|
|||
|
ResetLevel();
|
|||
|
}
|
|||
|
|
|||
|
public void ResetLevel()
|
|||
|
{
|
|||
|
m_level = (m_unit as PHomePet).Level;
|
|||
|
RefreshAttr();
|
|||
|
}
|
|||
|
|
|||
|
public void RefreshAttr()
|
|||
|
{
|
|||
|
for (int i = 0; i < LevelConfig.Count; i++)
|
|||
|
{
|
|||
|
if (LevelConfig[i].Level == m_level)
|
|||
|
{
|
|||
|
FireRate = LevelConfig[i].FireRate;
|
|||
|
//ShootRate = LevelConfig[i].ShootRate;
|
|||
|
ShootCount = LevelConfig[i].ShootCount;
|
|||
|
m_projectilePrefab = LevelConfig[i].m_projectilePrefab;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool DuringCoolDown
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (m_coolDownTimer > 0);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
[SerializeField]
|
|||
|
protected GameObject m_projectilePrefab;
|
|||
|
public GameObject ProjectilePrefab
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return m_projectilePrefab;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
Virtual_Update();
|
|||
|
}
|
|||
|
|
|||
|
public void EnterCooldown()
|
|||
|
{
|
|||
|
m_coolDownTimer = 1f / FireRate;
|
|||
|
}
|
|||
|
}
|
|||
|
|