Beispiel #1
0
        public void Initialize(int _aeID, InfoSystem _is, MapSystem _ms)
        {
            aeID       = _aeID;
            infoSystem = _is;
            mapSystem  = _ms;
            compDisp.Clear();

            AssignmentEntity myEntity = mapSystem.assignmentEntityDictionary[aeID];

            transform.parent        = mapSystem.coordinate;//mapSystem.floorList[myEntity.floor - 1].transform;
            transform.localPosition = myEntity.pos;

            SpriteRenderer sr = GetComponentInChildren <SpriteRenderer>();

            if (myEntity.aeType == AEType.computer)
            {
                sr.size = new Vector2(myEntity.radius, myEntity.radius) * 2;
                GetComponentInChildren <CircleCollider2D>().radius = myEntity.radius;
            }
            else
            {
                transform.rotation = Quaternion.Euler(new Vector3(0, 0, myEntity.theta));
                sr.size            = new Vector2(myEntity.radius, sr.size.y);
                GetComponentInChildren <BoxCollider2D>().size = sr.size;
            }

            mapSystem.currentFloor.AsObservable()
            .Subscribe(f => {
                Vector2 targetScale = InCurrentFloor() ? new Vector2(1, 1) : Vector2.zero;
                Ease ease           = InCurrentFloor() ? Ease.OutBack : Ease.InBack;
                transform.DOScale(targetScale, .3f)
                .SetEase(ease);
            }).AddTo(compDisp);

            mapSystem.SubjectAssignmentEntityModified.AsObservable()
            .Where(id => id == aeID)
            .Subscribe(id => {
                Initialize(id, infoSystem, mapSystem);
            }).AddTo(compDisp);

            selected.AsObservable()
            .Where(flag => flag)
            .Subscribe(flag => {
                mapSystem.SetCurrentFloor(mapSystem.assignmentEntityDictionary[aeID].floor);
                mapSystem.SelectAssignmentEntityRenderer(this);
            }).AddTo(compDisp);

            infoSystem.SubjectQueriedAssignmentsChanged.AsObservable()
            .Subscribe(l =>
            {
                bool flag = false;
                foreach (int _id in l)
                {
                    if (myEntity.assignmentIDList.Contains(_id))
                    {
                        flag = true;
                        break;
                    }
                }
                queried.Value = flag;
            }).AddTo(compDisp);

            infoSystem.SelectedAssignmentID.AsObservable()
            .Subscribe(_id =>
            {
                selected.Value = myEntity.assignmentIDList.Contains(_id);
            }).AddTo(compDisp);
        }