コード例 #1
0
    public BeamHandler CreateBeam(Vector3 start, Vector3 dir, BeamHandler template)
    {
        var beam = Instantiate <BeamHandler>(beamPrefab, beamParent.transform);

        beam.InitBeam(this, start, dir, template);
        return(beam);
    }
コード例 #2
0
ファイル: BeamHandler.cs プロジェクト: iburinoc/laser-game
    public void InitBeam(GameHandler h, Vector3 start, Vector3 dir, BeamHandler template)
    {
        if (beamCount >= MAX_BEAMS)
        {
            GameObject.Destroy(gameObject);
            return;
        }
        this.intensity = (template != null) ? template.intensity : 10;

        beamCount++;

        this.game = h;

        transform.rotation = Quaternion.FromToRotation(Vector3.right, dir);
        transform.position = start;

        this.start = 0;
        this.end   = 0;


        this.powered = true;

        this.endPoint = null;
        this.children = null;

        this.sprayEffect = game.CreateSprayEffect();

        layerMask =
            1 << LayerMask.NameToLayer("Tile") |
                1 << LayerMask.NameToLayer("Wall");

        SetEndpoints();
    }
コード例 #3
0
ファイル: MirrorHandler.cs プロジェクト: zhyty/laser-game
    public override List <BeamHandler> OnBeamCollision(BeamHandler beam, RaycastHit hit)
    {
        Vector3 reflectedDir = Vector3.Reflect(beam.GetDir(), hit.normal);
        var     beams        = new List <BeamHandler>();

        beams.Add(game.CreateBeam(hit.point, reflectedDir));
        return(beams);
    }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     beam = game.CreateBeam(
         transform.TransformPoint(new Vector3(0, 0.5f, 0)),
         transform.TransformDirection(new Vector3(0, 1, 0)),
         null /* no template beam */
         );
 }
コード例 #5
0
    public override List <BeamHandler> OnBeamCollision(BeamHandler beam, RaycastHit hit)
    {
        Vector3     reflectedDir = Vector3.Reflect(beam.GetDir(), hit.normal);
        var         beams        = new List <BeamHandler>();
        BeamHandler continuation = game.CreateBeam(hit.point + 0.000001f * beam.GetDir(), beam.GetDir());
        BeamHandler reemission   = game.CreateBeam(hit.point, reflectedDir);

        beams.Add(continuation);
        beams.Add(reemission);
        return(beams);
    }
コード例 #6
0
    public override List <BeamHandler> OnBeamCollision(BeamHandler beam, RaycastHit hit)
    {
        Vector3 reflectedDir = Vector3.Reflect(beam.GetDir(), hit.normal);
        var     beams        = new List <BeamHandler>();

        // Low-intensity beams are destroyed on contact with a beam-splitter,
        // since both re-emissions are too dim to trigger anything.
        if (beam.intensity > 0)
        {
            BeamHandler continuation = game.CreateBeam(hit.point + 0.000001f * beam.GetDir(), beam.GetDir(), beam);
            BeamHandler reemission   = game.CreateBeam(hit.point, reflectedDir, beam);

            continuation.intensity -= 1;
            reemission.intensity   -= 1;

            beams.Add(continuation);
            beams.Add(reemission);
        }
        return(beams);
    }
コード例 #7
0
ファイル: DoorHandler.cs プロジェクト: iburinoc/laser-game
 public override List <BeamHandler> OnBeamCollision(BeamHandler beam, RaycastHit hit)
 {
     return(null);
 }