forked from cgvr/DeltaVR
refactored model generation code out of test box into separate pipeline manager
This commit is contained in:
@@ -118,17 +118,18 @@ public class ArcheryRange : NetworkBehaviour
|
||||
|
||||
var randomPos = targetStartPosition.position + new Vector3(
|
||||
Random.Range(minRandomOffset.x, maxRandomOffset.x),
|
||||
(float)Math.Round(Random.Range(minRandomOffset.y, maxRandomOffset.y)),
|
||||
Random.Range(minRandomOffset.z, maxRandomOffset.z));
|
||||
(float) Math.Round(Random.Range(minRandomOffset.y, maxRandomOffset.y)),
|
||||
Random.Range(minRandomOffset.z, maxRandomOffset.z)
|
||||
);
|
||||
|
||||
var target = SpawnTarget(randomPos);
|
||||
|
||||
_targets.Add(target);
|
||||
}
|
||||
|
||||
private ArcheryTarget SpawnTarget(Vector3 randomPos)
|
||||
{
|
||||
var prefab = Instantiate(targetPrefab, randomPos, Quaternion.identity, null);
|
||||
// TODO: replace target prefab's child with the generated model
|
||||
ArcheryTarget target = prefab.GetComponent<ArcheryTarget>();
|
||||
target.endPosition = targetEndPosition.position;
|
||||
target.addScore = AddScore;
|
||||
@@ -148,7 +149,7 @@ public class ArcheryRange : NetworkBehaviour
|
||||
_targets = new List<ArcheryTarget>();
|
||||
if (_maxScore < _score) _maxScore = _score;
|
||||
|
||||
if(_presentPlayers.Count != 0) // If there are players in the area.
|
||||
if (_presentPlayers.Count != 0) // If there are players in the area.
|
||||
{
|
||||
// Gives the score to the player longest-lasting in the area. It would be better to give it to the player that fired the starting arrow, but I'm not spending 10 hours on this.
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using _PROJECT.Scripts.Bow;
|
||||
using _PROJECT.Scripts.Bow.Extra;
|
||||
using FishNet.Object;
|
||||
using FishNet.Object.Synchronizing;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class ArcheryTarget : NetworkBehaviour, IArrowHittable
|
||||
{
|
||||
@@ -13,12 +10,10 @@ public class ArcheryTarget : NetworkBehaviour, IArrowHittable
|
||||
public Vector3 endPosition;
|
||||
public float forwardSpeed = 2f;
|
||||
public Action<float> addScore;
|
||||
|
||||
private bool _flipDirection;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_flipDirection = Random.value > 0.5f;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -28,11 +23,12 @@ public class ArcheryTarget : NetworkBehaviour, IArrowHittable
|
||||
float step = forwardSpeed * Time.deltaTime;
|
||||
var position = transform.position;
|
||||
|
||||
if (Math.Abs(position.x - endPosition.x) < 0.1) Destroy(gameObject);
|
||||
if (Math.Abs(position.x - endPosition.x) < 0.1)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
||||
transform.position = Vector3.MoveTowards(position,
|
||||
new Vector3(endPosition.x, position.y, position.z), step);
|
||||
transform.position = Vector3.MoveTowards(position, new Vector3(endPosition.x, position.y, position.z), step);
|
||||
}
|
||||
|
||||
public void Hit(Arrow arrow)
|
||||
|
||||
Reference in New Issue
Block a user