Esempio n. 1
0
    void ManageSensors()
    {
        AIMovement.Sensor sensor = aiMovement.CheckSensors(sensorLength);
        switch (sensor)
        {
        case AIMovement.Sensor.Front:
            SetAxis(randomDirection, AxisType.SensorResponse, Axis.X);
            SetAxis(0, AxisType.SensorResponse, Axis.Y);
            break;

        case AIMovement.Sensor.FrontRight:
            SetAxis(-0.5f, AxisType.SensorResponse, Axis.X);
            axisYOverriden = false;
            break;

        case AIMovement.Sensor.FrontLeft:
            SetAxis(0.5f, AxisType.SensorResponse, Axis.X);
            axisYOverriden = false;
            break;

        case AIMovement.Sensor.Left:
            if (axisX < 0)
            {
                SetAxis(0, AxisType.SensorResponse, Axis.X);
                StopAxis(AxisType.SensorResponse, Axis.Y);
            }
            else
            {
                StopAxis(AxisType.SensorResponse, Axis.X);
                StopAxis(AxisType.SensorResponse, Axis.Y);
            }
            break;

        case AIMovement.Sensor.Right:
            if (axisX > 0)
            {
                SetAxis(0, AxisType.SensorResponse, Axis.X);
                StopAxis(AxisType.SensorResponse, Axis.Y);
            }
            else
            {
                StopAxis(AxisType.SensorResponse, Axis.X);
                StopAxis(AxisType.SensorResponse, Axis.Y);
            }
            break;

        default:
            float num = Mathf.RoundToInt(UnityEngine.Random.Range(0, 2));
            if (num == 0)
            {
                num = -1;
            }
            randomDirection = num;

            StopAxis(AxisType.SensorResponse, Axis.X);
            StopAxis(AxisType.SensorResponse, Axis.Y);
            break;
        }
        SelectMovementManagement();
    }