36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class castShadowLine : MonoBehaviour
|
||
|
{
|
||
|
public bool refreshEverySecond = true;
|
||
|
public Environment environment;
|
||
|
public GameObject startPos;
|
||
|
public GameObject endPos;
|
||
|
public sbyte shadowStrength = 50;
|
||
|
// Start is called before the first frame update
|
||
|
Vector3 oldPositionS;
|
||
|
Vector3 oldPositionE;
|
||
|
void Start()
|
||
|
{
|
||
|
// environment.addShadowLine(startPos.GetComponent<Transform>().position, endPos.GetComponent<Transform>().position, shadowStrength);
|
||
|
oldPositionS = startPos.GetComponent<Transform>().position;
|
||
|
oldPositionE = endPos.GetComponent<Transform>().position;
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
int frame = 0;
|
||
|
void Update()
|
||
|
{
|
||
|
if(refreshEverySecond&&frame%60==59)
|
||
|
{
|
||
|
environment.addShadowLine(oldPositionS, oldPositionE, (sbyte)(-1 * shadowStrength));
|
||
|
environment.addShadowLine(startPos.GetComponent<Transform>().position, endPos.GetComponent<Transform>().position, shadowStrength);
|
||
|
oldPositionS = startPos.GetComponent<Transform>().position;
|
||
|
oldPositionE = endPos.GetComponent<Transform>().position;
|
||
|
}
|
||
|
frame++;
|
||
|
}
|
||
|
}
|