Commit 23aeaecd authored by Corantin Hoffert's avatar Corantin Hoffert 💥
Browse files

More fixes

parent 90a46898
......@@ -16,20 +16,20 @@ namespace Effects
public class SlipTrailManager : MonoBehaviour
{
internal VehicleBase _car;
internal WheelCollider _wheel; // Wheels physic component
internal TrailRenderer _slipTrail; // The trail emitted when handbracking
public GameObject sand; // Sand particles
public GameObject sand; // Sand particles
private List<GameObject> _sandPoolObject;// Sand particles
private List<ParticleSystem> _sandPool; // Sand particles
private List<ParticleSystem> _sandPool; // Sand particles
private float _sandLast = 0;
private float _sandSpace = 0.01f;
private int _sandIterator = 0;
private bool _isSlipping = false; // If the car is handbraking
private WheelHit hit; // Collider hit informations
private WheelHit hit; // Collider hit informations
public bool IsSlipping // _isSlipping property
{
get
......@@ -51,7 +51,8 @@ namespace Effects
_wheel = GetComponentInParent<WheelCollider>();
_sandPoolObject = new List<GameObject>();
_sandPool = new List<ParticleSystem>();
for (int i = 0; i < 50; i++) {
for (int i = 0; i < 50; i++)
{
GameObject obj = (GameObject)Instantiate(sand, parent);
_sandPoolObject.Add(obj);
_sandPool.Add(obj.GetComponent<ParticleSystem>());
......@@ -61,14 +62,15 @@ namespace Effects
// Update is called once per frame
void Update()
{
if (_isSlipping && _wheel.GetGroundHit(out hit))
{
if (hit.collider.CompareTag("TerrainBeton")) {
_slipTrail.emitting = true;
}
else if (hit.collider.CompareTag("TerrainSand")
&& _sandSpace < Time.time - _sandLast
&& _car.GetSpeed() > 10)
if (_isSlipping && _wheel.GetGroundHit(out hit))
{
if (hit.collider.CompareTag("TerrainBeton"))
{
_slipTrail.emitting = true;
}
else if (hit.collider.CompareTag("TerrainSand")
&& _sandSpace < Time.time - _sandLast
&& _car._currentSpeed > 10)
{
_slipTrail.emitting = false;
_sandPool[_sandIterator].Stop();
......@@ -76,18 +78,18 @@ namespace Effects
_sandPoolObject[_sandIterator].transform.position = transform.position;
_sandPoolObject[_sandIterator].transform.rotation = transform.rotation;
_sandPool[_sandIterator].Play();
_sandIterator = (_sandIterator+1)%_sandPool.Count;
_sandIterator = (_sandIterator + 1) % _sandPool.Count;
_sandLast = Time.time;
}
else
{
_slipTrail.emitting = false;
}
}
}
else // Tout desactiver
{
{
_slipTrail.emitting = false;
}
}
}
}
}
......@@ -103,9 +103,10 @@ public class SceneLoader : Singleton<SceneLoader>
if (mode != LoadSceneMode.Additive) GameManager.Instance.PushCurrentSceneToHistory();
//GameManager.Instance.GetUIManager().PutBack();
var curScreenElem = GameManager.Instance.GetScreenManager().CurrentScreenElement();
if (curScreenElem != null && curScreenElem.canBeClosed)
GameManager.Instance.GetScreenManager().CloseCurrentScreen();
var sm = GameManager.Instance.GetScreenManager();
var curScreenElem = sm.CurrentScreenElement();
if (curScreenElem != null && (curScreenElem.canBeClosed || curScreenElem.name != sm.defaultMenu))
sm.CloseCurrentScreen();
TransitionEffect effect = transitionName == null ? null : effects.Find(e => e.transitionName.ToLower() == transitionName.ToLower());
Animator transition = null;
......
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
......@@ -69,13 +70,20 @@ public class UILobbyChatChannels : MonoBehaviour
if (openedChanels.Contains(friendId)) return;
if (!FriendsManager.IsFriendWith(friendId)) return;
openedChanels.Add(friendId);
var item = InternalCreateChannelItem(friendId);
UILobbyChatChannelItem item;
var index = _channelList.Count;
item.Button.onClick.AddListener(() => OnChannelSelect(item, index, friendId));
try
{
item = InternalCreateChannelItem(friendId);
item.Button.onClick.AddListener(() => OnChannelSelect(item, index, friendId));
}
catch (Exception _)
{
return;
}
openedChanels.Add(friendId);
_channelList.Add(item);
......
......@@ -266,7 +266,14 @@ public class FriendsManager : INetworkListener
var _friendList = message.list;
OnFriendList?.Invoke(_friendList);
friendList = message.list;
var localFriendList = friendList.ToList();
foreach (var friend in message.list)
{
if (!localFriendList.Any(x => x.id == friend.id))
localFriendList.Add(friend);
}
friendList = localFriendList.ToArray();
return true;
}
......@@ -277,8 +284,16 @@ public class FriendsManager : INetworkListener
if (isReceived)
{
friendRequestReceivedList = message.list;
OnFriendRequestReceivedList?.Invoke(message.list);
var localFriendRequestReceivedList = friendRequestReceivedList.ToList();
foreach (var friend in message.list)
{
if (!localFriendRequestReceivedList.Any(x => x.id == friend.id))
localFriendRequestReceivedList.Add(friend);
}
friendRequestReceivedList = localFriendRequestReceivedList.ToArray();
}
else
{
......
......@@ -78,6 +78,8 @@ public class PlayerController : VehicleBase, IInputListener
horn = true;
}
}
/**
* Method handling inputs of the player and transfering them to
* the vehicle
......@@ -88,7 +90,7 @@ public class PlayerController : VehicleBase, IInputListener
float dotProduct = Vector3.Dot(transform.forward, _rigidbody.velocity);
if (dotProduct > 0 && _currentDir.y < 0 || dotProduct < 0 && _currentDir.y > 0)
if (dotProduct > 0.1f && _currentDir.y < -0.05f || dotProduct < -0.1f && _currentDir.y > 0.05f)
{
SetBraking(true);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment