Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using Assets.Library.Spood.Lib.Interfaces;
  2. using UnityEngine;
  3. using UnityEngine.Experimental.U2D;
  4. using UnityEngine.UIElements;
  5. using Zenject;
  6.  
  7. namespace Assets.Spood.Behaviours.Views
  8. {
  9.     public class BackgroundNightMode : MonoBehaviour
  10.     {
  11.         private IBackground _background;
  12.  
  13.         private bool _isNight = false;
  14.  
  15.         [Inject]
  16.         void Construct(DiContainer container)
  17.         {
  18.             _background = container.ResolveId<IBackground>(Constants.Background.MountainBackgroundId);
  19.         }
  20.  
  21.         // Update is called once per frame
  22.         void Update()
  23.         {
  24.             if (Input.GetMouseButtonUp((int) MouseButton.LeftMouse))
  25.             {
  26.                 if (_isNight)
  27.                 {
  28.                     _background.GameObject.GetComponent<SpriteShapeRenderer>().color = Color.white;
  29.                     _isNight = false;
  30.                 }
  31.                 else
  32.                 {
  33.                     _background.GameObject.GetComponent<SpriteShapeRenderer>().color = Color.gray;
  34.                     _isNight = true;
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement