//-----------------------------------------------------------------------------------------------Networking public void ReceiveNPCAction(IndividualCard card, NPCManager.ActionType action, int data) { try { switch (action) { case NPCManager.ActionType.Die: Die(data == 1); break; case NPCManager.ActionType.SelectCard: Select(card); break; case NPCManager.ActionType.Activate: Activate(card); break; case NPCManager.ActionType.GoToPos: StartCoroutine(MoveToPosition(card)); break; default: DataLogger.LogError("Unrecognized power up action PUF"); break; } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
const char npc_die = 'D'; //NPCManager.ActionType.Die; public void SendNPCAction(int x, int y, int index, NPCManager.ActionType action, int data) { List <byte> toSend = new List <byte> (); toSend.AddRange(System.BitConverter.GetBytes((short)x)); toSend.AddRange(System.BitConverter.GetBytes((short)y)); toSend.AddRange(System.BitConverter.GetBytes((short)index)); toSend.AddRange(System.BitConverter.GetBytes((short)data)); switch (action) { case NPCManager.ActionType.Spawn: toSend.Add((byte)npc_spawn); break; case NPCManager.ActionType.GoToPos: toSend.Add((byte)npc_goto); break; case NPCManager.ActionType.SelectCard: toSend.Add((byte)npc_select); break; case NPCManager.ActionType.Activate: toSend.Add((byte)npc_activate); break; case NPCManager.ActionType.Die: toSend.Add((byte)npc_die); break; default: DataLogger.LogError("Unknown action type: " + action.ToString() + " can't send multiplayer data"); return; } SendData(a_npc, toSend.ToArray()); }
public void SendNPCAction(int x, int y, NPCManager.ActionType action, int data) { NPCManager.s.SendNPCAction(x, y, this, action, data); }