Browse Source

Fixed shot if client doesn't have resource

master
JoshuaReason 5 years ago
parent
commit
2386dda271
13 changed files with 4924 additions and 13 deletions
  1. +2
    -2
      Assets/Data/Inventory/BaseInventory.asset
  2. +2
    -2
      Assets/Data/Logic Blocks/Jump x4.asset
  3. +3
    -0
      Assets/Data/Logic Blocks/Missile.asset
  4. +8
    -0
      Assets/Data/Logic Blocks/Missile.asset.meta
  5. +2
    -2
      Assets/Data/Logic Blocks/Move x2.asset
  6. +2
    -2
      Assets/Data/Logic Blocks/Rotate L.asset
  7. +2
    -2
      Assets/Data/Logic Blocks/Rotate R.asset
  8. +1
    -1
      Assets/Data/Logic Blocks/Wait.asset
  9. +4792
    -0
      Assets/Resources/Missile.prefab
  10. +7
    -0
      Assets/Resources/Missile.prefab.meta
  11. +10
    -2
      Assets/Scripts/Logic/Blocks/Shoot.cs
  12. +82
    -0
      Assets/Scripts/Projectiles/HomingMissile.cs
  13. +11
    -0
      Assets/Scripts/Projectiles/HomingMissile.cs.meta

+ 2
- 2
Assets/Data/Inventory/BaseInventory.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7abdd52fffdae58812a259189e853c543358c7c219c21b883aa0a70a621cd3bf
size 1313
oid sha256:3fb94665e70a106a7e0a4ca21efd8c70634b208c2c9bcc75a6601c8a846c559b
size 1186

+ 2
- 2
Assets/Data/Logic Blocks/Jump x4.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:14a02c7122e6f6e41dded7d660f2ebfb079e12d62f6ed497703aedb690d199bf
size 652
oid sha256:1c5150ee7821bd6752635df7a4e75e522e5c83949bf6a3b2b8fdcd6d29b41b9a
size 579

+ 3
- 0
Assets/Data/Logic Blocks/Missile.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1407c67c7a52ce8f47e9373bd2c3663187ab8993f107ef768d5db368c59bc873
size 573

+ 8
- 0
Assets/Data/Logic Blocks/Missile.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e35fa076afd0b64490ee8a934237e40
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

+ 2
- 2
Assets/Data/Logic Blocks/Move x2.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:29eb5a502a740f7952ebc9213d321f98813c16fbd20cd57fd5ba49e29ffc03b3
size 629
oid sha256:cf1896bd1ad950c5c2fee7f7eeb876eff9e417c4c2eb98d306ff0b934bbc58a2
size 553

+ 2
- 2
Assets/Data/Logic Blocks/Rotate L.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f51e51a8146405e8694589cab181e716a7163fc9b631e1735bf212abb5aed33a
size 630
oid sha256:6bdd547d763d7db6d48e22fcb947601c11bc5adca2e6e02550e96e25d40a4de1
size 566

+ 2
- 2
Assets/Data/Logic Blocks/Rotate R.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d4dc2709949a4748e68da5170dd7c30cfd67987f109ad28214561d6eddc46dd1
size 631
oid sha256:3ea01fc0d3ad9bf270994843c6d532111ce194ac30849cc9a7336f94cb11da44
size 571

+ 1
- 1
Assets/Data/Logic Blocks/Wait.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dc8815845149e2879b2e1fc3a0a8dc47e3b28887cdd28481eadf66824476be0b
oid sha256:0f523990c61fcbf64c1b736d9c37e0253db2a84eef7d517857b173d2adc7f9ba
size 561

+ 4792
- 0
Assets/Resources/Missile.prefab
File diff suppressed because it is too large
View File


+ 7
- 0
Assets/Resources/Missile.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0cf1a8d5531d3eb44bb52de9028f95f2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 10
- 2
Assets/Scripts/Logic/Blocks/Shoot.cs View File

@ -15,6 +15,8 @@ public class Shoot : LogicBlock
[Header("Projectile to Shoot")]
private Projectile Projectile;
private string prefabName;
public override Block GetEndBlock(Block startBlock, Transform transform, LayerMask layerMask)
{
return startBlock;
@ -34,7 +36,10 @@ public class Shoot : LogicBlock
public override void CopyToken(BlockToken token)
{
base.CopyToken(token);
Projectile = Resources.Load<GameObject>(((ShotToken)token).prefabName).GetComponent<Projectile>();
prefabName = ((ShotToken)token).prefabName;
Projectile = Resources.Load<GameObject>(((ShotToken)token).prefabName)?.GetComponent<Projectile>();
Direction = ((ShotToken)token).direction;
}
@ -46,7 +51,10 @@ public class Shoot : LogicBlock
Debug.Log(base.ToToken(token).GetType().Name);
ShotToken retVal = (ShotToken)base.ToToken(token);
retVal.direction = Direction;
retVal.prefabName = Projectile.gameObject.name;
if (Projectile != null)
retVal.prefabName = Projectile.gameObject.name;
else
retVal.prefabName = prefabName;
return retVal;
}

+ 82
- 0
Assets/Scripts/Projectiles/HomingMissile.cs View File

@ -0,0 +1,82 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Networking.Server;
public class HomingMissile : Projectile
{
[SerializeField]
ClientList Clients;
public override IEnumerator ProjectileLogic(Character player, float animationTime, Vector3 direction)
{
Character target = findPlayer(player);
yield return StartCoroutine(LerpTo(transform.position + Vector3.up * 2, 0.5f));
yield return new WaitForSeconds(0.5f);
if (target != null)
{
yield return StartCoroutine(LerpTo(target.transform.position, 1f));
yield return PushPlayer(target);
}
}
private IEnumerator PushPlayer(Character player)
{
Direction[] possibleDirections = DirectionExtras.RandomOrder();
for (int i = 0; i < 4; i++)
{
if (Block.isBlockAtPosition( player.transform.position + possibleDirections[i].ToVector() + Vector3.up, 1, ~0))
continue;
yield return StartCoroutine(player.CurrentBlock.DoPush(player, possibleDirections[i].ToVector()));
break;
}
}
private Character findPlayer(Character thisCharacter)
{
Character retVal = null;
foreach (ClientData client in Clients)
{
if (client.Lives == 0 || client.playerCharacter.stuck || client.playerCharacter == thisCharacter)
continue;
if (retVal == null)
retVal = client.playerCharacter;
if (retVal.transform.position.x <= client.playerCharacter.transform.position.x)
retVal = client.playerCharacter;
}
return retVal;
}
private IEnumerator LerpTo(Vector3 endPosition,float animationTime)
{
Vector3 startPosition = transform.position;
float elapsedTime = 0;
while (elapsedTime < animationTime)
{
transform.position = Vector3.Lerp(startPosition, endPosition, elapsedTime / animationTime);
transform.LookAt(endPosition, Vector3.up);
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
}
transform.position = endPosition;
}
}

+ 11
- 0
Assets/Scripts/Projectiles/HomingMissile.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ede68cce804b6624cb4c368d5c511f49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save