Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetMouseButtonUp(0) && !isMarker)
        {
            if (currentConnectionUI && currentConnectionUI.hasTrap)
            {
                EventBus.PublishEvent(new TrapAlreadyExistsHereEvent());
            }

            // if (currentConnectionUI && currentConnectionUI.activeConnection)
            if (CanPlaceAtConnection(currentConnectionUI))
            {
                currentConnectionUI.hasTrap = true;
                Vector3 trapPosition = currentConnectionUI.GetTrapPosition();
                trap = Instantiate(itemPrefab, trapPosition, GetItemQuaternion());
                trap.GetComponent <Trap>().SetTendril(currentConnectionUI.tendril);
                MoneyManager.Instance.RemoveMoney(itemPrefab.GetComponent <PurchasableObject>().cost);
                isMarker = true;
                StartCoroutine(ShrinkIcon());
                trapOwningConnection = currentConnectionUI;
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Ejemplo n.º 2
0
 public void PrintProject()
 {
     foreach (Connection connection in Model.Connections)
     {
         //ConnectionCreator.AddActor(conne)
         ConnectionUI conn = new ConnectionUI(this.Model, this.target, connection, this.ConnectionCreator);
         this.ConnectionCreator.ConnectionDictionary.Add(connection, conn);
         conn.PrintOnTarget();
     }
     foreach (Shop shopModel in Model.Shops)
     {
         ShopUserControl shopUserControl = new ShopUserControl(shopModel, Model, ConnectionCreator);
         shopUserControl.printOnTarget(this.target);
     }
     foreach (Buyer buyerModel in Model.Buyers)
     {
         BuyerUserControl buyerUserControl = new BuyerUserControl(buyerModel, Model, ConnectionCreator);
         buyerUserControl.printOnTarget(this.target);
     }
     foreach (Supplier supplierModel in Model.Suppliers)
     {
         SupplierUserControl supplierUserControl = new SupplierUserControl(supplierModel, Model, ConnectionCreator);
         supplierUserControl.printOnTarget(this.target);
     }
 }
Ejemplo n.º 3
0
    void InitializeConnection()
    {
        levelCreationCanvas = GameObject.Find("LevelCreationUI").GetComponent <Canvas>();

        if (tendrilImage == null)
        {
            tendrilImage = Instantiate(Resources.Load("ConnectionImg") as GameObject).GetComponent <Image>();
            tendrilImage.rectTransform.SetParent(GameObject.Find("AxonContainer").transform);
        }

        ConnectionUI connUI = tendrilImage.gameObject.GetComponent <ConnectionUI>();

        connUI.connection = this;
        connUI.tendril    = GetTendril();

        Vector3 pos1 = Camera.main.WorldToViewportPoint(node1.transform.position);
        Vector3 pos2 = Camera.main.WorldToViewportPoint(node2.transform.position);

        pos1Canvas = new Vector2(pos1.x * levelCreationCanvas.pixelRect.width, pos1.y * levelCreationCanvas.pixelRect.height);

        float canvasDistX = (pos2.x - pos1.x) * levelCreationCanvas.pixelRect.width;
        float canvasDistY = (pos2.y - pos1.y) * levelCreationCanvas.pixelRect.height;

        length = Mathf.Sqrt(Mathf.Pow(canvasDistX, 2) + Mathf.Pow(canvasDistY, 2));
        float rads = Mathf.Atan2(canvasDistY, canvasDistX);

        tendrilImage.rectTransform.anchoredPosition = new Vector2((pos1.x - .5f) * levelCreationCanvas.pixelRect.width + length * Mathf.Cos(rads) / 2,
                                                                  (pos1.y - .5f) * levelCreationCanvas.pixelRect.height + length * Mathf.Sin(rads) / 2);
        tendrilImage.rectTransform.sizeDelta = new Vector2(length, tendrilImage.rectTransform.sizeDelta.y);
        tendrilImage.rectTransform.rotation  = Quaternion.Euler(0, 0, rads * Mathf.Rad2Deg);

        Image tendrilChild = tendrilImage.transform.GetChild(0).GetComponent <Image>();

        tendrilChild.rectTransform.sizeDelta = new Vector2(length, 60);
    }
Ejemplo n.º 4
0
 bool CanPlaceAtConnection(ConnectionUI connectionUI)
 {
     return(connectionUI &&
            !connectionUI.hasTrap &&
            connectionUI.tendril.isTraversable &&
            MoneyManager.Instance.CanAfford(itemPrefab.GetComponent <PurchasableObject>().cost));
 }
Ejemplo n.º 5
0
        public void RemoveConnection(ConnectionUI connection)
        {
            _connections.Remove(connection);
            _connectionPanel.Controls.Remove(connection);

            SaveAllDumps();
            ReOrder();
        }
Ejemplo n.º 6
0
 public void HandleActiveSegmentHoveredEvent(ActiveSegmentHoveredEvent e)
 {
     currentConnectionUI = e.connectionUI;
     if (!isMarker && CanPlaceAtConnection(e.connectionUI))
     {
         img.color = Color.yellow;
     }
 }
Ejemplo n.º 7
0
        public void CreateEmptyConnection(object sender, MouseEventArgs args)
        {
            var ui = new ConnectionUI(new ConnectionModel());

            _connections.Add(ui);

            _connectionPanel.Controls.Add(ui);

            ReOrder();
        }
        public void CreateConnectionIfPossible()
        {
            ConnectionUI connectionUI;
            Connection   conn;

            if (ActorA != null && ActorB != null)
            {
                switch (ActorA.GetUserControlType())
                {
                case EnumTypes.UserControlTypes.ShopUserControl:
                    ShopUserControl ShopA = (ShopUserControl)ActorA;
                    switch (ActorB.GetUserControlType())
                    {
                    case EnumTypes.UserControlTypes.ShopUserControl:
                        ShopUserControl ShopB = (ShopUserControl)ActorB;
                        conn         = new Connection(ShopA.ShopModel, ShopB.ShopModel, EnumTypes.ConnectionTypes.ShopToShop);
                        connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                        ConnectionDictionary.Add(conn, connectionUI);
                        this.Model.Connections.Add(conn);
                        connectionUI.PrintOnTarget();
                        ShopA.Reprint(Target);
                        ShopB.Reprint(Target);
                        break;

                    case EnumTypes.UserControlTypes.BuyerUserControl:
                        BuyerUserControl BuyerB = (BuyerUserControl)ActorB;
                        conn         = new Connection(ShopA.ShopModel, BuyerB.BuyerModel, EnumTypes.ConnectionTypes.ShopToBuyer);
                        connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                        ConnectionDictionary.Add(conn, connectionUI);
                        this.Model.Connections.Add(conn);
                        connectionUI.PrintOnTarget();
                        ShopA.Reprint(Target);
                        BuyerB.Reprint(Target);
                        break;
                    }
                    break;

                case EnumTypes.UserControlTypes.SupplierUserControl:
                    SupplierUserControl SuppA  = (SupplierUserControl)ActorA;
                    ShopUserControl     ShopB2 = (ShopUserControl)ActorB;
                    conn         = new Connection(SuppA.SupplierModel, ShopB2.ShopModel, EnumTypes.ConnectionTypes.SupplierToShop);
                    connectionUI = new ConnectionUI(this.Model, Target, conn, this);
                    ConnectionDictionary.Add(conn, connectionUI);
                    this.Model.Connections.Add(conn);
                    connectionUI.PrintOnTarget();
                    SuppA.Reprint(Target);
                    ShopB2.Reprint(Target);
                    break;
                }
                //RYSUJE - czyli
                this.ActorA = null;
                this.ActorB = null;
            }
        }
Ejemplo n.º 9
0
    public void HandleNoSegmentHoveredEvent(NoSegmentsHoveredEvent e)
    {
        if (!isMarker)
        {
            if (currentConnectionUI == e.connectionUI)
            {
                currentConnectionUI = null;
            }

            img.color = originalColor;
        }
    }
Ejemplo n.º 10
0
        private void RecursiveInit(JSONNode node, int index)
        {
            if (index == node.Count)
            {
                _ready = true;

                _restartButton.MouseClick += Restart;
                _exitButton.MouseClick    += Exit;
                _newButton.MouseClick     += CreateEmptyConnection;
                _link.MouseClick          += ToWebPage;

                return;
            }

            JSONNode n = node[index];

            ConnectionModel model = new ConnectionModel(n);

            var ui = new ConnectionUI(model);

            _connectionPanel.Controls.Add(ui);
            _connections.Add(ui);

            ui.Location = new Point(3, 3 + index * 27);

            Timer t = new Timer(100);

            t.Elapsed += (sender, args) => {
                t.Stop();

                if (MainForm.Instance.InvokeRequired)
                {
                    try {
                        MainForm.Instance.Invoke(new Action <JSONNode, int>(RecursiveInit), new object[] { node, index + 1 });
                    } catch (Exception e) {
                    }
                    return;
                }

                RecursiveInit(node, index + 1);
            };

            t.Start();
        }
Ejemplo n.º 11
0
        public Master()
        {
            currentInstance = this;

            // Make constants first so that all the others have access to it right away
            Constants = new ConstantMaster();

            _Dashboard_NT    = new NTInterface(this);
            _AutoSelector    = new AutonomousSelector(this);
            _Timer           = new Timer(this);
            _Accelerometer   = new Accelerometer(this);
            _Lift            = new Lift(this);
            _Monitor         = new NetworkMonitor(this);
            _Camera          = new Element_Controllers.Camera(this);
            _ConnectionUI    = new ConnectionUI(this);
            _Cautioner       = new Cautioner(this);
            ChecklistHandler = new Element_Controllers.Checklist(this);
            _MiscOperations  = new MiscOperations(this);

            RobotLogger = new RobotLogInterface();
        }
Ejemplo n.º 12
0
 public PortBridge(ConnectionModel model, ConnectionUI ui)
 {
     _ui    = ui;
     _model = model;
 }
Ejemplo n.º 13
0
 public AxonCutEvent(ConnectionUI connectionUI)
 {
     this.connectionUI = connectionUI;
 }
Ejemplo n.º 14
0
 public NoSegmentsHoveredEvent(ConnectionUI connectionUI)
 {
     this.connectionUI = connectionUI;
 }
Ejemplo n.º 15
0
 public ActiveSegmentHoveredEvent(ConnectionUI connectionUI)
 {
     this.connectionUI = connectionUI;
 }