mirror of
https://github.com/mixandjam/Splatoon-Ink.git
synced 2026-12-05 07:02:17 -06:00
final polish
This commit is contained in:
69
Assets/Scripts/ShootingSystem.cs
Normal file
69
Assets/Scripts/ShootingSystem.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Cinemachine;
|
||||
|
||||
public class ShootingSystem : MonoBehaviour
|
||||
{
|
||||
|
||||
MovementInput input;
|
||||
|
||||
[SerializeField] ParticleSystem inkParticle;
|
||||
[SerializeField] Transform parentController;
|
||||
[SerializeField] Transform splatGunNozzle;
|
||||
[SerializeField] CinemachineFreeLook freeLookCamera;
|
||||
CinemachineImpulseSource impulseSource;
|
||||
|
||||
void Start()
|
||||
{
|
||||
input = GetComponent<MovementInput>();
|
||||
impulseSource = freeLookCamera.GetComponent<CinemachineImpulseSource>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Vector3 angle = parentController.localEulerAngles;
|
||||
input.blockRotationPlayer = Input.GetMouseButton(0);
|
||||
bool pressing = Input.GetMouseButton(0);
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
VisualPolish();
|
||||
GetComponent<MovementInput>().RotateToCamera(transform);
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
inkParticle.Play();
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
inkParticle.Stop();
|
||||
|
||||
parentController.localEulerAngles
|
||||
= new Vector3(Mathf.LerpAngle(parentController.localEulerAngles.x, pressing ? RemapCamera(freeLookCamera.m_YAxis.Value, 0, 1, -25, 25) : 0,.3f), angle.y, angle.z);
|
||||
}
|
||||
|
||||
void VisualPolish()
|
||||
{
|
||||
if (!DOTween.IsTweening(parentController))
|
||||
{
|
||||
parentController.DOComplete();
|
||||
Vector3 forward = -parentController.forward;
|
||||
Vector3 localPos = parentController.localPosition;
|
||||
parentController.DOLocalMove(localPos - new Vector3(0, 0, .2f), .03f)
|
||||
.OnComplete(() => parentController.DOLocalMove(localPos, .1f).SetEase(Ease.OutSine));
|
||||
|
||||
impulseSource.GenerateImpulse();
|
||||
}
|
||||
|
||||
if (!DOTween.IsTweening(splatGunNozzle))
|
||||
{
|
||||
splatGunNozzle.DOComplete();
|
||||
splatGunNozzle.DOPunchScale(new Vector3(0, 1, 1) / 1.5f, .15f, 10, 1);
|
||||
}
|
||||
}
|
||||
|
||||
float RemapCamera(float value, float from1, float to1, float from2, float to2)
|
||||
{
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ShootingSystem.cs.meta
Normal file
11
Assets/Scripts/ShootingSystem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfb06fe47b1efa9418445b7194ad6456
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/SplatGun.cs
Normal file
8
Assets/Scripts/SplatGun.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[SelectionBase]
|
||||
public class SplatGun : MonoBehaviour
|
||||
{
|
||||
}
|
||||
11
Assets/Scripts/SplatGun.cs.meta
Normal file
11
Assets/Scripts/SplatGun.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f8cadbd2b3aeb1409a01ef193da371a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user