Exemple #1
0
    public void UpdateLaser(TargetingSensor sensor)
    {
        laser.enabled = sensor.IsLocked || sensor.HasObstacle;

        if (laser.enabled)
        {
            SetLineColor(sensor.HasObstacle ? blue : red);
            laser.SetPosition(0, sensor.StartPosition);
            laser.SetPosition(1, sensor.EndPosition);
        }
    }
Exemple #2
0
    public Bullet Shoot(TargetingSensor sensor)
    {
        // TODO MissingReferenceException ?
        Bullet bullet = bullets[--index] ?? CreateBullet(index);

        index = index == 0 ? size : index;

        bullet.Shoot(sensor);
        audioPlayer.Play(bullet.Audio, Sounds.SHOT, 1f, -0.5f);

        return(bullet);
    }
Exemple #3
0
    public void Shoot(TargetingSensor sensor)
    {
        transform.position = sensor.StartPosition;
        transform.rotation = sensor.Rotation;

        gameObject.SetActive(true);
        trail.Clear();
        trail.enabled = true;

        transform.Translate(offset, Space.Self);
        rb.AddForce(transform.forward * force, ForceMode.VelocityChange);

        crStop = StartCoroutine(StopBulletCR());
    }
Exemple #4
0
    public override void Initialize()
    {
        base.Initialize();

        Sensor     = new TargetingSensor(body, 20f, 30f);
        bulletPool = Object.FindObjectOfType <BulletPool>();
        eye        = movingParts.Find("Eye");
        cam        = transform.Find("Cam");

        navigator = GetComponent <NavigatorAgent>();
        resolution res = navigator.brain.brainParameters.cameraResolutions[0];

        // See changes in ML-Agents/Scripts/Agent.cs line 548 ff.
        camTexture = new Texture2D(res.width, res.height, TextureFormat.RGB24, false)
        {
            filterMode = FilterMode.Point
        };
        // See /DepthCam/Shader/DepthAndMotion.cginc
        GetCam().Initialize(ref camTexture);
        navigator.SetCustonTexture(ref camTexture);

        sfx = GetComponentInChildren <SFX>();
        sfx.Initialize(this);
    }