コード例 #1
0
ファイル: DreamObject.cs プロジェクト: williamd4112/GPFinal
 void OnLightEnter(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id && !isDetected)
     {
         c = mMaterial.color;
     }
 }
コード例 #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, !Screen.fullScreen);
        }

        if (Input.GetMouseButtonDown(0))
        {
            foreach (Light2D l in lightsInScene)
            {
                Rect box = new Rect(l.transform.position.x - 1, l.transform.position.y - 1, 2, 2);
                wasHit = box.Contains(Camera.main.ScreenToWorldPoint(Input.mousePosition));

                if (wasHit)
                {
                    selectedLight = l;
                    break;
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            CreateLight(Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10));
        }

        if (wasHit && Input.GetMouseButton(0))
        {
            selectedLight.transform.position = Vector3.Lerp(selectedLight.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0, 0, 10), Time.deltaTime * 20f); // new Vector3(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"), 0);
        }
    }
コード例 #3
0
ファイル: LightControl.cs プロジェクト: Krosantos/Time-Bubble
    void OnLightStay(Light2D l, GameObject g)
    {
        if (g.tag == "Enemy" && beamOn){
            if (!g.renderer.isVisible){
                if (audioSource.isPlaying) audioSource.Stop();
                g.GetComponent<MobBase>().Recover();
                g.transform.GetComponentInChildren<ParticleSystem>().Stop();
                ScreenShake2D.SetShake(0f);
                return;
            }
            float range = Mathf.Clamp(1f - ((g.transform.position - transform.position).magnitude / l.LightRadius), 0f, 1f);
            float compositeintensity = range * intensity;
            g.GetComponent<MobBase>().Petrify(compositeintensity);
            g.transform.GetComponentInChildren<ParticleSystem>().startSpeed = Mathf.Lerp(5f,10f,intensity);
            if (g.GetComponent<MobBase>().isPetrified){
                g.transform.GetComponentInChildren<ParticleSystem>().Stop();
                ScreenShake2D.Shake(0f,0f);
                if (audioSource.isPlaying) audioSource.Stop();
            }
            else{
                if (!g.transform.GetComponentInChildren<ParticleSystem>().isPlaying){
                    g.transform.GetComponentInChildren<ParticleSystem>().Play();
                }
                ScreenShake2D.SetShake(Mathf.Clamp(intensity-.5f, 0f, 1f) * .1f);
                if (!audioSource.isPlaying) audioSource.Play();
                audioSource.pitch = Mathf.Lerp(.25f, 2f, compositeintensity);
                audioSource.volume = Mathf.Lerp(0f, .75f, compositeintensity);
            }
        }if (g.tag == "Enemy" && !beamOn){
            //g.GetComponent<MobBase>().Recover();
            g.transform.GetComponentInChildren<ParticleSystem>().Stop();
            if (audioSource.isPlaying) audioSource.Stop();

        }
    }
コード例 #4
0
ファイル: EventSample_VLS.cs プロジェクト: Insality/LD33
 private void OnLightEnter(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id){
         c += l.LightColor;
         AudioSource.PlayClipAtPoint(hitSound, transform.position, 0.1f);
     }
 }
コード例 #5
0
    void OnLightExit(Light2D l, GameObject o)
    {
        if (o.GetInstanceID() == id)
        {

        }
    }
コード例 #6
0
 void OnLightEnter(Light2D l, GameObject o)
 {
     if(o.GetInstanceID() == id)
     {
         Debug.Break();
     }
 }
コード例 #7
0
ファイル: BeatLightScaler.cs プロジェクト: Insality/LD33
 private void Start()
 {
     _cameraBeatTracker = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<BeatTracker>();
     _light2D = GetComponent<Light2D>();
     ScaleFrom = _light2D.LightRadius;
     ScaleTo = ScaleFrom + ScaleUpTo;
 }
コード例 #8
0
 void OnLightStay(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id)
     {
         isDetected = true;
     }
 }
コード例 #9
0
ファイル: DreamObject.cs プロジェクト: drowsy810301/GPFinal
    void OnLightExit(Light2D l, GameObject g)
    {
        if (g.GetInstanceID() == id)
        {
            Debug.Log("Exit");

        }
    }
コード例 #10
0
ファイル: DreamObject.cs プロジェクト: drowsy810301/GPFinal
 void OnLightStay(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id)
     {
         Debug.Log("Stay");
         isDetected = true;
     }
 }
コード例 #11
0
 // Use this for initialization
 void Awake()
 {
     light2d = GetComponent<Light2D>();
     renderer = GetComponent<MeshRenderer>();
     sprite = GetComponentInChildren<SpriteRenderer>();
     collider = GetComponentInChildren<PolygonCollider2D>();
     DrawSprite();
 }
コード例 #12
0
ファイル: DreamObject.cs プロジェクト: drowsy810301/GPFinal
 void OnLightEnter(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id)
     {
         Debug.Log("Enter");
         c = mOriginColor + l.LightColor;
     }
 }
コード例 #13
0
ファイル: LightControl.cs プロジェクト: Krosantos/Time-Bubble
    void OnLightEnter(Light2D l, GameObject g)
    {
        //Debug.Log(g.name);
        if (g.tag == "Enemy" && beamOn && g.renderer.isVisible){
            g.transform.GetComponentInChildren<ParticleSystem>().Play();
            if (!audioSource.isPlaying) audioSource.Play();

        }
    }
コード例 #14
0
 void OnStayEvent(Light2D light, GameObject go)
 {
     if (go.GetInstanceID() == colliderObject.GetInstanceID())
     {
         float d = Vector3.Distance(light.gameObject.transform.position, colliderObject.transform.position) / light.LightRadius;
         Color c = new Color(light.LightColor.r, light.LightColor.g, light.LightColor.b);
         AddColor(Color.Lerp(c, new Color(0, 0, 0, 1f), Mathf.Clamp(d, 0, 1f)));
     }
 }
コード例 #15
0
ファイル: LightControl.cs プロジェクト: Krosantos/Time-Bubble
 void OnLightExit(Light2D l, GameObject g)
 {
     if (g == null) return;
     if (g.tag == "Enemy"){
         if (audioSource.isPlaying) audioSource.Stop();
         g.GetComponent<MobBase>().Recover();
         g.transform.GetComponentInChildren<ParticleSystem>().Stop();
         ScreenShake2D.SetShake(0f);
     }
 }
コード例 #16
0
 // Use this for initialization
 public void Start()
 {
     base.Start();
     mBounds = GetComponent<Collider2D>().bounds;
     mFlashLight = Light2D.Create(transform.position + new Vector3(mBounds.extents.x + EPILSON, 0, 0),
         Color.blue, 10.0f, 15);
     mFlashLight.EnableEvents = true;
     mFlashLight.LightConeStart = 0;
     mPlatformCharacter = GetComponent<PlatformerCharacter2D>();
 }
コード例 #17
0
    void CreateLight(Vector3 position)
    {
        selectedLight = Light2D.Create(position, new Color(1f, 0.5f, 0f, 0f), initialRadius);
        selectedLight.EnableEvents = true;

        if (isPro)
            selectedLight.gameObject.layer = 31;

        lightsInScene.Add(selectedLight);
    }
コード例 #18
0
ファイル: LightLogic.cs プロジェクト: Insality/LD33
    // Use this for initialization
    private void Start()
    {
        _lightSource = GetComponent<Light2D>();
        _startRadius = _lightSource.LightRadius;
        _lightScaler = GetComponent<BeatLightScaler>();
        _goalX = 0;

        _levelManager = Camera.main.GetComponent<LevelManager>();

        Camera.main.GetComponent<BeatTracker>().BeatEvent += (sender, args)=>LightBeat();
    }
コード例 #19
0
 void OnLightStay(Light2D _lightObject, GameObject _gameObject)
 {
     if (_gameObject.GetInstanceID() == gameObject.GetInstanceID())
     {
         Transform lightSource = _lightObject.transform.parent;
         if (lightSource.tag == "Guard")
         {
             BeChasedByGuard(lightSource);
         }
     }
 }
コード例 #20
0
ファイル: RandomLightOff.cs プロジェクト: silentic/Flashlight
 // Use this for initialization
 void Start()
 {
     player = Game.player;
     playerRenderer = player.GetComponent<Renderer>();
     InvokeRepeating("LightActive", 5, 1);
     lightRenderer = GetComponent<Renderer>();
     GameObject visionObject = GameObject.FindGameObjectWithTag("Vision");
     playerVision = visionObject.GetComponent<Light2D>();;
     light3D = visionObject.GetComponent<Light>();
     blackOut = false;
 }
コード例 #21
0
ファイル: ScreamScript.cs プロジェクト: silentic/Flashlight
    void OnLightEnter(Light2D _light, GameObject _go)
    {
        if (_go.GetInstanceID() == gameObject.GetInstanceID())
        {
            if (visible <= 0)
            {
                Debug.Log("Object Entered Light");

                enemyRenderer.enabled = true;
            }
            visible += 1;
        }
    }
コード例 #22
0
ファイル: Enemy.cs プロジェクト: silentic/Flashlight
    protected void OnLightEnter(Light2D light, GameObject go)
    {
        if (go.GetInstanceID() == gameObject.GetInstanceID())
        {
            if(visible <= 0)
            {
                //Debug.Log("Object Entered Light");
                enterLightEffect();

            }
            visible += 1;
        }
    }
コード例 #23
0
ファイル: Enemy.cs プロジェクト: silentic/Flashlight
    protected void OnLightExit(Light2D light, GameObject go)
    {
        if (go.GetInstanceID() == gameObject.GetInstanceID())
        {
            visible -= 1;
            if(visible <= 0)
            {
                //Debug.Log("Object Exited Light");
                exitLightEffect();
            }

        }
    }
コード例 #24
0
ファイル: FOVScript_VLS.cs プロジェクト: Insality/LD33
    private void OnLightExit(Light2D _light, GameObject _go)
    {
        /* Function called everytime an object exits the light.
         * Use the _go object that is passed to determin if the current
         * gameObject is equal to the one this script is in (if needed) */
        if (_go.GetInstanceID() == gameObject.GetInstanceID()){
            // GameObject just left the visibility of the light object
            Debug.Log("Object Exited Light");

            // Change color [For Visualization]
            gameObject.GetComponent<Renderer>().material.color = kColor;
        }
    }
コード例 #25
0
    void OnLightStay(Light2D _light, GameObject _go)
    {
        /* Function called every LateUpdate if an object is in the light.
         * Use the _go object that is passed to determin if the current
         * gameObject is equal to the one this script is in (if needed) */
        if (_go.GetInstanceID() == gameObject.GetInstanceID())
        {
            // GameObject is currently visible by light object
            Debug.Log("Object Inside Light");

            // Change color [For Visualization]
            gameObject.renderer.material.color = Color.Lerp(gameObject.renderer.material.color, Color.red, Time.deltaTime * 0.5f);
        }
    }
コード例 #26
0
    void OnLightEnter(Light2D _light, GameObject _go)
    {
        /* Function called everytime a new object enters the light.
         * Use the _go object that is passed to determin if the current
         * gameObject is equal to the one this script is in (if needed) */
        if (_go.GetInstanceID() == gameObject.GetInstanceID())
        {
            // GameObject just became visible by light object
            Debug.Log("Object Entered Light");

            // Change color [For Visualization]
            gameObject.renderer.material.color = Color.blue;
        }
    }
コード例 #27
0
ファイル: Exit.cs プロジェクト: silentic/Flashlight
    void OnLightEnter(Light2D light, GameObject go)
    {
        if (go.GetInstanceID() == gameObject.GetInstanceID())
        {
            if(visible <= 0)
            {
                foreach(SpriteRenderer renderer in GetComponentsInChildren<SpriteRenderer>())
                {
                    renderer.enabled = true;
                }

            }
            visible += 1;
        }
    }
コード例 #28
0
ファイル: Exit.cs プロジェクト: silentic/Flashlight
    void OnLightExit(Light2D light, GameObject go)
    {
        if (go.GetInstanceID() == gameObject.GetInstanceID())
        {
            visible -= 1;
            if(visible <= 0)
            {
                foreach(SpriteRenderer renderer in GetComponentsInChildren<SpriteRenderer>())
                {
                    renderer.enabled = false;
                }
            }

        }
    }
コード例 #29
0
ファイル: Shape.cs プロジェクト: takdw00/Project_Empty
        public static void Draw(Light2D light, LightCollider2D id)
        {
            if (id.InLight(light) == false)
            {
                return;
            }

            light.AddCollider(id);

            foreach (LightColliderShape shape in id.shapes)
            {
                List <Polygon2> polygons = shape.GetPolygonsWorld();

                ShadowEngine.Draw(polygons, shape.shadowDistance, id.shadowTranslucency);
            }
        }
コード例 #30
0
        public Player(Vector2 positionInWorld)
            : base(GamePlayManager.MobManager, BuildBody())
        {
            Light = new Light2D()
            {
                Texture   = Game1.LightTexture,
                Range     = 120,
                Color     = Color.LightBlue,
                Intensity = .7f,
                Angle     = MathHelper.TwoPi
            };

            SetPhysicalBodyPosition(ConvertUnits.ToSimUnits(positionInWorld));
            AnimatedSprite = new AnimatedSprite(@"Photon");
            Speed          = 5;
        }
コード例 #31
0
        virtual protected void OnLightStay(Light2D l, GameObject g)
        {
            if (g.GetInstanceID() == id)
            {
                //Debug.Log (l.LightColor+" "+errorLight);

                if (ColorUtil.colorCompareQuantRGB(l.LightColor, errorLight, 127))
                {
                    isCrazy = true;
                }
                else
                {
                    isCrazy = false;
                }
            }
        }
コード例 #32
0
    void Start()
    {
        eyeLimitAngle.upRightAngle    = 0.0f + limitEyeSightRange;
        eyeLimitAngle.upLeftAngle     = 0.0f + limitEyeSightRange;
        eyeLimitAngle.downRightAngle  = 180.0f - limitEyeSightRange;
        eyeLimitAngle.downLeftAngle   = 180.0f - limitEyeSightRange;
        headLimitAngle.upRightAngle   = 0.0f + limitEyeSightRange;
        headLimitAngle.upLeftAngle    = 0.0f - limitEyeSightRange;
        headLimitAngle.downRightAngle = -90.0f + limitEyeSightRange;
        headLimitAngle.downLeftAngle  = 90.0f - limitEyeSightRange;

        light2D = eyeSight.GetComponent <Light2D>();

        innerAngle = light2D.pointLightInnerAngle;
        outerAngle = light2D.pointLightOuterAngle;
    }
コード例 #33
0
    private int tweenID;                     // LeanTween-operaatiolle annettava uniikki ID, jolla voidaan esim. pysäyttää operaatio


    // Start is called before the first frame update
    void Start()
    {
        player         = UnityEngine.GameObject.FindGameObjectWithTag("Player");
        cameraLight    = GetComponentInChildren <Light2D>();
        spriteRenderer = GetComponentInChildren <SpriteRenderer>();

        enemyTriggerArea.SetActive(false);

        spriteRenderer.sprite = viewConeSafeSprite;
        originalSize          = gameObject.transform.localScale;
        tweenID = 0;

        GetComponentInParent <BoxCollider2D>().enabled = false;

        StartCoroutine(Rotate(angle / 2, rotationTime / 2));    // Ensimmäinen rotaatio puolet tavallisesta
    }
コード例 #34
0
    void Start()
    {
        //Get a reference to the Light component on the child game object
        localLight = GetComponentInChildren <Light2D>();

        if (localLight == null)
        {
            Debug.LogError("Error with LightFlicker script component " + this);
            Destroy(this);
            return;
        }

        //Record the intensity and pick a random seed number to start
        intensity = localLight.intensity;
        offset    = Random.Range(0, 10000);
    }
コード例 #35
0
ファイル: Player.cs プロジェクト: drGsus/Dead-Cosmonauts
    void Awake()
    {
        if (controller == null)
        {
            controller = GetComponent <CharacterController>();
        }

        ammoText   = GameObject.Find("AmmoText").GetComponent <tk2dTextMesh>();
        weaponText = GameObject.Find("WeaponText").GetComponent <tk2dTextMesh>();

        health     = maxHealth;
        stamina    = maxStamina;
        flashlight = GetComponentInChildren <Light2D>();

        UpdateAmmoHUD();
    }
コード例 #36
0
    private void ToggleNightMode(Toggle toggle)
    {
        Light2D dayLight   = GameObject.FindGameObjectWithTag("DayLight").GetComponent <Light2D>();
        Light2D nightLight = GameObject.FindGameObjectWithTag("NightLight").GetComponent <Light2D>();

        if (toggle.isOn)
        {
            dayLight.enabled   = false;
            nightLight.enabled = true;
        }
        else
        {
            nightLight.enabled = false;
            dayLight.enabled   = true;
        }
    }
コード例 #37
0
        /// <summary>
        /// Applied to Light2D to properly attribute lighting sources.
        /// </summary>
        private static bool AddToScenePartitioner_Prefix(Light2D __instance,
                                                         ref IntHandle ___solidPartitionerEntry,
                                                         ref IntHandle ___liquidPartitionerEntry)
        {
            var  lm   = PLightManager.Instance;
            bool cont = true;

            if (lm != null)
            {
                // Replace the whole method since the radius could use different algorithms
                lm.CallingObject = __instance.gameObject;
                cont             = !PLightManager.AddScenePartitioner(__instance,
                                                                      ref ___solidPartitionerEntry, ref ___liquidPartitionerEntry);
            }
            return(cont);
        }
コード例 #38
0
    void OnLightExit(Light2D l, GameObject g)
    {
        if (g.GetInstanceID() == id)
        {
            c -= l.LightColor;

            if ((GetComponent<Renderer>().material.color.r > 0.95f) && (GetComponent<Renderer>().material.color.g > 0.95f) && (GetComponent<Renderer>().material.color.b > 0.95f))
            {
                AudioSource.PlayClipAtPoint(whiteSound, transform.position, 0.5f);
                Light2D l2d = Light2D.Create(transform.position, hitLightMaterial, new Color(.8f, .8f, 0.6f), Random.Range(3, 5f));
                l2d.ShadowLayer = 0;
                l2d.transform.Rotate(0, 0, Random.Range(10, 80f));
                GameObject.Destroy(l2d.gameObject, 0.2f);
            }
        }
    }
コード例 #39
0
    void Awake()
    {
        noteAudio      = GetComponent <AudioSource>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        _light         = GetComponent <Light2D>();

        spriteRenderer.color            = nodeBlockDisabled;
        spriteRenderer.sortingLayerName = _SortingLayerDisabled;

        blockEnabled = false;

        gameObject.layer = LayerMask.NameToLayer(_SortingLayerDisabled);

        _light.enabled   = true;
        _light.intensity = 0;
    }
コード例 #40
0
    // Start is called before the first frame update
    void Start()
    {
        mainCamera       = FindObjectOfType <Camera>();
        cameraOriginSize = mainCamera.orthographicSize;

        animator = GetComponent <Animator>();

        playerLight    = GetComponentInChildren <Light2D>();
        basicColor     = playerLight.color;
        basicIntensity = playerLight.intensity;

        playerMovement = GetComponentInParent <Movement>();
        levelMax       = 1;
        currentLevel   = 1;
        invicibility   = false;
    }
コード例 #41
0
		public override void DoPostConfigureComplete(GameObject go)
		{
			go.AddOrGet<LoopingSounds>();
			Light2D light2D = go.AddOrGet<Light2D>();
			light2D.overlayColour = LIGHT2D.CEILINGLIGHT_OVERLAYCOLOR;
			light2D.Color = LIGHT2D.CEILINGLIGHT_COLOR;
			light2D.Range = 9f;
			light2D.Angle = 3f;
			light2D.Direction = LIGHT2D.CEILINGLIGHT_DIRECTION;
			light2D.Offset = LIGHT2D.CEILINGLIGHT_OFFSET;
			light2D.shape = LightShape.Cone;
			light2D.drawOverlay = true;
			light2D.Lux = 1800;
			BuildingTemplates.DoPostConfigure(go);
			go.GetComponent<KPrefabID>().prefabInitFn += game_object => new CeilingLamp.Instance(game_object.GetComponent<KPrefabID>()).StartSM();
		}
コード例 #42
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            Light2D light2D = go.AddOrGet <Light2D>();

            light2D.Lux           = 1;
            light2D.overlayColour = LIGHT2D.PLASMALAMP_OVERLAYCOLOR;
            light2D.Color         = LIGHT2D.PLASMALAMP_COLOR;

            light2D.Range       = 8f;
            light2D.Angle       = 0.0f;
            light2D.Direction   = LIGHT2D.PLASMALAMP_DIRECTION;
            light2D.Offset      = LIGHT2D.PLASMALAMP_OFFSET;
            light2D.shape       = LightShape.Circle;
            light2D.drawOverlay = true;
            go.AddOrGetDef <LightController.Def>();
        }
コード例 #43
0
    public void SetNoActiveLight()
    {
        if (ActiveLight == null)
        {
            return;
        }

        if (Tracker != null)
        {
            Destroy(Tracker);
        }

        ActiveLight = null;

        OnNoLightSelected?.Invoke();
    }
コード例 #44
0
ファイル: Map.cs プロジェクト: Soulvomit/Project-Ares-XNA
        public Light2D CreateLight(Texture2D texture, float range, Color color, float intensity, float angle, Vector2 position, float fov)
        {
            Light2D light = new Light2D()
            {
                Texture   = texture,
                Range     = range,
                Color     = color,
                Intensity = intensity,
                Angle     = angle,
                Position  = position,
                Fov       = fov
            };

            Krypton.Lights.Add(light);
            return(light);
        }
コード例 #45
0
    void OnLightExit(Light2D l, GameObject g)
    {
        if (g.GetInstanceID() == id)
        {
            c -= l.LightColor;

            if ((GetComponent <Renderer>().material.color.r > 0.95f) && (GetComponent <Renderer>().material.color.g > 0.95f) && (GetComponent <Renderer>().material.color.b > 0.95f))
            {
                AudioSource.PlayClipAtPoint(whiteSound, transform.position, 0.5f);
                Light2D l2d = Light2D.Create(transform.position, hitLightMaterial, new Color(.8f, .8f, 0.6f), Random.Range(3, 5f));
                l2d.ShadowLayer = 0;
                l2d.transform.Rotate(0, 0, Random.Range(10, 80f));
                GameObject.Destroy(l2d.gameObject, 0.2f);
            }
        }
    }
コード例 #46
0
ファイル: ScreamScript.cs プロジェクト: silentic/Flashlight
    void OnLightExit(Light2D _light, GameObject _go)
    {
        if (_go.GetInstanceID() == gameObject.GetInstanceID())
        {
            visible -= 1;
            if (visible <= 0)
            {
                Debug.Log("Scream: Object Exited Light");

                enemyRenderer.enabled = false;

                Destroy(gameObject);
            }

        }
    }
コード例 #47
0
    // Start is called before the first frame update
    void Start()
    {
        if (SceneManager.GetActiveScene().name == "Play")
        {
            pointLight  = GetComponent <Light2D>();
            globalLight = GameObject.Find("GlobalLight2D").GetComponent <Light2D>();

            if (!isPlayer)
            {
                if (lightValue - globalLight.intensity >= 0)
                {
                    pointLight.intensity = lightValue - globalLight.intensity;
                }
            }
        }
    }
コード例 #48
0
    protected virtual void Start()
    {
        gameSceneController = FindObjectOfType <GameSceneController>();

        if (partToSpawn == null)
        {
            Debug.LogError("Assign a part to spawn to the snake head");
        }

        positionsAfterTurn = new Queue <Vector3>();

        myRigidbody = GetComponent <Rigidbody2D>();
        myRenderer  = GetComponentInChildren <SpriteRenderer>();
        myLight     = GetComponentInChildren <Light2D>();


        if (speed < Mathf.Epsilon && editorSpeed > Mathf.Epsilon)
        {
            speed = editorSpeed / 2.0f;
        }


        if (front != null)
        {
            if (((snakeLength - 2) / 2) % 3 == 1)
            {
                foreach (Light2D light in GetComponentsInChildren <Light2D>())
                {
                    light.color = Color.HSVToRGB(316f / 360, 0.8f, 1);
                }
            }
            else if (((snakeLength - 2) / 2) % 3 == 2)
            {
                foreach (Light2D light in GetComponentsInChildren <Light2D>())
                {
                    light.color = Color.HSVToRGB(76f / 360, 0.8f, 1);
                }
            }
            else
            {
                foreach (Light2D light in GetComponentsInChildren <Light2D>())
                {
                    light.color = Color.HSVToRGB(196f / 360, 0.8f, 1);
                }
            }
        }
    }
コード例 #49
0
        protected override void Draw()
        {
            Camera.Update();

            if (LightsEnabled)
            {
                _krypton.Matrix = Camera.View;
                this._krypton.LightMapPrepare();
            }

            GraphicsDevice.Clear(new Color(240, 240, 240));

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Camera.View);

            foreach (var layer in Map.Layers.Where(p => p.Order <= ActiveLayer.Order).OrderBy(p => p.Order))
            {
                DrawLayer(layer);
            }

            _spriteBatch.End();

            if (LightsEnabled)
            {
                this._krypton.Draw();
            }

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Camera.View);

            ActiveTool.Draw(_spriteBatch, Camera, _currentMousePosition, _pixel);

            if (!mouseDown && _movingLight != null)
            {
                _movingLight = null;
            }

            foreach (Light2D light in _krypton.Lights)
            {
                if (light == SelectedLight)
                {
                    _spriteBatch.Draw(_selectionTexture, light.Position + new Vector2(1, -1), Color.White);
                }

                _spriteBatch.Draw(_lightSymbolTexture, light.Position /* - new Vector2(_lightSymbolTexture.Width / 2, _lightSymbolTexture.Height / 2)*/, Color.White);
            }

            _spriteBatch.End();
        }
コード例 #50
0
            static public void BumpedSprite(Light2D light, LightTilemapCollider2D id, Material material)
            {
                Texture bumpTexture = id.bumpMapMode.GetBumpTexture();

                if (bumpTexture == null)
                {
                    return;
                }

                material.SetTexture("_Bump", bumpTexture);

                Vector2 lightPosition = -light.transform.position;

                LightTilemapCollider.Base tilemapCollider = id.GetCurrentTilemap();

                if (id.superTilemapEditor.tilemap != null)
                {
                    if (id.superTilemapEditor.tilemap.Tileset != null)
                    {
                        material.mainTexture = id.superTilemapEditor.tilemap.Tileset.AtlasTexture;
                    }
                }

                material.SetPass(0);
                GL.Begin(GL.QUADS);

                foreach (LightingTile tile in id.superTilemapEditor.mapTiles)
                {
                    tile.UpdateTransform(tilemapCollider);

                    Vector2 tilePosition = tile.GetWorldPosition(tilemapCollider);
                    tilePosition += lightPosition;

                    if (tile.NotInRange(tilePosition, light.size))
                    {
                        continue;
                    }

                    Vector2 scale = tile.worldScale * 0.5f * tile.scale;

                    Rendering.Universal.Texture.DrawPassSTE(tilePosition, scale, tile.uv, tile.worldRotation, 0);
                }

                GL.End();

                material.mainTexture = null;
            }
コード例 #51
0
ファイル: PlayerManager.cs プロジェクト: Ranackk/Plokoth
    ////////////////////////////////////////////////////////////////

    IEnumerator C_FaceInLightForSaveParticleSystem()
    {
        Light2D light = m_CurrentSaveParticleSystem.GetComponentInChildren <Light2D>();

        float time         = 0.0f;
        float totalTime    = 0.7f;
        float maxIntensity = 1.1f;

        while (time < totalTime)
        {
            time += Time.deltaTime;

            light.intensity = (time / totalTime) * maxIntensity;

            yield return(new WaitForEndOfFrame());
        }
    }
コード例 #52
0
        private static MeshObject GetMeshPixelPerfect(Light2D light)
        {
            if (pixelPerfectMeshObject == null)
            {
                Camera camera = Camera.main;

                Rect rect = CameraTransform.GetWorldRect(camera);

                CalculatePoints();

                CalculateOffsets(rect.height * 1.1f / light.size);

                pixelPerfectMeshObject = GenerateMesh();
            }

            return(pixelPerfectMeshObject);
        }
コード例 #53
0
    void Awake()
    {
        _rigidbody = GetComponent <Rigidbody2D>();
        _animator  = GetComponent <Animator>();

        _maxSanity = sanity;

        _memorySpeed     = moveSpeed;
        _initialCooldown = dashCooldown;

        //Lights
        _pointLight        = transform.GetChild(0).gameObject;
        _light             = _pointLight.GetComponent <Light2D>();
        _maxLightIntensity = _light.intensity;
        _intensityLoss     = (_light.intensity - _minLightIntensity) / lightDurationInSeconds * lightFallOff;
        _targetMask        = LayerMask.GetMask("LightSource");
    }
コード例 #54
0
ファイル: BoomShroom.cs プロジェクト: Slawson91gd/MagicArrow
    // Start is called before the first frame update
    void Start()
    {
        MainLight     = transform.GetChild(0).gameObject;
        BulbLights    = new Light2D[9];
        BulbLights[0] = MainLight.transform.GetChild(0).GetComponent <Light2D>();
        BulbLights[1] = MainLight.transform.GetChild(1).GetComponent <Light2D>();
        BulbLights[2] = MainLight.transform.GetChild(2).GetComponent <Light2D>();
        BulbLights[3] = MainLight.transform.GetChild(3).GetComponent <Light2D>();
        BulbLights[4] = MainLight.transform.GetChild(4).GetComponent <Light2D>();
        BulbLights[5] = MainLight.transform.GetChild(5).GetComponent <Light2D>();
        BulbLights[6] = MainLight.transform.GetChild(6).GetComponent <Light2D>();
        BulbLights[7] = MainLight.transform.GetChild(7).GetComponent <Light2D>();
        BulbLights[8] = MainLight.transform.GetChild(8).GetComponent <Light2D>();
        lightState    = LightState.DIM;

        IdleSpores = transform.GetChild(1).gameObject.GetComponent <ParticleSystem>();
    }
コード例 #55
0
ファイル: Main.cs プロジェクト: takdw00/Project_Empty
        public static void Draw(Light2D light)
        {
            ShadowEngine.Prepare(light);

            LayerSetting[] layerSettings = light.GetLayerSettings();

            if (layerSettings == null)
            {
                return;
            }

            if (layerSettings.Length < 1)
            {
                return;
            }

            for (int layerID = 0; layerID < layerSettings.Length; layerID++)
            {
                LayerSetting layerSetting = layerSettings[layerID];

                if (layerSetting == null)
                {
                    continue;
                }

                if (pass.Setup(light, layerSetting) == false)
                {
                    continue;
                }

                ShadowEngine.SetPass(light, layerSetting);

                if (layerSetting.sorting == LightLayerSorting.None)
                {
                    NoSort.Draw(pass);
                }
                else
                {
                    pass.sortPass.SortObjects();

                    Sorted.Draw(pass);
                }
            }

            LightSource.Main.Draw(light);
        }
コード例 #56
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            go.AddOrGet <LoopingSounds>();
            Light2D light2D = go.AddOrGet <Light2D>();

            light2D.overlayColour = LIGHT2D.CEILINGLIGHT_OVERLAYCOLOR;
            light2D.Color         = new Color(0.5f, 0.5f, 0);
            light2D.Range         = 4f;
            light2D.Angle         = 0f;
            light2D.Direction     = LIGHT2D.FLOORLAMP_DIRECTION;
            light2D.Offset        = new Vector2(0f, 0.5f);
            light2D.shape         = LightShape.Circle;
            light2D.drawOverlay   = true;
            light2D.Lux           = 1800;
            BuildingTemplates.DoPostConfigure(go);
            go.GetComponent <KPrefabID>().prefabInitFn += game_object => new LightController.Instance(game_object.GetComponent <KPrefabID>()).StartSM();
        }
コード例 #57
0
    public static Light2D Create(Vector3 position, Material lightMaterial, Color lightColor, float lightRadius, float sweepStart, int sweepSize, LightDetailSetting detailSetting)
    {
        GameObject go = new GameObject("Created Light");

        go.transform.position = position;

        Light2D nLight = go.AddComponent <Light2D>();

        nLight.lightMaterial = lightMaterial;
        nLight.lightColor    = lightColor;
        nLight.lightRadius   = lightRadius;
        nLight.sweepStart    = sweepStart;
        nLight.sweepSize     = sweepSize;
        nLight.lightDetail   = detailSetting;

        return(nLight);
    }
コード例 #58
0
    private IEnumerator Start()
    {
        Light2D light = GetComponent <Light2D>();

        while (true)
        {
            float startIntensity  = light.intensity;
            float targetIntensity = Random.Range(minIntensity, maxIntensity);
            float targetTime      = Random.Range(minTime, maxTime);

            for (float t = 0; t < targetTime; t += Time.deltaTime)
            {
                light.intensity = Mathf.Lerp(startIntensity, targetIntensity, t / targetTime);
                yield return(null);
            }
        }
    }
コード例 #59
0
        static void CreateLight(MenuCommand menuCommand, string name, Light2D.LightType type)
        {
            GameObject go      = ObjectFactory.CreateGameObject(name, typeof(Light2D));
            Light2D    light2D = go.GetComponent <Light2D>();

            light2D.lightType = type;

            var parent = menuCommand.context as GameObject;

            Place(go, parent);

            Analytics.Light2DData lightData = new Analytics.Light2DData();
            lightData.was_create_event = true;
            lightData.instance_id      = light2D.GetInstanceID();
            lightData.light_type       = light2D.lightType;
            Analytics.Renderer2DAnalytics.instance.SendData(Analytics.AnalyticsDataTypes.k_LightDataString, lightData);
        }
コード例 #60
0
ファイル: FlickerLamp.cs プロジェクト: duriumm/Pixel-Game
    void Start()
    {
        //fireParticleEffect = this.gameObject.GetComponent<ParticleSystem>();
        torch2dLightComponent = this.gameObject.GetComponent <Light2D>();
        minOuterRadius        = torch2dLightComponent.pointLightOuterRadius - 0.05f;
        maxOuterRadius        = torch2dLightComponent.pointLightOuterRadius + 0.05f;

        minInnerRadius = torch2dLightComponent.pointLightInnerRadius - 0.05f;
        maxInnerRadius = torch2dLightComponent.pointLightInnerRadius + 0.05f;

        minIntensity = torch2dLightComponent.intensity - 0.02f;
        maxIntensity = torch2dLightComponent.intensity + 0.02f;



        InvokeRepeating("Flicker", 0.0f, 0.2f);
    }