/// <summary> /// Updates the objects position when the server says so. :D /// </summary> /// <param name="proto"></param> public void UpdateServerObject(Protocol.BaseProtocol proto) { Protocol.ServerObject obj = proto.AsType <Protocol.ServerObject>(); if (obj.Type != serverObjectType || obj.object_id != serverObjectId) { return; } print(obj.Action + "==" + Protocol.ServerObject.ObjectAction.Destroy + " && " + obj.Type + "==" + serverObjectType + " && " + obj.object_id + "==" + serverObjectId); if (obj.Action == Protocol.ServerObject.ObjectAction.Destroy) { Destroy(gameObject); } if (obj.Action != Protocol.ServerObject.ObjectAction.Defualt) { return; } // stop the nav agent if present. ClientAgent agent = GetComponent <ClientAgent>(); if (agent != null && !agent.FindingPath && agent.Naving) { print("Stop Agent."); agent?.CancelAction(); } print("TAG " + gameObject.tag + " transform.position " + transform.position); // update the position of the object. transform.position = lastPosition = obj.Position; transform.eulerAngles = lastRotation = obj.Rotation; }
void Shoot() { if (player.gun != null) { player.SetUpperAniState(Player.StateNameHash.shoot); Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); Vector3 targetPoint; RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 100f, player.hitLayer)) { targetPoint = hitInfo.point; } else { targetPoint = Camera.main.transform.position + ray.direction * 100f; } if (player.gun.Shoot(targetPoint, player.hitLayer, out hitInfo)) { LevelManager lm = UnityHelper.GetLevelManager(); Collider collider = hitInfo.collider; if (collider.gameObject.layer == LayerMask.NameToLayer(StringAssets.bodyLayerName)) { Player p = UnityHelper.FindObjectUpward <Player>(collider.transform); if (p != null) { if (lm != null) { lm.CreateParticleEffect(LevelManager.ParticleEffectType.HitPlayer, hitInfo.point, hitInfo.normal); } controller.HitOtherPlayer(p, hitInfo.point, 100f); } else { Debug.LogError("AimState.Shoot >> hit body, but can't find Player component"); } } else if (collider.gameObject.layer == LayerMask.NameToLayer(StringAssets.groundLayerName)) { if (lm != null) { lm.CreateParticleEffect(LevelManager.ParticleEffectType.HitGround, hitInfo.point, hitInfo.normal); } } } if (GlobalVariables.hostType == HostType.Server) { ServerAgent sa = UnityHelper.GetServerAgent(); sa.SendShoot(player.id, targetPoint); } else if (GlobalVariables.hostType == HostType.Client) { ClientAgent ca = UnityHelper.GetClientAgent(); ca.SendShoot(player.id, targetPoint); } } }
public static void KeepGetMessage(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, Func <ReturnValue <KFCallMsg>, bool> onMessage) { ClientAgent agent = socket.ClientObject as ClientAgent; if (null != agent) { agent.KFCallMsg = onMessage; } }
public static void UpdateKuaFuMapClientCount(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int serverId, Dictionary <int, int> mapClientCountDict) { ClientAgent agent = socket.ClientObject as ClientAgent; if (mapClientCountDict != null && mapClientCountDict.Count > 0) { KuaFuServerManager.UpdateKuaFuLineData(agent.ClientInfo.ServerId, mapClientCountDict); ClientAgentManager.Instance().SetMainlinePayload(agent.ClientInfo.ServerId, mapClientCountDict.Values.ToList <int>().Sum()); } }
void OnDestroy() { if (GlobalVariables.hostType == HostType.Server) { ServerAgent sm = GetComponent <ServerAgent>(); sm.enabled = false; } else if (GlobalVariables.hostType == HostType.Client) { ClientAgent cm = GetComponent <ClientAgent>(); cm.enabled = false; } }
public void Save(ClientAgent entity) { if (entity.ClientAgentId > 0) { _context.ClientAgents.Attach(entity); _context.Entry <ClientAgent>(entity).State = System.Data.EntityState.Modified; } else { _context.ClientAgents.Add(entity); } _context.SaveChanges(); }
static void Main(string[] args) { InnerLogger.ConsulLog += c => Console.WriteLine(c.Content); //#region get srvConfig var conf = new ConfigurationBuilder() .SetBasePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory)) .AddJsonFile("appsetting.json", false, false) .Build(); var clientConfig = conf. GetSection("consul:remotes:demo"). Get <ConsulRemoteServiceConfig>(); //#endregio var clientWithClientMiddleware = new ClientAgent <FM.Demo.HelloSrv.HelloSrvClient>(clientConfig, new ClientAgentOption { ClientCallActionCollection = new ClientCallActionCollection { new InvokeTimeoutMiddleware(10000), new LoggerClientCallAction() } }); try { clientWithClientMiddleware.Proxy.Hi(new FM.Demo.HiRequest()); //client.Proxy.Hi(new FM.Demo.HiRequest(), null, DateTime.UtcNow.AddMilliseconds(3000)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } var rawClient = new ClientAgent <FM.Demo.HelloSrv.HelloSrvClient>(clientConfig); try { rawClient.Proxy.Hi(new FM.Demo.HiRequest()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } //end Console.ReadLine(); }
// Use this for initialization void Start() { Physics.gravity = new Vector3(0f, -9.8f, 0f) * gravityScale; //设置重力 Time.timeScale = timeScale; if (GlobalVariables.hostType == HostType.Server) { ServerAgent sm = GetComponent <ServerAgent>(); sm.enabled = true; } else if (GlobalVariables.hostType == HostType.Client) { ClientAgent cm = GetComponent <ClientAgent>(); cm.enabled = true; } }
protected void ButtonFindAgent_Click(object sender, EventArgs e) { ListBoxRealName_Licenses.Items.Clear(); if (TextBoxCodeName.Text.Equals("")) { ListBoxRealName_Licenses.Items.Add("Please type the agent code name"); } else { try { SecretAgentServiceEngland.SecretAgentService agentserviceobject = new SecretAgentServiceEngland.SecretAgentService(); SecretAgentServiceEngland.Agent a; ClientAgent ca; a = agentserviceobject.AgentInfo(TextBoxCodeName.Text); ca = new ClientAgent(a); TextBoxCodeName.Text = ca.codeName; ListBoxRealName_Licenses.Items.Add(ca.ToString()); if (a.licenses != null) { ListBoxRealName_Licenses.Items.Add("List of licenses:"); foreach (string s in a.licenses) { ListBoxRealName_Licenses.Items.Add(s); } } else { ListBoxRealName_Licenses.Items.Add("Without a license!"); } } catch { ListBoxRealName_Licenses.Items.Add("Database is offline... Please try again later.."); } } ListBoxRealName_Licenses.Focus(); }
public void HitOtherPlayer(Player target, Vector3 hitPoint, float damage) { if (GlobalVariables.hostType == HostType.Server) { if (target.playerType == PlayerType.LocalAI || target.playerType == PlayerType.Local) { target.Damage(player, damage, hitPoint); } else if (target.playerType == PlayerType.Remote) { ServerAgent sm = UnityHelper.GetServerAgent(); sm.SendDamage(player, target, hitPoint, damage); } } else if (GlobalVariables.hostType == HostType.Client) { if (target.playerType == PlayerType.Remote) { ClientAgent cm = UnityHelper.GetClientAgent(); cm.SendDamage(player, target, hitPoint, damage); } } }
public ClientsProxy(ClientAgent clientAgent) { _clientAgent = clientAgent; }
/// <summary> /// Controller will create a coordination group between the /// client and the best possible solution agent. /// Three possibilities can occur when requesting an agent from /// the operator, all of which will be handled by the payoff function /// of the agent. /// IE: A logistics agent is nearby which already has a load but no longer /// has a client. /// A manufacturer is nearby which already has capacity but no longer has /// a client. /// A manufacturer is nearby which has spare capacity. /// </summary> /// <param name="client">Client agent which is making the request</param> private void HandleRequestMessage(ClientAgent client) { // Controller will request payoffs from all agents in the environment // from the possible payoffs it is possible for the controller to select the // best agent for the job. // Create a demand request message and send it to the operator agent. Task cTask = new ClientTask(client); Message agentRequest = new RequestMessage(this, ref cTask); messageQueue.SendPost(switchboard, agentRequest); // Check if the communication edge is already set communicationNode.AddEdge(client.CommunicationNode); }
public void Delete(ClientAgent entity) { _context.ClientAgents.Attach(entity); _context.Entry <ClientAgent>(entity).State = System.Data.EntityState.Deleted; _context.SaveChanges(); }
public PeopleBusiness(IMapper mapper) { _mapper = mapper; _peopleAgent = new PeopleAgent(); _clientAgent = new ClientAgent(); }
public ClientBusiness(IMapper mapper) { _mapper = mapper; _clientAgent = new ClientAgent(); }