Epic mk1
This commit is contained in:
@@ -31,6 +31,7 @@ public class EffectPool : MonoBehaviour
|
||||
|
||||
//Not in pool
|
||||
GameObject newItem = Instantiate(prefab, EffectsParent);
|
||||
newItem.transform.position = position;
|
||||
if(!active.ContainsKey(prefab.name)){
|
||||
active.Add(prefab.name, new List<GameObject>());
|
||||
}
|
||||
|
||||
60
Assets/Game/Scripts/Minigame/DebrisEffect.cs
Normal file
60
Assets/Game/Scripts/Minigame/DebrisEffect.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DebrisEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField]private float MoveSpeed= 1;
|
||||
[SerializeField]private float DrowningSpeed= 1;
|
||||
|
||||
[SerializeField]private float AliveTime = 30;
|
||||
[SerializeField]private float RotationSpeed = 1;
|
||||
float aliveTimer = 0;
|
||||
private Dictionary<Transform, Vector3> debris;
|
||||
|
||||
void Start(){
|
||||
Play();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if(debris == null){
|
||||
return;
|
||||
}
|
||||
if(aliveTimer < AliveTime){
|
||||
aliveTimer+=Time.deltaTime;
|
||||
MoveDebris();
|
||||
}else{
|
||||
//Time to go!
|
||||
gameObject.SetActive(false);
|
||||
aliveTimer=0;
|
||||
}
|
||||
}
|
||||
|
||||
void MoveDebris(){
|
||||
foreach(KeyValuePair<Transform, Vector3> debri in debris){
|
||||
float m_moveSpeed= MoveSpeed;
|
||||
if(debri.Value.z > 0){
|
||||
m_moveSpeed= MoveSpeed*2;
|
||||
}
|
||||
debri.Key.position+= debri.Value * m_moveSpeed;
|
||||
if(aliveTimer > AliveTime/3f){
|
||||
debri.Key.position -= new Vector3(0,0, DrowningSpeed);
|
||||
}
|
||||
debri.Key.Rotate(new Vector3(0,0,0.1f) *debri.Value.magnitude * RotationSpeed);
|
||||
}
|
||||
}
|
||||
public void Play(Vector3 position){
|
||||
transform.position = position;
|
||||
Play();
|
||||
}
|
||||
public void Play(){
|
||||
aliveTimer=0;
|
||||
|
||||
debris = new Dictionary<Transform, Vector3>();
|
||||
for(int i=0; i < transform.childCount; i++){
|
||||
Vector2 movement = new Vector3(Random.Range(-1f,1f), Random.Range(-1f,1f), Random.Range(-1f,0f));
|
||||
debris.Add(transform.GetChild(i), movement);
|
||||
transform.GetChild(i).position = transform.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/Minigame/DebrisEffect.cs.meta
Normal file
11
Assets/Game/Scripts/Minigame/DebrisEffect.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09fa0cd5cdbff7f478b056b48a6801e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -71,6 +71,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
[SerializeField]private int ErrorStateCount;
|
||||
[SerializeField]private int RubberBandsCount;
|
||||
public GameObject DeathEffect;
|
||||
public GameObject debrisEffect;
|
||||
public GameObject PickupEffect;
|
||||
|
||||
public float distanceFromCenter = 0;
|
||||
@@ -566,8 +567,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
[ClientRpc]
|
||||
void RpcShowDeathEffect(Vector2 position){
|
||||
EffectPool.Spawn(DeathEffect, position);
|
||||
|
||||
EffectPool.Spawn(DeathEffect, position);
|
||||
EffectPool.Spawn(debrisEffect, position).GetComponent<DebrisEffect>().Play();
|
||||
}
|
||||
|
||||
void OnKill()
|
||||
|
||||
Reference in New Issue
Block a user