Beispiel #1
0
    public async ValueTask <IEnumerable <NodeLocation> > FetchAsync(CancellationToken cancellationToken = default)
    {
        try
        {
            using var client = new HttpClient();
            var text = await client.GetStringAsync(URL, cancellationToken);

            var results = new List <NodeLocation>();

            foreach (var line in text.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (!AxisMessage.TryStringToNode(line, out var nodeLocation))
                {
                    continue;
                }
                results.Add(nodeLocation);
            }

            return(results.ToArray());
        }
        catch (Exception e)
        {
            _logger.Warn(e);
        }

        return(Enumerable.Empty <NodeLocation>());
    }
Beispiel #2
0
        protected virtual void SendAxisData(string name, float value)
        {
            // send axis data
            AxisMessage msg = new AxisMessage();

            msg.AxisName  = name;
            msg.AxisValue = value;
            this.Client.Send(InputMsgType.Axis, msg);
        }
Beispiel #3
0
    protected void Evade(PlayerController player)
    {
        float forwardAngle = Vector3.Angle(player.transform.position - transform.position, transform.forward);
        float rightAngle = Vector3.Angle(player.transform.position - transform.position, transform.right);
        float numX, numY;

        // Depending on the angle from the player firing, attempt to first set axis in a certain direction
        if (rightAngle < 90f)
        {
            numX = -1f;
        }
        else
        {
            numX = 1f;
        }
        if (forwardAngle < 90f)
        {
            numY = 1f;
        }
        else
        {
            numY = -1f;
            numX = -numX;
        }

        // Rotate left, right or not at all depending on X Axis Restrictions
        AxisMessage responseX = SetXAxis(numX, Priority.Evasion);

        if (responseX == AxisMessage.AxisOutOfRange)
        {
            responseX = SetXAxis(-numX, Priority.Evasion);
            if (responseX == AxisMessage.AxisOutOfRange)
            {
                responseX = SetXAxis(0, Priority.Evasion);
            }
        }
        // Move forward or backward depending on Y Axis Restrictions
        AxisMessage responseY = SetYAxis(numY, Priority.Evasion);

        if (responseY == AxisMessage.AxisOutOfRange)
        {
            SetYAxis(-numY, Priority.Evasion);
        }
        // Rotate until tank is 90 degrees from player
        evadeMechanism    = new AIEvadeMechanism(90f, 1f, playerFireTarget, evadeDistance);
        lastPlayerFirePos = player.transform.position;
    }
        protected virtual void OnReceiveAxis(NetworkMessage netMsg)
        {
            AxisMessage msg = netMsg.ReadMessage <AxisMessage> ();

            this._axis [msg.AxisName] = msg.AxisValue;
        }