Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3b069c0
Fix tower capture not being completed for clients
tcgj Apr 16, 2020
573b33d
Add host button timeout
tcgj Apr 16, 2020
5b7e6fc
Fix monsters not synchronising movement and spawning multiple damage
tcgj Apr 16, 2020
25223df
Fixed plant death anim
heze8 Apr 17, 2020
697352f
Make monster retreat when player is too far away
heze8 Apr 17, 2020
a8df53e
Update semicolon
heze8 Apr 17, 2020
a175c6b
Kill all monster instances if it dies in any client
tcgj Apr 17, 2020
9f9b303
Change trigger target to nearest player
heze8 Apr 17, 2020
aa2ee67
Fix float
heze8 Apr 17, 2020
7372227
Fix skill handler picking up network player skills
tcgj Apr 17, 2020
211b6f0
Fix not moving
heze8 Apr 17, 2020
20722fb
Fix ui skill handler not removing correct skill
tcgj Apr 17, 2020
81808be
Fix monster attack animation not triggering
tcgj Apr 17, 2020
3435db9
increase capsule collider on monster
fatclarence Apr 17, 2020
79d5f42
increase capsule collider on all monsters again
fatclarence Apr 17, 2020
88fde3c
Fix network player attempting to access player movement
tcgj Apr 17, 2020
414e2de
Made the player detection update onTriggerstay as well
heze8 Apr 17, 2020
cb6fda9
Check for reference of nearest player in couroutine update
heze8 Apr 17, 2020
2a8a0f6
increase height of mushroom capsule collider
fatclarence Apr 17, 2020
27c0dca
Add last monster to scene
heze8 Apr 17, 2020
d865164
edit capsule colliders of in-scene monsters
fatclarence Apr 17, 2020
010e476
Minor game fixes
tcgj Apr 17, 2020
13c3b6f
Add character controller null check
tcgj Apr 17, 2020
ab56036
fix mushroom colliders to improve damage detection
fatclarence Apr 17, 2020
88e4017
fix shuriken colliding with player and move mushroom monster
fatclarence Apr 17, 2020
3cbd260
Set player without display name as Guest
tcgj Apr 17, 2020
04c8c3f
Check for null
heze8 Apr 17, 2020
56f9a85
Make tower fill gauge relative to fraction of players in zone
tcgj Apr 17, 2020
390f0a4
Remove buggy hairstyle from customisation
tcgj Apr 17, 2020
9e9f9fb
Playtest Fixes e6.2.1
Eclmist Apr 19, 2020
5184660
Removed junk from master
Eclmist Apr 19, 2020
b3e2ffe
Change tower capture message
tcgj Apr 19, 2020
43e4f6a
Fix terrain hole texture sampling
Eclmist Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace BeardedManStudios.Forge.Networking.Generated
{
[GeneratedRPC("{\"types\":[]")]
[GeneratedRPCVariableNames("{\"types\":[]")]
[GeneratedRPC("{\"types\":[[\"string\"]]")]
[GeneratedRPCVariableNames("{\"types\":[[\"attackName\"]]")]
public abstract partial class MonsterObjectBehavior : NetworkBehavior
{
public const byte RPC_TRIGGER_ATTACK_ANIM = 0 + 5;

public MonsterObjectNetworkObject networkObject = null;

Expand All @@ -21,6 +22,7 @@ public override void Initialize(NetworkObject obj)
networkObject.AttachedBehavior = this;

base.SetupHelperRpcs(networkObject);
networkObject.RegisterRpc("TriggerAttackAnim", TriggerAttackAnim, typeof(string));

networkObject.onDestroy += DestroyGameObject;

Expand Down Expand Up @@ -94,6 +96,11 @@ protected override void InitializedTransform()
networkObject.SnapInterpolations();
}

/// <summary>
/// Arguments:
/// string attackName
/// </summary>
public abstract void TriggerAttackAnim(RpcArgs args);

// DO NOT TOUCH, THIS GETS GENERATED PLEASE EXTEND THIS CLASS IF YOU WISH TO HAVE CUSTOM CODE ADDITIONS
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace BeardedManStudios.Forge.Networking.Generated
{
[GeneratedInterpol("{\"inter\":[0.15]")]
[GeneratedInterpol("{\"inter\":[0]")]
public partial class TowerNetworkObject : NetworkObject
{
public const int IDENTITY = 16;
Expand All @@ -18,7 +18,7 @@ public partial class TowerNetworkObject : NetworkObject
[ForgeGeneratedField]
private float _captureGauge;
public event FieldEvent<float> captureGaugeChanged;
public InterpolateFloat captureGaugeInterpolation = new InterpolateFloat() { LerpT = 0.15f, Enabled = true };
public InterpolateFloat captureGaugeInterpolation = new InterpolateFloat() { LerpT = 0f, Enabled = false };
public float captureGauge
{
get { return _captureGauge; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ public void ConnectToMatchmaking()

public void Host()
{
if (waitForTimeout)
{
if (Time.time < nextAvailableConnect)
return;
}

waitForTimeout = true;
nextAvailableConnect = Time.time + timeoutDuration + 2.0f;

if (useTCP)
{
server = new TCPServer(maxPlayers);
Expand Down
25 changes: 22 additions & 3 deletions Assets/Scripts/AI/AiActors/AiMonster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class AiMonster : AiActor, Attacker, ICanInteract
private HealthHandler m_HealthHandler;

private bool m_CanAttack = true;
private string m_AttackThisFrame = "";
private bool m_IsStun = false;
private SkinnedMeshRenderer[] m_MonsterSkin;
private ParticleSystem[] m_DeathParticles;
Expand Down Expand Up @@ -55,6 +56,11 @@ private void OnTriggerExit(Collider c)
InteractWith(c.GetComponent<IInteractable>(), InteractionType.INTERACTION_TRIGGER_EXIT);
}

private void LateUpdate()
{
m_AttackThisFrame = "";
}

private void InteractWith(IInteractable interactable, InteractionType interactionType)
{
if (interactable != null) // null check done here instead.
Expand All @@ -71,8 +77,7 @@ public void Attack(float attackInterval)
{
if (m_CanAttack)
{
float attack = m_MonsterAnimation.RandomizeAttack()/2;

float attack = m_MonsterAnimation.RandomizeAttack(out m_AttackThisFrame)/2;
//logic for damaging the player here

StartCoroutine(DealDamage(attack));
Expand All @@ -85,8 +90,22 @@ IEnumerator DealDamage(float delay)
yield return new WaitForSeconds(delay);
DamageEntities();
}
}


public string GetAttack()
{
return m_AttackThisFrame;
}

public AiAnimation GetMonsterAnimation()
{
return m_MonsterAnimation;
}

public void DisableAttack()
{
StopCoroutine("SetCanAttack");
m_CanAttack = false;
}

private void DamageEntities()
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/AI/AiAnimation/AiAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ private void Awake()

public abstract void GoInactive();
public abstract void Move(bool toMove);
public abstract float RandomizeAttack();
public abstract float RandomizeAttack(out string attack);
public abstract void SetAttackTrigger(string name);

public abstract float TakenDamage();
public abstract float Death();
Expand Down
8 changes: 7 additions & 1 deletion Assets/Scripts/AI/AiAnimation/AiMushroomAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ public override void Move(bool toMove)
m_Animator.SetFloat("locomotion", 0);
}

public override float RandomizeAttack()
public override float RandomizeAttack(out string attackName)
{
AnimMovesParam [] temp = {AnimMovesParam.attack1, AnimMovesParam.attack2, AnimMovesParam.attack3};
AnimMovesParam attack = temp[Random.Range(0, temp.Length)];
attackName = attack.ToString();
m_Animator.SetTrigger(attack.ToString());
return GetTime(attack);
}

public override void SetAttackTrigger(string name)
{
m_Animator.SetTrigger(name);
}
}
8 changes: 7 additions & 1 deletion Assets/Scripts/AI/AiAnimation/AiPlantAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ public override void Move(bool toMove)
m_Animator.SetFloat("locomotion", 0);
}

public override float RandomizeAttack()
public override float RandomizeAttack(out string attackName)
{
AnimMovesParam [] temp = {AnimMovesParam.attack1, AnimMovesParam.attack2};
AnimMovesParam attack = temp[Random.Range(0, temp.Length)];
attackName = attack.ToString();
m_Animator.SetTrigger(attack.ToString());
return GetTime(attack);
}

public override void SetAttackTrigger(string name)
{
m_Animator.SetTrigger(name);
}
}
10 changes: 8 additions & 2 deletions Assets/Scripts/AI/AiAnimation/AiRockAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,20 @@ public override void Move(bool toMove)
m_Animator.SetFloat("locomotion", 0);
}

public override float RandomizeAttack()
public override float RandomizeAttack(out string attackName)
{
AnimMovesParam[] temp = {AnimMovesParam.attack1A, AnimMovesParam.attack1B, AnimMovesParam.attack2};
int range = Random.Range(0, temp.Length);

AnimMovesParam attack = temp[range];


attackName = attack.ToString();
m_Animator.SetTrigger(attack.ToString());
return GetTime(attack);
}

public override void SetAttackTrigger(string name)
{
m_Animator.SetTrigger(name);
}
}
8 changes: 7 additions & 1 deletion Assets/Scripts/AI/AiAnimation/AiWormAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ public override void Move(bool toMove)
m_Animator.SetTrigger(AnimMovesParam.appear.ToString());
}

public override float RandomizeAttack()
public override float RandomizeAttack(out string attackName)
{
AnimMovesParam[] temp = {AnimMovesParam.attack1, AnimMovesParam.attack2};
AnimMovesParam attack = temp[Random.Range(0, temp.Length)];
attackName = attack.ToString();
StartCoroutine(Attack(ReactToPlayer(), attack));

return GetTime(attack);
Expand All @@ -84,4 +85,9 @@ IEnumerator Attack(float delay, AnimMovesParam attack)

m_Animator.SetTrigger(attack.ToString());
}

public override void SetAttackTrigger(string name)
{
StartCoroutine(Attack(ReactToPlayer(), (AnimMovesParam)System.Enum.Parse(typeof(AnimMovesParam), name)));
}
}
7 changes: 4 additions & 3 deletions Assets/Scripts/Gameplay/Circuit/Checkpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public void Interact(ICanInteract interactor, InteractionType interactionType)
if (!m_IsActivated)
return;

if (!GameManager.Instance.GetGameStarted())
if (!(interactor is Player))
return;

if (!(interactor is Player) || PlayerManager.Instance.GetLocalPlayer() != (interactor as Player))
Player player = interactor as Player;
if (player != PlayerManager.Instance.GetLocalPlayer())
return;

switch (interactionType)
Expand All @@ -40,7 +41,7 @@ public void Deactivate()
m_IsActivated = false;
}

private void SetCheckpoint()
public void SetCheckpoint()
{
Debug.Log("Checkpoint activated");
m_IsActivated = false;
Expand Down
10 changes: 1 addition & 9 deletions Assets/Scripts/Gameplay/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,10 @@ public void TowerCheckpointCaptured(TowerBase tower)
SetCurrentTower(null);
tower.RevealNext();

// Replace tower with checkpoint
TowerHost th = tower.GetComponent<TowerHost>();
TowerClient tc = tower.GetComponent<TowerClient>();
if (th != null)
Destroy(th);
if (tc != null)
Destroy(tc);

int priority = tower.GetPriority();
if (m_CurrentCheckpointPriority <= priority)
{
tower.GetComponent<Checkpoint>().Activate();
tower.GetComponent<Checkpoint>().SetCheckpoint();
m_CurrentCheckpointPriority = priority;
}
}
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Gameplay/Towers/TowerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ private void HandleEntry(Player player)
{
m_PlayersInCaptureZone.Add(player);
m_CaptureCountChangeThisFrame++;
m_Tower.TowerEntered?.Invoke(m_Tower);
if (player == PlayerManager.Instance.GetLocalPlayer())
m_Tower.TowerEntered?.Invoke(m_Tower);
}
}

Expand All @@ -93,7 +94,8 @@ private void HandleExit(Player player)
{
m_PlayersInCaptureZone.Remove(player);
m_CaptureCountChangeThisFrame--;
m_Tower.TowerExited?.Invoke();
if (player == PlayerManager.Instance.GetLocalPlayer())
m_Tower.TowerExited?.Invoke();
}
}
}
53 changes: 34 additions & 19 deletions Assets/Scripts/Network/MonsterNetworkHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using BeardedManStudios.Forge.Networking;
using BeardedManStudios.Forge.Networking.Generated;
using BeardedManStudios.Forge.Networking.Unity;

[RequireComponent(typeof(AiMonster), typeof(HealthHandler))]
public class MonsterNetworkHandler : MonsterObjectBehavior
Expand All @@ -17,37 +18,51 @@ private void Start()
{
Debug.LogError("No health handler and ai monster attached " + this);
}
if (networkObject == null)

if (NetworkManager.Instance == null)
{
this.enabled = false;
return;
}
else
{
if (!NetworkManager.Instance.IsServer)
m_aiMonster.DisableAttack();
}
}

private void Update()
{

if (networkObject.IsOwner)
if (networkObject != null)
{
// If we are the owner of the object we should send the new position
// and rotation across the network for receivers to move to in the above code
networkObject.position = transform.position;
networkObject.rotation = transform.rotation;
networkObject.isDead = m_aiMonster.IsDead;
networkObject.health = m_healthHandler.GetHealth();
if (NetworkManager.Instance.IsServer)
{
// If we are the owner of the object we should send the new position
// and rotation across the network for receivers to move to in the above code
networkObject.position = transform.position;
networkObject.rotation = transform.rotation;
networkObject.isDead = m_aiMonster.IsDead;
networkObject.health = m_healthHandler.GetHealth();

}
else
{
transform.position = networkObject.position;
transform.rotation = networkObject.rotation;
if (networkObject.isDead)
string attackName = m_aiMonster.GetAttack();
if (attackName.Length > 0)
networkObject.SendRpc(RPC_TRIGGER_ATTACK_ANIM, Receivers.Others, attackName);
}
else
{
m_aiMonster.OnDeath();
transform.position = networkObject.position;
transform.rotation = networkObject.rotation;
if (networkObject.isDead)
{
m_aiMonster.OnDeath();
}
m_healthHandler.SetHealth(networkObject.health);
}
m_healthHandler.SetHealth(networkObject.health);
}

}

public override void TriggerAttackAnim(RpcArgs args)
{
m_aiMonster.GetMonsterAnimation()?.SetAttackTrigger(args.GetNext<string>());
}
}