Browse Source

lighthouse searchlight spline

master
Sagittaeri 7 years ago
parent
commit
087dc1181b
8 changed files with 94 additions and 0 deletions
  1. BIN
      IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat
  2. +56
    -0
      IronToad_UnityProject/Assets/Lighthouse.cs
  3. +12
    -0
      IronToad_UnityProject/Assets/Lighthouse.cs.meta
  4. BIN
      IronToad_UnityProject/Assets/Materials/No Name.mat
  5. +9
    -0
      IronToad_UnityProject/Assets/Models.meta
  6. +9
    -0
      IronToad_UnityProject/Assets/Sound.meta
  7. BIN
      IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity
  8. +8
    -0
      IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity.meta

BIN
IronToad_UnityProject/Assets/BansheeGz/BGCurve/Examples/Materials/BGTestLineRendererCheckerBox.mat View File


+ 56
- 0
IronToad_UnityProject/Assets/Lighthouse.cs View File

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BansheeGz.BGSpline.Components;
using BansheeGz.BGSpline.Curve;
public class Lighthouse : MonoBehaviour
{
public BGCurve splineCurve;
public List<float> splineDistantPoints = new List<float>();
public float speed = 200f;
public float timePadding = 0.5f;
public float timeBetweenPoints = 3f;
private BGCcCursor splineCursor;
private int targetPoint = 0;
private bool reverseDirection = false;
void Start()
{
splineCursor = splineCurve.GetComponent<BGCcCursor>();
moveToNextPoint();
}
public void moveToNextPoint()
{
LeanTween.delayedCall(gameObject, timeBetweenPoints, ()=>{
if (reverseDirection)
targetPoint--;
else
targetPoint++;
if (targetPoint >= splineDistantPoints.Count)
{
if (splineCurve.Closed)
{
targetPoint = 1;
splineCursor.Distance = 0f;
}
else
{
targetPoint = splineDistantPoints.Count - 2;
reverseDirection = !reverseDirection;
}
}
float start = splineCursor.Distance;
float end = splineDistantPoints[targetPoint];
float distance = Mathf.Abs(end - start);
LeanTween.value(gameObject, start, end, distance / speed + timePadding).setOnUpdate((float val)=>{
splineCursor.Distance = val;
}).setEaseInOutQuad().setOnComplete(moveToNextPoint);
});
}
}

+ 12
- 0
IronToad_UnityProject/Assets/Lighthouse.cs.meta View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e529d146693e04d5983a4fbbb25de5ab
timeCreated: 1484975905
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/Materials/No Name.mat View File


+ 9
- 0
IronToad_UnityProject/Assets/Models.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: dc40a5a63cf904fd5b676a47e405c742
folderAsset: yes
timeCreated: 1484970039
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
IronToad_UnityProject/Assets/Sound.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0fbabcae9313543ffbf1429aeac3664d
folderAsset: yes
timeCreated: 1484963877
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity View File


+ 8
- 0
IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4c20f98c0786f41f7b817e6e904f0926
timeCreated: 1484970007
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save