114 lines
3.5 KiB
C#
114 lines
3.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using cfg.BlacksmithData;
|
|
using Spine.Unity;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
using Vector3 = System.Numerics.Vector3;
|
|
|
|
/// <summary>
|
|
/// 玩家战斗预制体资源
|
|
/// </summary>
|
|
public class PlayerItem : MonoBehaviour
|
|
{
|
|
[SerializeField] private SkeletonAnimation spine;
|
|
private BattleEquipment _battleEquipment;
|
|
[SerializeField]
|
|
private List<GameObject> _gameObjects = new List<GameObject>();
|
|
|
|
public playerAniType Type
|
|
{
|
|
get
|
|
{
|
|
return _type;
|
|
}
|
|
set
|
|
{
|
|
if (_type!=value)
|
|
{
|
|
_type = value;
|
|
switch (_type)
|
|
{
|
|
case playerAniType.play:
|
|
spine.state.SetAnimation(0, "attack_3", true);
|
|
break;
|
|
case playerAniType.wait:
|
|
spine.state.SetAnimation(0, "idle_3", true);
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private playerAniType _type = playerAniType.wait;
|
|
|
|
public void SetModel(int i)
|
|
{
|
|
spine.Skeleton.SetSkin("mod_"+i);
|
|
spine.Skeleton.SetSlotsToSetupPose();
|
|
}
|
|
public void SetData(BattleEquipment battleData)
|
|
{
|
|
switch (_type)
|
|
{
|
|
case playerAniType.play:
|
|
spine.state.SetAnimation(0, "attack_3", true);
|
|
break;
|
|
case playerAniType.wait:
|
|
spine.state.SetAnimation(0, "idle_3", true);
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
_battleEquipment = battleData;
|
|
if (_battleEquipment.Weapon!=null)
|
|
{
|
|
_battleEquipment.Weapon.AddAction(SkillEvent);
|
|
}
|
|
if (_battleEquipment.Weapon2!=null)
|
|
{
|
|
_battleEquipment.Weapon2.AddAction(SkillEvent);
|
|
}
|
|
if (_battleEquipment.Armor!=null)
|
|
{
|
|
_battleEquipment.Armor.AddAction(SkillEvent);
|
|
}
|
|
if (_battleEquipment.AudioUniversal!=null)
|
|
{
|
|
_battleEquipment.AudioUniversal.AddAction(SkillEvent);
|
|
}
|
|
if (_battleEquipment.AudioWeapon!=null)
|
|
{
|
|
_battleEquipment.AudioWeapon.AddAction(SkillEvent);
|
|
}
|
|
if (_battleEquipment.AudioWeapon2!=null)
|
|
{
|
|
_battleEquipment.AudioWeapon2.AddAction(SkillEvent);
|
|
}
|
|
|
|
PrefabPool.ins.AddPond("Prefab/Buttle", 12);
|
|
}
|
|
|
|
private void SkillEvent(SkillState data)
|
|
{
|
|
PrefabPool.ins.LoadObj("Prefab/Buttle", (GameObject obj) =>
|
|
{
|
|
obj.transform.parent = transform;
|
|
obj.transform.localPosition = UnityEngine.Vector3.zero;
|
|
BattleManager.ins.AxisLookAt(obj.transform,
|
|
BattleManager.ins.Mousters[Random.Range(0, BattleManager.ins.MousterCount)].transform.position);
|
|
obj.GetComponent<Bullet>().SetAttack(data,(int)(data.Attack*(data.Ratio+((float)BattleManager.ins.Buff(data.itemData.Includearms).attack/10000)))
|
|
,data.data.Skillmove,BattleManager.ins.Buff(data.itemData.Includearms).piercing+1,BattleManager.ins.Buff(data.itemData.Includearms).criticalStrike);
|
|
BattleManager.ins.AddBullets(obj.GetComponent<Bullet>());
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
public enum playerAniType
|
|
{
|
|
play,
|
|
wait
|
|
} |