Exemplo n.º 1
0
 //отсылает модель в форму
 public void Init(MainForm form, CrossRoadModel model)
 {
     _form  = form;
     _model = model;
     form.ShowCrossRoadList(model.CrossRoads);
     form.AddItem    += new Action(form_AddItem);
     form.DeleteItem += new Action <CrossRoad>(form_DeleteItem);
     form.EditItem   += new Action <CrossRoad>(form_EditItem);
 }
    public void FindMyNeighbours()
    {
        if (nextElement == null)
        {
            GameObject myNeighbourForward = ElementTable.MyClosestNeighbour(this.gameObject, this.transform.forward * 5);

            NextElement = myNeighbourForward;

            if (myNeighbourForward.tag.Equals("RoadModel"))
            {
                RoadElementModel component = myNeighbourForward.GetComponent <RoadElementModel>();

                if (component.PreviousElement == null)
                {
                    component.PreviousElement = this.gameObject;
                }
                component.FindMyNeighbours();
            }

            if (myNeighbourForward.tag.Equals("CrossRoad"))
            {
                CrossRoadModel component = myNeighbourForward.GetComponent <CrossRoadModel>();

                if (component.ClosestRoad == null)
                {
                    component.ClosestRoad = this.gameObject;
                }

                component.FindMyNeighbours();
            }
        }

        if (previousElement == null)
        {
            GameObject myNeighbourBackward = ElementTable.MyClosestNeighbour(this.gameObject, (-1) * this.transform.forward * 5);

            PreviousElement = myNeighbourBackward;

            if (myNeighbourBackward.tag.Equals("RoadModel"))
            {
                RoadElementModel component = myNeighbourBackward.GetComponent <RoadElementModel>();

                if (component.NextElement == null)
                {
                    component.NextElement = this.gameObject;
                }
                component.FindMyNeighbours();
            }

            if (myNeighbourBackward.tag.Equals("CrossRoad"))
            {
                CrossRoadModel component = myNeighbourBackward.GetComponent <CrossRoadModel>();

                if (component.ClosestRoad == null)
                {
                    component.ClosestRoad = this.gameObject;
                }

                component.FindMyNeighbours();
            }
        }
    }