Ejemplo n.º 1
0
        public void CreateNew(AEType _type)
        {
            AssignmentEntity newEntity = new AssignmentEntity();
            int newID = 1000;

            while (mapSystem.assignmentEntityDictionary.ContainsKey(newID))
            {
                newID++;
            }
            newEntity.aeID   = newID;
            newEntity.aeType = _type;
            newEntity.floor  = mapSystem.currentFloor.Value;
            newEntity.pos    = Vector2.zero;
            newEntity.radius = .5f;
            newEntity.theta  = 0;

            mapSystem.assignmentEntityDictionary.Add(newEntity.aeID, newEntity);

            AssignmentEntityRenderer newRenderer = _type == AEType.computer ?
                                                   GameObject.Instantiate(assCompPrefab, mapSystem.coordinate) :
                                                   GameObject.Instantiate(assWallPrefab, mapSystem.coordinate);

            newRenderer.Initialize(newEntity.aeID, infoSystem, mapSystem);

            mapSystem.SelectAssignmentEntityRenderer(newRenderer);
        }
Ejemplo n.º 2
0
        public List <AssignmentEntity> ParseXML(string text)
        {
            List <AssignmentEntity> result = new List <AssignmentEntity>();

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(text);

            XmlNode     root = xmlDoc.SelectSingleNode("AssignmentEntities");
            XmlNodeList assignmentEntities = root.SelectNodes("AssignmentEntity");

            foreach (XmlNode node in assignmentEntities)
            {
                AssignmentEntity newAE = new AssignmentEntity();
                newAE.aeID   = XmlParser.IntParseNode(node, "@id");
                newAE.aeType = XmlParser.StringParseNode(node, "@type").Equals("computer") ? AEType.computer : AEType.wall;
                newAE.floor  = XmlParser.IntParseNode(node, "floor");
                newAE.pos    = new Vector2(XmlParser.FloatParseNode(node, "shape/point/@x"), XmlParser.FloatParseNode(node, "shape/point/@y"));
                newAE.radius = XmlParser.FloatParseNode(node, "shape/radius/@r");
                if (newAE.aeType == AEType.wall)
                {
                    newAE.theta = XmlParser.FloatParseNode(node, "shape/theta/@t");
                }
                XmlNodeList asss = node.SelectNodes("assignments/assignment");
                foreach (XmlNode ass in asss)
                {
                    newAE.assignmentIDList.Add(XmlParser.IntParseNode(ass, "@id"));
                }
                result.Add(newAE);
            }
            return(result);
        }
Ejemplo n.º 3
0
        void Start()
        {
            SelectedAssignmentID.AsObservable()
            .Subscribe(id => {
                showDetail.Value = id >= 0;
            });
            InfoCardSelected(-1);

            tagSelector.tagMask.AsObservable()
            .Subscribe(mask => UpdateQueried(QueryDefault(mask)));

            listByName.AsObservable()
            .Subscribe(byName => {
                if (!byName)
                {
                    UpdateQueried(QueryDefault(tagSelector.tagMask.Value));
                }
                else
                {
                    Search();
                }
            });

            queriedByEntity.AsObservable()
            .Where(flag => !flag)
            .Subscribe(flag => {
                if (!listByName.Value)
                {
                    UpdateQueried(QueryDefault(tagSelector.tagMask.Value));
                }
                else
                {
                    Search();
                }
            });

            searchInputField.onEndEdit
            .AddListener((s) => Search());

            mapSystem.SubjectAssignmentEntityRendererClicked.AsObservable()
            .Subscribe(ent => {
                AssignmentEntity entity = mapSystem.assignmentEntityDictionary[ent.aeID];
                UpdateQueried(QueryByList(entity.assignmentIDList));
            });
        }
Ejemplo n.º 4
0
        public void InstEntityRenderers()
        {
            AssignmentEntityRenderer newAERenderer;

            foreach (KeyValuePair <int, AssignmentEntity> kv in assignmentEntityDictionary)
            {
                AssignmentEntity ae = kv.Value;

                if (ae.aeType == AEType.computer)
                {
                    newAERenderer = GameObject.Instantiate(assCompPrefab);
                }
                else
                {
                    newAERenderer = GameObject.Instantiate(assWallPrefab);
                }
                newAERenderer.Initialize(kv.Key, infoSystem, this);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        protected void LoadAssEntity(AssignmentEntityRenderer entityRenderer)
        {
            Debug.Log("dd");
            compDisp.Clear();

            currentRenderer = entityRenderer;
            currentEntity   = entityRenderer.mapSystem.assignmentEntityDictionary[entityRenderer.aeID];
            id.text         = currentEntity.aeID.ToString();
            floor.text      = currentEntity.floor.ToString();
            rad.text        = currentEntity.radius.ToString();
            rot.text        = currentEntity.theta.ToString();
            posX.text       = currentEntity.pos.x.ToString();
            posY.text       = currentEntity.pos.y.ToString();
            string a = "";

            foreach (int i in currentEntity.assignmentIDList)
            {
                a += i + " ";
            }
            assignments.text = a;

            Observable
            .CombineLatest(posX.ObserveEveryValueChanged(__ => __.text), posY.ObserveEveryValueChanged(__ => __.text))
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.VALUES)
            .Subscribe(_pos => {
                float pos0, pos1;
                bool canParse;
                canParse = float.TryParse(_pos[0], out pos0);
                canParse = float.TryParse(_pos[1], out pos1) && canParse;
                if (canParse)
                {
                    currentRenderer.transform.localPosition = new Vector2(pos0, pos1);
                }
            }).AddTo(compDisp);

            rot.ObserveEveryValueChanged(__ => __.text)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.VALUES)
            .Subscribe(_rot => {
                float rotOut;
                if (float.TryParse(_rot, out rotOut))
                {
                    currentRenderer.transform.rotation = Quaternion.Euler(0, 0, rotOut);
                }
            });

            rad.ObserveEveryValueChanged(__ => __.text)
            .Where(__ => currentRenderer.myType == AEType.wall)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.VALUES)
            .Subscribe(_rad => {
                float radOut;
                if (float.TryParse(_rad, out radOut))
                {
                    currentRenderer.GetComponentInChildren <SpriteRenderer>().size =
                        new Vector2(radOut, currentRenderer.GetComponentInChildren <SpriteRenderer>().size.y);
                }
            });

            rad.ObserveEveryValueChanged(__ => __.text)
            .Where(__ => currentRenderer.myType == AEType.computer)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.VALUES)
            .Subscribe(_rad => {
                float radOut;
                if (float.TryParse(_rad, out radOut))
                {
                    currentRenderer.GetComponentInChildren <SpriteRenderer>().size =
                        new Vector2(radOut, radOut) * 2;
                }
            });

            entityRenderer.ObserveEveryValueChanged(__ => __.transform.localPosition)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.TRANSFORM)
            .Subscribe(pos => {
                posX.text = pos.x.ToString();
                posY.text = pos.y.ToString();
            }).AddTo(compDisp);

            entityRenderer.ObserveEveryValueChanged(__ => __.transform.localEulerAngles)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.TRANSFORM)
            .Subscribe(_rot => {
                rot.text = _rot.z.ToString();
            }).AddTo(compDisp);

            currentRenderer.GetComponentInChildren <SpriteRenderer>().ObserveEveryValueChanged(__ => __.size)
            .Where(__ => editorSystem.currentMode.Value == EditorSystem.EditMode.TRANSFORM)
            .Subscribe(_size => {
                rad.text = _size.x.ToString();
            }).AddTo(compDisp);
        }