magical attack fixed

This commit is contained in:
sewmina7@gmail.com 2024-07-22 22:34:21 +05:30
parent 896eb0c137
commit c55923c918
6 changed files with 106 additions and 46 deletions

View File

@ -4833,15 +4833,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -9751,15 +9749,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 3
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -14763,15 +14759,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 3
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -19681,15 +19675,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 3
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -24589,15 +24581,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -24649,7 +24639,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
clientStarted: 1
clientStarted: 0
sceneId: 0
_assetId: 1059374897
serverOnly: 0
@ -24667,7 +24657,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a553cb17010b2403e8523b558bffbc14, type: 3}
m_Name:
m_EditorClassIdentifier:
syncDirection: 1
syncDirection: 0
syncMode: 0
syncInterval: 0
target: {fileID: 7706410961180048727}

View File

@ -9131,6 +9131,7 @@ MonoBehaviour:
currentQuest: {fileID: 0}
questActions: []
completedQuests: []
projectile: {fileID: 8407628868844321581, guid: 845dd5352c7714440a8d537e79b36ed1, type: 3}
isLoaded: 0
playerAttack: {fileID: 0}
isDead: 0

View File

@ -78,38 +78,22 @@ public class PlayerAttack : NetworkBehaviour{
if(pnet.health<=0){return;}
Vector3 direction = GetPlayerLookDir();
if(isServer){
magicalAttack(direction);
}else{
//if(isServer){
pnet.MagicalAttack(direction, magicalProjectileSpawnOffset, damage);
/*}else{
Debug.Log(direction);
CmdMagicalAttack(direction);
}
return;
Debug.Log("direction Magic"+ direction);
GameObject projectileSpawned = Instantiate(projectile , transform.position + (direction * magicalProjectileSpawnOffset) , Quaternion.identity);
projectileSpawned.GetComponent<RangeProjectile>().direction = direction;
projectileSpawned.GetComponent<RangeProjectile>().OnHit.AddListener(OnMagicalHit);
}*/
}
[Command]
/* [Command]
void CmdMagicalAttack(Vector3 direction){
magicalAttack(direction);
}
}*/
void magicalAttack(Vector3 direction){
GameObject projectileSpawned = Instantiate(projectile , transform.position + (direction * magicalProjectileSpawnOffset) , Quaternion.identity);
RangeProjectile _projectile = projectileSpawned.GetComponent<RangeProjectile>();
_projectile.direction = direction;
_projectile.OnHit.AddListener(OnMagicalHit);
_projectile.shooterId = netId;
NetworkServer.Spawn(projectileSpawned);
}
void OnMagicalHit(enemyScript victim){
int damageamount = damage + (pnet.lvl*5);
victim.TakeMagicalDamage(damageamount, netId);
}
Vector3 GetPlayerLookDir(){
Vector3 direction = Vector3.right;

View File

@ -77,11 +77,27 @@ public class RangeProjectile : NetworkBehaviour
void DestroyProjectile(){
//Instantiate hit effect
Instantiate(hitEffectVfx , transform.position , Quaternion.identity);
Destroy(gameObject);
if (isServer)
{
RpcDestroyProjectile();
destroyProjectile();
}
//Destroy(hitEffectVfx, hitLifetime);
}
[ClientRpc]
void RpcDestroyProjectile()
{
destroyProjectile();
}
void destroyProjectile()
{
Instantiate(hitEffectVfx, transform.position, Quaternion.identity);
Destroy(gameObject);
}
void OnDrawGizmos(){
Gizmos.DrawWireSphere(transform.position, castRadius);
}

View File

@ -148,6 +148,8 @@ public class playerNetwork : NetworkBehaviour
public List<QuestAction> questActions;
public List<string> completedQuests;
public GameObject projectile;
public void QuestFunction(QuestScriptable questData){
currentQuest = questData;
questText.text = questData.questTitle;
@ -690,11 +692,60 @@ public class playerNetwork : NetworkBehaviour
void CmdDropPickup(string type){
GameManager.instance.SpawnPickup(type,transform.position + new Vector3(4,0));
}
public void GoBackMenu(){
int magicalDmg = 0;
public void MagicalAttack(Vector3 direction, float magicalProjectileSpawnOffset, int dmg)
{
if (isServer)
{
magicalAttack(direction, magicalProjectileSpawnOffset, dmg);
}
else
{
CmdMagicalAttack(direction, magicalProjectileSpawnOffset, dmg);
}
}
[Command]
void CmdMagicalAttack(Vector3 direction, float magicalProjectileSpawnOffset, int dmg)
{
magicalAttack(direction, magicalProjectileSpawnOffset, dmg);
}
void magicalAttack(Vector3 direction, float magicalProjectileSpawnOffset, int dmg)
{
magicalDmg = dmg;
GameObject projectileSpawned = Instantiate(projectile, transform.position + (direction * magicalProjectileSpawnOffset), Quaternion.identity);
RangeProjectile _projectile = projectileSpawned.GetComponent<RangeProjectile>();
_projectile.direction = direction;
_projectile.OnHit.AddListener(OnMagicalHit);
_projectile.shooterId = netId;
NetworkServer.Spawn(projectileSpawned);
}
void OnMagicalHit(enemyScript victim)
{
int damageamount = magicalDmg + (lvl * 5);
victim.TakeMagicalDamage(damageamount, netId);
}
public void GoBackMenu(){
startClient.instance.networkManager.StopClient();
SceneManager.LoadScene("GameLogin");
#if UNITY_EDITOR || UNITY_SERVER
#if UNITY_EDITOR || UNITY_SERVER || UNITY_STANDALONE_WIN
#else
PlayGamesPlatform.Instance.SignOut();
Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();

View File

@ -0,0 +1,18 @@
{
"MonoBehaviour": {
"Version": 4,
"EnableBurstCompilation": true,
"EnableOptimisations": true,
"EnableSafetyChecks": false,
"EnableDebugInAllBuilds": false,
"DebugDataKind": 1,
"EnableArmv9SecurityFeatures": false,
"CpuMinTargetX32": 0,
"CpuMaxTargetX32": 0,
"CpuMinTargetX64": 0,
"CpuMaxTargetX64": 0,
"CpuTargetsX32": 6,
"CpuTargetsX64": 72,
"OptimizeFor": 0
}
}