void Awake()
    {
        if (lightDefaltIntensity == LightDefaltIntensity.fullStrenght)
        {
            defaltIntensity = maxIntensity;
        }
        else if (lightDefaltIntensity == LightDefaltIntensity.randomHighIntensity)
        {
			defaltIntensity = (float)((randomGen.Next(100) * 0.01) * maxIntensity * .5 + maxIntensity * .5);
        }
        else if (lightDefaltIntensity == LightDefaltIntensity.randomLowIntensity)
        {
            defaltIntensity = (float)((randomGen.Next(100) * 0.01) * maxIntensity * .5);
        }
        else if (lightDefaltIntensity == LightDefaltIntensity.off)
        {
            defaltIntensity = 0;
        }

        if (lightType == LightType.emissiveLight && pointLight != null)
        {
            pointLight.intensity = 0;
        } else if (lightType == LightType.pointLight && pointLight != null)
        {
            pointLight.enabled = true;
            pointLight.gameObject.SetActive(true);
        }
        if (powerProviderObject != null)
        {
            powerProvider = powerProviderObject.GetComponent<PowerProvider>();
            powerProvider.sendReference(this);
        }
       
    }
	// Use this for initialization
	void Start () {
//		fadeEmission = GetComponent<FadeEmission> ();
//		if (fadeEmission == null) {
//			fadeEmission = gameObject.AddComponent<FadeEmission> ();
//		}
		if (LerpCoroutine.currentInstance == null)
		{
			LerpCoroutine lerpCoroutine = gameObject.AddComponent<LerpCoroutine>();
			lerpCoroutine.Awake();
		}
//		if (Application.isEditor) {
//			StartCoroutine (checkIfPowered ());
//		}
		powerProvider = powerProviderObject.GetComponent<PowerProvider> ();
		powerProvider.sendReference (this);
		Material[] materials = objectRenderer.materials;
		if (materials.Length >= 2) {
			mat = materials [1];
		} else {
			mat = objectRenderer.material;
		}
		baseColor = mat.GetColor ("_EmissionColor");
		mat.SetVector ("_WireStart", startPoint.position);
		mat.SetFloat ("_Distance", 0);
		DynamicGI.UpdateMaterials (objectRenderer);
	}
	public override void powerOff(PowerProvider reference) {
		for (int i = 0; i < doorLocks.Length; i++) {
			if (doorLocks [i].reference == reference) {
				changeLockPowerState (i, false);
				break;
			}
		}
	}
Example #4
0
	// Use this for initialization
	public virtual void Start () {
		animator = GetComponent<Animator> ();
		animator.SetBool ("DoorUnlocked",true);
		if (powerProviderGameObject != null) {
			powerProvider = powerProviderGameObject.GetComponent<PowerProvider> ();
			if (powerProvider != null) {
				powerProvider.sendReference (this);
				animator.SetBool ("DoorUnlocked",false);
			}
		}
	}
Example #5
0
	// Use this for initialization
	void Start () {
		powerProvider = powerProviderGameObject.GetComponent<PowerProvider> ();
		powerProvider.sendReference (this);
		startPoint = startingPoint.position;
		endPoint = transform.position;
		if (LerpCoroutine.currentInstance == null)
		{
			LerpCoroutine lerpCoroutine = gameObject.AddComponent<LerpCoroutine>();
			lerpCoroutine.Awake();
		}
		changePosition (0);
	}
Example #6
0
        /// <summary>
        /// 获得某个角色分配的权限
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPower()
        {
            string                   CompanyID  = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            string                   RoleNum    = WebUtil.GetFormValue <string>("RoleNum", string.Empty);
            PowerProvider            provider   = new PowerProvider(CompanyID);
            List <SysResourceEntity> listResult = provider.GetRoleResource(RoleNum);
            DataResult <List <SysResourceEntity> > dataResult = new DataResult <List <SysResourceEntity> >()
            {
                Code    = (int)EResponseCode.Success,
                Message = "响应成功",
                Result  = listResult
            };

            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Example #7
0
        public ActionResult Save([ModelBinder(typeof(JsonBinder <List <string> >))] List <string> List, string roleNum)
        {
            PowerProvider provider = new PowerProvider();
            int           line     = provider.AllotPower(roleNum, List);

            if (line > 0)
            {
                this.ReturnJson.AddProperty("d", "success");
            }
            else
            {
                this.ReturnJson.AddProperty("d", "");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Example #8
0
    public void powerOff(PowerProvider reference) {
		if (reference != null) {
			int numOn = 0;
			for (int i = 0; i < doorLocks.Length; i++) {
				if (doorLocks [i].reference == reference) {
					changeLockPowerState (i, false);
				}
				if (doorLocks [i].isPowered) {
					numOn++;
				}
			}
			if (roomLights != null) {
				roomLights.powerOff (numOn / doorLocks.Length);
			}
		}
    }
	// Use this for initialization
	void Start () {
		AllRooms.Add (this);
        lightStripObjects = GetComponentsInChildren<LightStripController>();
        List<List<LightStripController>> lightStripGroups = new List<List<LightStripController>>(20);
        int numberOfGroups = 0;
        for (int i = 0; i < lightStripObjects.Length; i++)
        {
            bool spotFound = false; ;
            LightInfo lightInfo = lightStripObjects[i].getLightInfo();
            for (int j = 0; j < lightStripGroups.Count; j++)
            {
                LightInfo groupLightInfo = lightStripGroups[j][0].getLightInfo();
                if (groupLightInfo.color == lightInfo.color && groupLightInfo.defaltIntensity == lightInfo.defaltIntensity && groupLightInfo.maxIntensity == lightInfo.maxIntensity)
                {
                    lightStripGroups[j].Add(lightStripObjects[i]);
                    spotFound = true;
                    break;
                }
            }
            if (!spotFound)
            {
                lightStripGroups.Add(new List<LightStripController>());
                lightStripGroups[lightStripGroups.Count-1].Add(lightStripObjects[i]);
                numberOfGroups++;
            }
        }

        lightGroups = new FadeEmissionLightGroup[lightStripGroups.Count];
        for (int i = 0; i < lightGroups.Length; i++)
        {
            lightGroups[i] = new FadeEmissionLightGroup();
            LightInfo lightInfo = lightStripGroups[i][0].getLightInfo();
            lightGroups[i].setup(lightStripGroups[i].ToArray(), lightInfo, this, animationLength);
        }

        if (LerpCoroutine.currentInstance == null)
        {
            LerpCoroutine lerpCoroutine = gameObject.AddComponent<LerpCoroutine>();
            lerpCoroutine.Awake();
        }

        if (powerProviderObject != null)
        {
            powerProvider = powerProviderObject.GetComponent<PowerProvider>();
            powerProvider.sendReference(this);
        }
	}
Example #10
0
        /// <summary>
        /// 根据登录用的角色加载菜单信息
        /// </summary>
        private void SetMenu()
        {
            StringBuilder sb = new StringBuilder();

            if (IsLogin() && !this.LoginUser.RoleNum.IsEmpty())
            {
                PowerProvider            provider = new PowerProvider();
                List <SysResourceEntity> list     = provider.GetAllotedPower(this.LoginUser.RoleNum);

                if (!list.IsNullOrEmpty())
                {
                    foreach (SysResourceEntity parent in list.Where(a => a.ParentNum.IsEmpty()))
                    {
                        StringBuilder sbChild = new StringBuilder();
                        sbChild.AppendFormat("<ul class=\"sub\">");
                        bool flag   = false;
                        bool exists = false;
                        var  tl     = list.Where(a => a.ParentNum == parent.ResNum).OrderBy(p => p.ResNum);
                        foreach (SysResourceEntity child in tl)
                        {
                            flag = child.Url.ToLower() == this.Path.ToLower() ||
                                   (!child.Children.IsNullOrEmpty() && child.Children.Exists(c => c.Url.ToLower() == this.Path.ToLower()))
                            ;
                            if (flag)
                            {
                                exists = true;
                            }


                            sbChild.AppendFormat("<li {0}><a href=\"{1}\">{2}</a></li>", flag ? "class=\"active\"" : "", child.Url.IsEmpty() ? "javascript:void(0)" : child.Url, child.ResName);
                        }
                        sbChild.AppendFormat("</ul>");

                        sb.AppendFormat("<li class=\"has-sub {0}\">", exists ? "active" : "");
                        sb.AppendFormat("<a href=\"javascript:void(0);\">");
                        sb.AppendFormat("<i class=\"{0}\"></i>", parent.CssName.IsEmpty() ? "icon-bookmark-empty" : parent.CssName);
                        sb.AppendFormat("<span class=\"title\">{0}</span>", parent.ResName);
                        sb.AppendFormat("<span class=\"arrow {0}\"></span>", exists ? "open" : "");
                        sb.AppendFormat("</a>");
                        sb.Append(sbChild.ToString());
                        sb.AppendFormat("</li>");
                    }
                }
            }
            ViewBag.MenuItems = sb.ToString();
        }
Example #11
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //AdminEntity LoginUser = filterContext.HttpContext.Session[CacheKey.SESSION_LOGIN_ADMIN] as AdminEntity;
            ////如果是未登陆则跳转到登陆页面
            //if (LoginUser == null)
            //{
            //    string path = GetPath(filterContext);
            //    string url = "/Home/Index";
            //    if (!path.IsEmpty())
            //    {
            //        path = filterContext.HttpContext.Server.UrlEncode(path);
            //        url = "/Home/Index?returnurl=" + path;
            //    }
            //    filterContext.Result = new RedirectResult(url);
            //}

            if (this.ValidateLogin)
            {
                AdminEntity LoginUser = filterContext.HttpContext.Session[CacheKey.SESSION_LOGIN_ADMIN] as AdminEntity;
                string      path      = filterContext.HttpContext.Request.Path;
                if (LoginUser.IsNull())
                {
                    string url = "/Home/Index";
                    if (!path.IsEmpty())
                    {
                        path = filterContext.HttpContext.Server.UrlEncode(path);
                        url  = "/Home/Index?returnurl=" + path;
                    }
                    filterContext.Result = new RedirectResult(url);
                }
                else
                {
                    if (ValidateRequest && path != "/")
                    {
                        PowerProvider provider = new PowerProvider();
                        bool          hasPower = provider.HasPower(path, LoginUser.RoleNum);
                        if (!hasPower)
                        {
                            string url = "/Home/Error";
                            filterContext.Result = new RedirectResult(url);
                        }
                    }
                }
            }
        }
Example #12
0
        public ActionResult GetTreeSource()
        {
            string        RoleNum  = WebUtil.GetFormValue <string>("RoleNum", this.LoginUser.RoleNum);
            PowerProvider provider = new PowerProvider();
            Params <List <SysResourceEntity>, List <SysResourceEntity>, List <SysResourceEntity> > param = provider.GetRole(RoleNum);
            List <SysResourceEntity> listAlloted    = null;
            List <SysResourceEntity> listNotAlloted = null;
            List <SysResourceEntity> listSource     = null;

            listSource     = param.Item1;
            listAlloted    = param.Item2;
            listNotAlloted = param.Item3;
            listSource     = listSource.IsNull() ? new List <SysResourceEntity>() : listSource;
            listAlloted    = listAlloted.IsNull() ? new List <SysResourceEntity>() : listAlloted;
            listNotAlloted = listNotAlloted.IsNull() ? new List <SysResourceEntity>() : listNotAlloted;
            this.ReturnJson.AddProperty("ListNotAlloted", ConvertJson.ListToJson <SysResourceEntity>(listNotAlloted));
            this.ReturnJson.AddProperty("ListAlloted", ConvertJson.ListToJson <SysResourceEntity>(listAlloted));
            return(Content(this.ReturnJson.ToString()));
        }
Example #13
0
        /// <summary>
        /// 保存权限分配
        /// </summary>
        /// <returns></returns>
        public ActionResult SavePower()
        {
            string        CompanyID  = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            string        RoleNum    = WebUtil.GetFormValue <string>("RoleNum", string.Empty);
            List <string> listItems  = WebUtil.GetFormObject <List <string> >("List");
            PowerProvider provider   = new PowerProvider(CompanyID);
            int           line       = provider.AllotPower(RoleNum, listItems);
            DataResult    dataResult = new DataResult();

            if (line > 0)
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "权限分配成功";
            }
            else
            {
                dataResult.Code    = (int)EResponseCode.Exception;
                dataResult.Message = "权限分配失败";
            }
            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Example #14
0
        /// <summary>
        /// 判断是否有权限
        /// </summary>
        /// <returns></returns>
        public ActionResult HasPower()
        {
            string        CompanyID  = WebUtil.GetFormValue <string>("CompanyID", string.Empty);
            string        RoleNum    = WebUtil.GetFormValue <string>("RoleNum", string.Empty);
            string        ResNum     = WebUtil.GetFormValue <string>("ResNum", string.Empty);
            PowerProvider provider   = new PowerProvider(CompanyID);
            bool          hasPower   = provider.HasPower(ResNum, RoleNum);
            DataResult    dataResult = new DataResult();

            if (hasPower)
            {
                dataResult.Code    = (int)EResponseCode.Success;
                dataResult.Message = "验证有权限";
            }
            else
            {
                dataResult.Code    = (int)EResponseCode.Exception;
                dataResult.Message = "验证无权限";
            }
            return(Content(JsonHelper.SerializeObject(dataResult)));
        }
Example #15
0
	public void powerOn (PowerProvider reference) {
        //fadeEmission.turnOn ();
        //ConnectedObject.powerOn (this);

        powered = true;
//        for (int i = 0; i < lightGroups.Length; i++)
//        {
//            changeLightState(i, true);
//        }

		if (currentCoroutine != null) {
			LerpCoroutine.stopCoroutine (currentCoroutine);
		}
		currentCoroutine = LerpCoroutine.LerpMinToMax(animationLength,0,1,coroutineCurrentPoint,changeAllLights,false);

        if (ConnectedObject != null)
        {
        ConnectedObject.powerOn(this);
        }

	}
Example #16
0
	public void powerOn (PowerProvider reference){
		if (!isPowered) {
			isPowered = true;
			LerpCoroutine.LerpMinToMax(Vector3.Distance(startPoint.position,endPoint.position)*speed,0,
				Vector3.Distance(startPoint.position,endPoint.position),currentPoint,changeWireDistance,false);
			//fadeEmission.turnOn ();
			//coroutine = StartCoroutine(waitForFullEmission());
		}
	}
Example #17
0
	public void powerOff (PowerProvider reference){
		if (isPowered) {
			StopCoroutine (coroutine);
			isPowered = false;
			changeWireDistance (0);
//			fadeEmission.turnOff ();
//			if (connectedObject != null) {
//				connectedObject.powerOff (this);
//			}
		}
	}
Example #18
0
	// Use this for initialization
	void Start () {
		powerProvider = powerProviderGameObject.GetComponent<PowerProvider> ();
		powerProvider.sendReference (this);
	}
Example #19
0
	public void powerOff(PowerProvider provider) {
		changePower(new float[]{GetInstanceID(),1});
	}
Example #20
0
        /// <summary>
        /// 设置导航信息
        /// </summary>
        private void SetNav()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<ul class=\"breadcrumb\">");
            sb.Append("<li>");
            sb.Append("<i class=\"icon-home\"></i>");
            sb.Append("<a href=\"/Home/Welcome\">首页</a>");
            sb.Append("<i class=\"icon-angle-right\"></i>");
            sb.Append("</li>");
            if (IsLogin() && !this.LoginUser.RoleNum.IsEmpty())
            {
                PowerProvider            provider            = new PowerProvider();
                SysResourceProvider      SysResourceProvider = new SysResourceProvider();
                List <SysResourceEntity> listSource          = SysResourceProvider.GetList();
                List <SysResourceEntity> list = provider.GetRoleResource(this.LoginUser.RoleNum);
                if (!list.IsNullOrEmpty())
                {
                    SysResourceEntity        item       = list.SingleOrDefault(a => a.Url.ToLower() == this.Path.ToLower());
                    List <SysResourceEntity> listResult = new List <SysResourceEntity>();
                    while (item != null)
                    {
                        listResult.Insert(0, item);

                        if (item.ParentNum.IsEmpty())
                        {
                            break;
                        }
                        else
                        {
                            if (listSource.Exists(a => a.ResNum == item.ParentNum))
                            {
                                item = listSource.First(a => a.ResNum == item.ParentNum);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    for (int i = 0; i < listResult.Count; i++)
                    {
                        if (i != listResult.Count - 1)
                        {
                            sb.Append("<li>");
                            sb.AppendFormat("<a href=\"{0}\">{1}</a>", listResult[i].Url.IsEmpty() ? "javascript:void(0)" : listResult[i].Url, listResult[i].ResName);
                            sb.Append("<i class=\"icon-angle-right\"></i>");
                            sb.Append("</li>");
                        }
                        else
                        {
                            sb.Append("<li>");
                            sb.AppendFormat("<a href=\"javascript:void(0)\">{0}</a>", listResult[i].ResName);
                            sb.Append("</li>");
                        }
                    }
                }
            }
            sb.Append("</ul>");
            ViewBag.NavMenu = sb.ToString();
        }
Example #21
0
 public void powerOff(PowerProvider powerProvider)
 {
     powered = false;
     setColorAndIntensity(color, defaltIntensity);
     if (connectedObject != null)
     {
     connectedObject.powerOff(this);
     }
 }
Example #22
0
    public void powerOn(PowerProvider powerProvider)
    {

        powered = true;
        setColorAndIntensity(Color.white, maxIntensity);
        if (connectedObject != null)
        {
        connectedObject.powerOn(this);
        }
    }  
Example #23
0
	public virtual void powerOff (PowerProvider reference) {
		animator.SetBool ("DoorUnlocked",false);
	}
 public override void CompPostMake()
 {
     _provider = new PowerProvider(Props.maxEnergy, Props.maxRate, Props.maxEnergy, this);
     ConnectTo(parent.pawn.AllComps.OfType <IEnergyNet>().First());
 }