// Use this for initialization
 void Start()
 {
     go        = this.gameObject;
     us        = Camera.main.GetComponent <UnitSelectionComponent> ();
     mat       = GetComponent <Renderer> ().material;
     mat.color = Color.blue;
     moving    = false;
     upswing   = true;
 }
 // Use this for initialization
 void Start()
 {
     EventManager.StartListening("MoveEvent", MoveEventHandler);
     EventManager.StartListening("SelectionEvent", SelectionEventHandler);
     go        = this.gameObject;
     us        = Camera.main.GetComponent <UnitSelectionComponent> ();
     mat       = GetComponent <Renderer> ().material;
     mat.color = Color.blue;
     upswing   = true;
     moving    = false;
 }
Exemple #3
0
        private void OnElementOnClick(MouseEvent mouseEvent)
        {
            if (mouseEvent.srcElement.className.Contains("unit"))
            {
                GameObject unit = PhotonNetwork.GetPhotonView(int.Parse(mouseEvent.srcElement.id)).gameObject;
                cameraController.DeselectAllUnits();

                UnitSelectionComponent selection = unit.GetComponent <UnitSelectionComponent>();
                selection.SetSelect(false);

                MapScript.MoveCameraToPoint(unit.transform.position);
            }
        }
 void Start()
 {
     MessagingSystem.Instance.AttachListener(typeof(MoveToMessage),
                                             this.HandleMoveToMessage);
     MessagingSystem.Instance.AttachListener(typeof(MoveMessage),
                                             this.HandleMoveMessage);
     MessagingSystem.Instance.AttachListener(typeof(SelectionMessage),
                                             this.HandleSelectionMessage);
     go        = this.gameObject;
     us        = Camera.main.GetComponent <UnitSelectionComponent> ();
     mat       = GetComponent <Renderer> ().material;
     mat.color = Color.blue;
     moving    = false;
     upswing   = true;
 }
Exemple #5
0
    public void btnObstacle()
    {
        if (noeud != null)
        {
            Renderer rend = noeud.GetComponent <Renderer>();
            rend.material.color = Color.black;
            Noeud n = noeud.GetComponent <Noeud>();
            n.setLibre(false);
            obstacles.Add(noeud);
            if (noeud == noeudDepart)
            {
                noeudDepart = null;
            }
            if (noeud == noeudArrivee)
            {
                noeudArrivee = null;
            }
            noeud = null;
        }
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.black;
            Noeud n = nd.GetComponent <Noeud>();
            n.setLibre(false);
            obstacles.Add(nd);
            if (nd == noeudDepart)
            {
                noeudDepart = null;
            }
            if (nd == noeudArrivee)
            {
                noeudArrivee = null;
            }
        }
        selection.clearSelections();
    }
    public void BtnUnblockPath()
    {
        if (node != null)
        {
            // Set selected node to white.
            Renderer rend = node.GetComponent <Renderer>();
            rend.material.color = Color.white;

            // Set selected not to walkable.
            Node n = node.GetComponent <Node>();
            n.SetWalkable(true);

            // Remove selected node from the block path list.
            blockPath.Remove(node);

            node = null;
        }

        // For selection grid system.
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            // Set selected node to white.
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.white;

            // Set selected not to walkable.
            Node n = nd.GetComponent <Node>();
            n.SetWalkable(true);

            // Remove selected node from the block path list.
            blockPath.Remove(nd);
        }

        selection.clearSelections();
    }
Exemple #7
0
    public void btnEnleveObstacle()
    {
        if (noeud != null)
        {
            Renderer rend = noeud.GetComponent <Renderer>();
            rend.material.color = Color.white;
            Noeud n = noeud.GetComponent <Noeud>();
            n.setLibre(true);
            obstacles.Remove(noeud);
            noeud = null;
        }
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.white;
            Noeud n = nd.GetComponent <Noeud>();
            n.setLibre(true);
            obstacles.Remove(nd);
        }
        selection.clearSelections();
    }
    public void BtnBlockPath()
    {
        if (node != null)
        {
            // Render the selected node to black.
            Renderer rend = node.GetComponent <Renderer>();
            rend.material.color = Color.black;

            // Set selected node to not walkable
            Node n = node.GetComponent <Node>();
            n.SetWalkable(false);

            // Add the node to the block path list.
            blockPath.Add(node);

            // If the block path is start node, we remove start node.
            if (node == startNode)
            {
                startNode = null;
            }

            // If the block path is end node, we remove end node.
            if (node == endNode)
            {
                endNode = null;
            }

            node = null;
        }

        // For selection grid system.
        UnitSelectionComponent selection = gameObject.GetComponent <UnitSelectionComponent>();
        List <Transform>       selected  = selection.getSelectedObjects();

        foreach (Transform nd in selected)
        {
            // Render the selected node to black.
            Renderer rend = nd.GetComponent <Renderer>();
            rend.material.color = Color.black;

            // Set selected node to not walkable
            Node n = nd.GetComponent <Node>();
            n.SetWalkable(false);

            // Add the node to the block path list.
            blockPath.Add(nd);

            // If the block path is start node, we remove start node.
            if (nd == startNode)
            {
                startNode = null;
            }

            // If the block path is end node, we remove end node.
            if (nd == endNode)
            {
                endNode = null;
            }
        }

        selection.clearSelections();
    }
 void Awake()
 {
     selector = Camera.main.GetComponent <UnitSelectionComponent>();
 }
 /// <summary>
 /// Start this instance.
 /// </summary>
 void Start()
 {
     unitSelection = FindObjectOfType<UnitSelectionComponent> ();
 }