72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "BulletPet4_m" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class BulletPet4_m : MonoBehaviour
|
|
{
|
|
private float _bulletSpeed = -1f;
|
|
private float _sideSpeed;
|
|
private Vector3 _originScale;
|
|
private Vector3 _direction;
|
|
private Vector3 _sideDirection;
|
|
|
|
private int _side;
|
|
private BulletPet4 _bullet;
|
|
|
|
private void Awake()
|
|
{
|
|
_originScale = transform.localScale;
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
transform.localScale = Vector3.zero;
|
|
|
|
_bulletSpeed = -2f;
|
|
_sideSpeed = 0.2f + Random.Range(-0.1f, 0.1f);
|
|
_direction = transform.forward;
|
|
_sideDirection = transform.right * _side;
|
|
}
|
|
|
|
public void Init(BulletPet4 bullet, int side)
|
|
{
|
|
_bullet = bullet;
|
|
_side = side;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
var pos = transform.position;
|
|
|
|
_bulletSpeed += Time.deltaTime * 6f;
|
|
_sideSpeed = Mathf.Lerp(_sideSpeed, 0f, Time.deltaTime * 2f);
|
|
|
|
transform.localScale = Vector3.Lerp(transform.localScale, _originScale, Time.deltaTime * 4f);
|
|
pos += _sideDirection * Time.deltaTime * _sideSpeed;
|
|
pos += _direction * Time.deltaTime * _bulletSpeed;
|
|
Vector3 position = transform.position;
|
|
if (position.y < 0f)
|
|
{
|
|
_bullet.SplashOn(pos);
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
transform.position = pos;
|
|
}
|
|
}
|
|
}
|