Beispiel #1
0
    bool InputActivator()
    {
        if (LastSeenTile.ActivatorOnTile == null)
        {
            return(false);
        }

        PreassurePlate pp = LastSeenTile.ActivatorOnTile as PreassurePlate;

        if (pp != null)
        {
            return(false);
        }

        LaserReceiver lr = LastSeenTile.ActivatorOnTile as LaserReceiver;

        if (lr != null)
        {
            return(false);
        }

        LaserGenerator lg = LastSeenTile.ActivatorOnTile as LaserGenerator;

        if (lg != null)
        {
            return(false);
        }

        LastSeenTile.ActivatorOnTile.OnActivate();
        return(true);
    }
    protected override void LaserEffect2()
    {
        LaserReceiver laserReceiver = sensor.GetComponent <LaserReceiver> ();

        laserReceiver.powerLvl += Time.deltaTime * 2;
    }
Beispiel #3
0
    public void CreateLaser(Tile t)
    {
        if (render == null)
        {
            render = GetComponent <MeshRenderer>();
        }

        if (c == null)
        {
            c = GetComponent <Collider>();
        }

        render.enabled = true;

        LaserReceiver lr = t.ActivatorOnTile as LaserReceiver;

        if (lr != null)
        {
            receiver = lr;
            receiver.OnActivate();
            return;
        }

        if (t.ObjectOnTile != null)
        {
            LaserGenerator lg = t.ObjectOnTile as LaserGenerator;

            if (lr != null)
            {
                receiver = lr;
                receiver.OnActivate();
            }
            else if (lg != null && lg.isMirror)
            {
                receiver = lg;
                receiver.OnActivate();
            }
            else
            {
                render.enabled = false;
            }
        }

        Vector3 vec = transform.position + source.DirVector;

        Debug.Log("TRANS: " + transform.position + " " + source.DirVector);
        Debug.Log(vec.x);
        Tile[] tiles = Level.GetTile(vec);

        if (tiles == null)
        {
            return;
        }

        Tile tile;

        Debug.Log("Tile " + tiles[0].Position);

        GameObject laserObj;

        if (orientation.Equals(LaserDirection.upDown))
        {
            laserObj = Instantiate(source.laserPrefabUpDown);
        }
        else
        {
            laserObj = Instantiate(source.laserPrefab);
        }

        Laser l = laserObj.GetComponent <Laser>();

        if (l.render == null)
        {
            l.render = l.GetComponent <MeshRenderer>();
        }

        if (ItemType.Equals(TimelineObject.Present))
        {
            tile              = tiles[0];
            l.ItemType        = TimelineObject.Present;
            l.render.material = l.material;
        }
        else
        {
            tile              = tiles[1];
            l.ItemType        = TimelineObject.Past;
            l.render.material = l.pastMaterial;
        }

        if (!tile.IsAccessable)
        {
            Debug.Log("There is no such tile!");
            Destroy(laserObj);
            return;
        }

        laserObj.transform.parent = source.transform;
        l.source         = source;
        l.previousLaser  = this;
        nextLaser        = l;
        tile.LaserOnTile = l;
        l.myTile         = tile;

        Debug.Log("TILE SET: " + myTile.Position);
        laserObj.transform.rotation = this.transform.rotation;
        laserObj.transform.position = new Vector3(tile.Position.x, tile.Height, tile.Position.y);

        Debug.Log("Visibility check");
        l.SetVisibility();
        l.CreateLaser(tile);
    }