248 lines
6.7 KiB
C#
248 lines
6.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "Cha_Control_ride_cha" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
public class Cha_Control_ride_cha : MonoBehaviour
|
|
{
|
|
public Transform horseSpine;
|
|
|
|
public Transform horse;
|
|
|
|
public Transform dummy_weapon;
|
|
|
|
public Transform ef_souleat;
|
|
|
|
public Transform ef_damage;
|
|
|
|
public Transform ef_twirl;
|
|
|
|
public Transform spear;
|
|
|
|
public Transform coin;
|
|
|
|
private Transform ef_swing;
|
|
|
|
private bool _isfinish;
|
|
|
|
private Ef_swing1_ride script_swing;
|
|
|
|
private Cha_Control_ride_horse script_horse;
|
|
|
|
private Ef_twirl script_twirl;
|
|
|
|
private Cam_Move_ride script_cam;
|
|
|
|
private float _attackDelay;
|
|
|
|
private float _particleDelay;
|
|
|
|
private float _falldownDelay;
|
|
|
|
public int amount_soulstone;
|
|
|
|
public int _coinCount;
|
|
|
|
public int _monsterCount;
|
|
|
|
public int _behitCount;
|
|
|
|
private Animator _animator;
|
|
private Ef_Coin[] _scriptCoins = new Ef_Coin[8];
|
|
private int _coinFxIndex = 0;
|
|
private Ef_Coin script_coin
|
|
{
|
|
get
|
|
{
|
|
_coinFxIndex++;
|
|
if (_coinFxIndex >= _scriptCoins.Length)
|
|
_coinFxIndex = 0;
|
|
return _scriptCoins[_coinFxIndex];
|
|
}
|
|
}
|
|
|
|
#region Method
|
|
|
|
void PlayAnim(string anim)
|
|
{
|
|
_animator.Play(anim);
|
|
}
|
|
|
|
void PlayAnim(string anim, int layer)
|
|
{
|
|
_animator.Play(anim, layer);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
private void Awake()
|
|
{
|
|
//myanimation = this.GetComponent<Animation>();
|
|
_animator = GetComponent<Animator>();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
script_cam = Camera.main.GetComponent<Cam_Move_ride>();
|
|
ef_swing = transform.Find("ef_swing1");
|
|
_scriptCoins[0] = coin.GetComponent<Ef_Coin>();
|
|
for (int i = 1; i < _scriptCoins.Length; i++)
|
|
{
|
|
_scriptCoins[i] = Object.Instantiate(_scriptCoins[0]);
|
|
}
|
|
|
|
script_swing = ef_swing.GetComponent<Ef_swing1_ride>();
|
|
script_horse = horse.GetComponent<Cha_Control_ride_horse>();
|
|
script_twirl = ef_twirl.GetComponent<Ef_twirl>();
|
|
|
|
PlayAnim("ride1");
|
|
}
|
|
|
|
//float _progress;
|
|
private void Update()
|
|
{
|
|
if (!_isfinish)
|
|
{
|
|
//_progress += Time.deltaTime * 0.033f;
|
|
//UI_InRide.Instance.GainComplete(_progress);
|
|
//gauge_navi.position += Vector3.right * Time.deltaTime * 0.033f;
|
|
}
|
|
|
|
transform.position = horseSpine.position + Vector3.up * -0.085f;
|
|
transform.rotation = horse.rotation;
|
|
if (_falldownDelay > 0f)
|
|
{
|
|
_falldownDelay -= Time.deltaTime;
|
|
}
|
|
else if (_attackDelay > 0f)
|
|
{
|
|
_attackDelay -= Time.deltaTime;
|
|
}
|
|
|
|
if (_particleDelay > 0f)
|
|
{
|
|
_particleDelay -= Time.deltaTime;
|
|
if (_particleDelay < 0f)
|
|
{
|
|
//ef_souleat.particleEmitter().emit = false;
|
|
//ef_damage.particleEmitter().emit = false;
|
|
_particleDelay = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void Damaged()
|
|
{
|
|
if (!_isfinish)
|
|
{
|
|
GetSoulStone(-3);
|
|
}
|
|
}
|
|
|
|
public void Attack(bool isRight)
|
|
{
|
|
if (_attackDelay > 0f)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Vector3 position = this.transform.position;
|
|
if (position.y < 0.01f)
|
|
{
|
|
if (isRight)
|
|
{
|
|
PlayAnim("attack_ride1", 1);
|
|
ef_swing.localRotation = Quaternion.Euler(20f, 60f, 170f);
|
|
script_swing.SwingOn(0.16f, 2, 2, 18, 1, 0);
|
|
}
|
|
else
|
|
{
|
|
PlayAnim("attack_ride2", 1);
|
|
ef_swing.localRotation = Quaternion.Euler(20f, -60f, 10f);
|
|
script_swing.SwingOn(0.16f, 2, 2, 18, 1, 0);
|
|
}
|
|
_attackDelay = 1f;
|
|
}
|
|
}
|
|
|
|
public void GetSoulStone(int a)
|
|
{
|
|
amount_soulstone = Mathf.Max(0, amount_soulstone + a);
|
|
if (a == 1)
|
|
{
|
|
ef_souleat.gameObject.SetActive(false);
|
|
ef_souleat.gameObject.SetActive(true);
|
|
//ef_souleat.particleEmitter().emit = true;
|
|
script_twirl.TwirlOn(4, 4, 20, false);
|
|
this.GetComponent<AudioSource>().Play();
|
|
script_coin.GetCoin(transform.position);
|
|
_coinCount++;
|
|
|
|
SoundProxy.PlayFxAsync("bt_cha_get_item2");
|
|
UI_InRide.Instance.GainProp(3001, amount_soulstone);
|
|
}
|
|
else if (a < 0)
|
|
{
|
|
//screen_effect.gameObject.SetActive(true);
|
|
script_cam.Hitcam();
|
|
//ef_damage.particleEmitter().emit = true;
|
|
_behitCount++;
|
|
UI_InRide.Instance.GainAttacked(_behitCount, a);
|
|
//_coinCount--;
|
|
}
|
|
else
|
|
{
|
|
_monsterCount++;
|
|
//_coinCount += 2;
|
|
UI_InRide.Instance.GainKiller(0, _monsterCount, a);
|
|
}
|
|
|
|
//stage_num.text = amount_soulstone.ToString();
|
|
_particleDelay = 0.5f;
|
|
}
|
|
|
|
public void FallDown()
|
|
{
|
|
if (!_isfinish && _falldownDelay <= 0f)
|
|
{
|
|
script_horse.FallDown();
|
|
GetSoulStone(-3);
|
|
script_cam.Hitcam2();
|
|
_falldownDelay = 1f;
|
|
}
|
|
}
|
|
|
|
public void Finish()
|
|
{
|
|
_isfinish = true;
|
|
}
|
|
|
|
public void RisePocket()
|
|
{
|
|
GameObject.FindWithTag("dummy").GetComponent<Obj_Pocket>().PickPocket();
|
|
}
|
|
|
|
public void CrynStop()
|
|
{
|
|
script_twirl.TwirlOff();
|
|
Object.Destroy(spear.gameObject);
|
|
PlayAnim("ride2");
|
|
}
|
|
|
|
}
|
|
}
|