コード例 #1
0
    public void makeOptions()
    {
        List <battleOption> allOptions = new List <battleOption>();

        if (gridMaster.selector.selectedUnit != null)
        {
            unit_parent currentUnit = gridMaster.selector.selectedUnit;

            currentUnit.savedScanTargets   = currentUnit.getScanTargets2();
            currentUnit.savedAttackTargets = currentUnit.listAttackNodes();

            if (currentUnit.isActive)
            {
                if (currentUnit.checkAttackTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(0, "Attack", globals.action_cost_attack));
                }
                if (currentUnit.checkDrillTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(1, "Drill", globals.action_cost_drill));
                }
                if (currentUnit.checkHoldTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(2, "Take", globals.action_cost_hold));
                }
                if (currentUnit.checkScanTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(8, "Scan", globals.action_cost_scan));
                }
                if (currentUnit.checkDropTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(6, "Drop", 0));
                }
                allOptions.Add(new battleOption(3, "Wait", 0));
                if (currentUnit.checkBombTargets(currentUnit.thisNode, false))
                {
                    allOptions.Add(new battleOption(7, "Detonate", 0));
                }
                allOptions.Add(new battleOption(5, "Turn Off", 0));
            }

            if (!currentUnit.isActive)
            {
                allOptions.Add(new battleOption(4, "Turn On", 0));
            }
        }

        allOptions.Add(new battleOption(10, "Cancel", 0));


        foreach (Transform child in content.transform)
        {
            Destroy(child.gameObject);
        }

        highlighter      = Instantiate(highlighterPrefab, Vector3.zero, Quaternion.identity, content.transform);
        highlighter.name = "highlighter battle";

        /*highlighter.anchorMin = new Vector2(0, 1);
         * highlighter.anchorMax = new Vector2(0, 1);
         * highlighter.pivot = new Vector2(0, 0);
         * highlighter.sizeDelta = new Vector2(400, 30);*/
        highlighter.localPosition    = new Vector3(5, -33, 0);
        highlighter.localEulerAngles = new Vector3(0, 0, 0);
        highlighter.localScale       = new Vector3(1, 1, 1);

        int iteration = 0;

        foreach (battleOption option in allOptions)
        {
            GameObject gogo = Resources.Load("UIbutton_OPs") as GameObject;
            //Button bb = (Button) gogo.GetComponent<Button>();

            GameObject button = Instantiate(gogo, Vector3.zero, Quaternion.identity) as GameObject;

            //button.GetComponent<Button>().onClick.AddListener(optionSelected );
            button.GetComponent <Button>().onClick.AddListener(delegate { optionSelected(option.code); });
            if (option.cost == 0)
            {
                button.gameObject.GetComponentInChildren <Text>().text = option.name;
            }
            else
            {
                button.gameObject.GetComponentInChildren <Text>().text = option.name + " - " + option.cost + " Gas";
            }
            Transform rectTransform = button.GetComponent <RectTransform>();
            rectTransform.SetParent(content.transform);
            rectTransform.localPosition    = new Vector3(5, -33 - (iteration * 30), 0);
            rectTransform.localEulerAngles = new Vector3(0, 0, 0);
            rectTransform.localScale       = new Vector3(1, 1, 1);
            iteration++;
            buttonArray.Add(button);
            maxOptions = iteration;
        }
        content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, maxOptions * 30);
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        controls.calculate();


        if (actionLocked)
        {
            return;
        }


        //----------------------------------------------------------------------------------------------------------------------------------------
        switch (state_selector)
        {
        case 0:     // nada seleccionado
            if (Input.GetButtonDown("Fire1"))
            {
                if (!cursorNode.nodeOculto && cursorNode.isThereAUnitHere())
                {
                    selectedUnit = cursorNode.unitInThisNode;
                    if (!selectedUnit.alreadyMoved)
                    {
                        selectedUnit.listMovementRange();
                        selectedUnit.selected = true;
                        state_selector        = 1;
                        //Debug.Log("found unit");
                    }
                    else
                    {
                        selectedUnit = null;
                        //Debug.Log("unit already moved");
                    }
                }
                else
                {
                    if (!cursorNode.nodeOculto && cursorNode.isThereAnEnemyHere())
                    {
                        selectedEnemy = cursorNode.enemyInThisNode;
                        selectedEnemy.listMovementRange();
                        selectedEnemy.selected = true;
                        state_selector         = 1;
                    }
                    else
                    {
                        if (!cursorNode.nodeOculto && cursorNode.tiletype.Equals("HQ"))
                        {
                            state_selector       = 6;
                            unitHQ_code.selected = true;
                            showCreationMenu();
                        }
                        else
                        {
                            //Debug.Log("no unit");
                        }
                    }
                }
            }

            //abrir menu de stage
            if (Input.GetButtonDown("Fire2"))
            {
                showStageMenu();
            }
            break;

        //--------------------------
        case 1:     //unidad seleccionada
            if ((selectedUnit != null) && (selectedUnit.selected))
            {
                //if (selectedUnit.checkDistanceWalk(cursorNode, selectedUnit.thisNode, selectedUnit.thisNode, 0)) {
                if (selectedUnit.highLightMoveableNodes(cursorNode))
                {
                    lastPath     = pathToCursor;
                    pathToCursor = pathToAlert(cursorNode, selectedUnit.thisNode, 100);
                    if (lastPath != null)
                    {
                        foreach (Node pathnode in lastPath)
                        {
                            pathnode.pathmember = false;
                        }
                    }
                    foreach (Node pathnode in pathToCursor)
                    {
                        pathnode.pathmember = true;
                    }
                }

                if (Input.GetButtonDown("Fire1"))
                {
                    if (selectedUnit.highLightMoveableNodes(cursorNode))
                    {
                        /*Debug.Log("move here!");
                         * //selectedUnit.lastNode = selectedUnit.thisNode;
                         * //selectedUnit.thisNode = this.cursorNode;
                         * //selectedUnit.updatePosition();
                         * selectedUnit.nextNode = this.cursorNode;
                         * selectedUnit.previewPosition();
                         *
                         * //disengage code
                         * selectedUnit.selected = false;
                         * selectedUnit.alreadyMoved = true;
                         * selectedUnit = null;
                         * actionLocked = false;
                         * state_selector = 0;
                         * if (lastPath != null) {
                         *  foreach (Node pathnode in lastPath) {
                         *      pathnode.pathmember = false;
                         *  }
                         * }
                         * //open action menu
                         * //actionLocked = true;
                         * state_selector = 2;*/



                        //Debug.Log("move here!");
                        selectedUnit.nextNode = this.cursorNode;
                        selectedUnit.previewPosition();
                        state_selector = 2;
                        showBattleMenu();
                    }
                }

                //cancel movement
                if (Input.GetButtonDown("Fire2"))
                {
                    battleMenuCancelHighlightMovement();
                }
            }

            if ((selectedEnemy != null) && (selectedEnemy.selected))
            {
                //cancel movement
                if (Input.GetButtonDown("Fire2"))
                {
                    enemyCancelHighlight();
                }
            }



            break;

        case 2:
            //durante este estado el menu esta abierto
            //cancel

            /*if (Input.GetButtonDown("Fire2")) {
             *  battleMenuCancelMovement();
             * }*/
            break;

        case 3:
            //drill
            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    if (selectedUnit.checkDrillTargets(this.cursorNode, true) && this.cursorNode.nodeOculto)
                    {
                        this.cursorNode.revealNode();
                        GameObject dust = Instantiate((GameObject)Resources.Load("dust_ps"));    //, cursorNode.gridPoint, Quaternion.identity, gridMaster.groupUnit
                        dust.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, -1);
                        Destroy(dust, 1.0f);
                        //disengage code
                        selectedUnit.lastNode = selectedUnit.thisNode;
                        selectedUnit.thisNode = selectedUnit.nextNode;
                        if (selectedUnit.heldRelic != null)
                        {
                            selectedUnit.heldRelic.thisNode = selectedUnit.thisNode;
                        }
                        ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                        selectedUnit.updatePosition();
                        selectedUnit.selected     = false;
                        selectedUnit.alreadyMoved = true;
                        selectedUnit   = null;
                        actionLocked   = false;
                        state_selector = 0;
                        //gridMaster.addGas(-globals.action_cost_drill);
                        if (lastPath != null)
                        {
                            foreach (Node pathnode in lastPath)
                            {
                                pathnode.pathmember = false;
                            }
                        }
                    }
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                battleMenuCancelAction();
            }
            break;

        case 4:
            //attack
            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    selectedUnit.savedAttackTargets = selectedUnit.listAttackNodes();
                    if (selectedUnit.checkAttackTargets(this.cursorNode, true) && this.cursorNode.isThereAnEnemyHere())
                    {
                        enemy_parent target = this.cursorNode.enemyInThisNode;
                        target.health -= selectedUnit.attackPower;
                        if (target.health <= 0)
                        {
                            //Destroy(target.gameObject);
                            target.getRekt();
                        }
                        //disengage code
                        selectedUnit.lastNode = selectedUnit.thisNode;
                        selectedUnit.thisNode = selectedUnit.nextNode;
                        if (selectedUnit.heldRelic != null)
                        {
                            selectedUnit.heldRelic.thisNode = selectedUnit.thisNode;
                        }
                        ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                        selectedUnit.updatePosition();
                        selectedUnit.selected     = false;
                        selectedUnit.alreadyMoved = true;
                        selectedUnit   = null;
                        actionLocked   = false;
                        state_selector = 0;
                        //gridMaster.addGas(-globals.action_cost_attack);
                        if (lastPath != null)
                        {
                            foreach (Node pathnode in lastPath)
                            {
                                pathnode.pathmember = false;
                            }
                        }
                    }
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                battleMenuCancelAction();
            }
            break;

        case 5:    //hold
            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    if (selectedUnit.checkHoldTargets(this.cursorNode, true) && this.cursorNode.isThereAnItemHere())
                    {
                        relic targetrelic = (relic)cursorNode.itemInThisNode;
                        selectedUnit.heldRelic = targetrelic;
                        targetrelic.onTake(true);
                        targetrelic.transform.position = selectedUnit.transform.position;
                        //disengage code
                        selectedUnit.lastNode = selectedUnit.thisNode;
                        selectedUnit.thisNode = selectedUnit.nextNode;
                        if (selectedUnit.heldRelic != null)
                        {
                            selectedUnit.heldRelic.thisNode = selectedUnit.thisNode;
                        }
                        ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                        selectedUnit.updatePosition();
                        selectedUnit.selected     = false;
                        selectedUnit.alreadyMoved = true;
                        selectedUnit   = null;
                        actionLocked   = false;
                        state_selector = 0;
                        //gridMaster.addGas(-globals.action_cost_hold);
                        if (lastPath != null)
                        {
                            foreach (Node pathnode in lastPath)
                            {
                                pathnode.pathmember = false;
                            }
                        }
                        gridMaster.wakeUpStatues();    //only for wake up boss check
                    }
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                battleMenuCancelAction();
            }
            break;

        case 6:    //create unit
            //buffer state
            //create unit menu active
            break;

        case 7:
            //set created unit in place
            if (Input.GetButtonDown("Fire1"))
            {
                if ((unitHQ_code != null) && unitHQ_code.selected && unitHQ_code.checkCreationSpaces(this.cursorNode, true) && (create_selector != 0))
                {
                    int         createcost             = globals.drill_create_cost;
                    unit_parent selected_creation_unit = gridMaster.unit_drill_prefab;
                    switch (create_selector)
                    {
                    case 1:
                        createcost             = globals.drill_create_cost;
                        selected_creation_unit = gridMaster.unit_drill_prefab;
                        break;

                    case 2:
                        createcost             = globals.tank_create_cost;
                        selected_creation_unit = gridMaster.unit_tank_prefab;
                        break;

                    case 3:
                        createcost             = globals.scout_create_cost;
                        selected_creation_unit = gridMaster.unit_scout_prefab;
                        break;

                    case 4:
                        createcost             = globals.bomb_create_cost;
                        selected_creation_unit = gridMaster.unit_bomb_prefab;
                        break;

                    case 5:
                        createcost             = globals.tank_create_cost;
                        selected_creation_unit = gridMaster.unit_armoredS_prefab;
                        break;
                    }

                    if (gridMaster.recursoDinero >= 0)
                    {
                        //create unit
                        unit_parent new_creation_unit = Instantiate(selected_creation_unit, new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0), Quaternion.identity, gridMaster.groupUnit);
                        new_creation_unit.alreadyMoved = true;
                        gridMaster.addDinero(-createcost);
                        gridMaster.updateActors();

                        //unset state
                        unitHQ_code.selected     = false;
                        unitHQ_code.alreadyMoved = true;
                        actionLocked             = false;
                        state_selector           = 0;
                    }
                }
            }

            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                creationMenuCancelCreation();
            }
            break;

        case 8:    //drop
            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    if (selectedUnit.checkDropTargets(cursorNode, true))
                    {
                        if (cursorNode.tiletype.Equals("HQ"))
                        {
                            selectedUnit.heldRelic.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                            selectedUnit.heldRelic.onSave();
                            selectedUnit.heldRelic = null;
                        }
                        else
                        {
                            selectedUnit.heldRelic.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                            selectedUnit.heldRelic.onReveal();
                            selectedUnit.heldRelic = null;
                        }
                        //disengage code
                        selectedUnit.lastNode = selectedUnit.thisNode;
                        selectedUnit.thisNode = selectedUnit.nextNode;
                        if (selectedUnit.heldRelic != null)
                        {
                            selectedUnit.heldRelic.thisNode = selectedUnit.thisNode;
                        }
                        ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                        selectedUnit.updatePosition();
                        selectedUnit.selected     = false;
                        selectedUnit.alreadyMoved = true;
                        selectedUnit   = null;
                        actionLocked   = false;
                        state_selector = 0;
                        if (lastPath != null)
                        {
                            foreach (Node pathnode in lastPath)
                            {
                                pathnode.pathmember = false;
                            }
                        }
                    }
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                battleMenuCancelAction();
            }
            break;

        case 9:
            //go bomb
            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    //this.cursorNode.revealNode();
                    GameObject explotion_inst = Instantiate((GameObject)Resources.Load("bomb_explotion"), selectedUnit.transform.position, Quaternion.identity, gridMaster.groupUnit);
                    Destroy(explotion_inst, 1.0f);
                    //GameObject dust = Instantiate((GameObject)Resources.Load("dust_ps2"));
                    //dust.transform.position = new Vector3(selectedUnit.nextNode.gridPoint.x, selectedUnit.nextNode.gridPoint.y, -1);
                    //Destroy(dust, 2.0f);

                    foreach (Node nnn in selectedUnit.listBombNodes())
                    {
                        if (nnn.nodeOculto)
                        {
                            nnn.revealNode();
                        }
                        else
                        {
                            if (nnn.isThereAnEnemyHere())
                            {
                                nnn.enemyInThisNode.health -= globals.bombExplodeStat;
                                if (nnn.enemyInThisNode.health <= 0)
                                {
                                    nnn.enemyInThisNode.getRekt();
                                }
                            }
                            //friendly fire off is more fun

                            /*if (nnn.isThereAUnitHere()) {
                             *  nnn.unitInThisNode.health -= globals.bombExplodeStat;
                             *  if (nnn.unitInThisNode.health <= 0) {
                             *      nnn.unitInThisNode.getRekt();
                             *  }
                             * }*/
                        }
                    }
                    //disengage code
                    selectedUnit.lastNode = selectedUnit.thisNode;
                    selectedUnit.thisNode = selectedUnit.nextNode;
                    if (selectedUnit.heldRelic != null)
                    {
                        selectedUnit.heldRelic.thisNode = selectedUnit.thisNode;
                    }
                    ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                    selectedUnit.updatePosition();
                    selectedUnit.selected     = false;
                    selectedUnit.alreadyMoved = true;
                    unit_parent tempunit = selectedUnit;
                    selectedUnit   = null;
                    actionLocked   = false;
                    state_selector = 0;
                    //gridMaster.addGas(-globals.action_cost_base_bomb);

                    //destroy bomb
                    tempunit.detonate();

                    if (lastPath != null)
                    {
                        foreach (Node pathnode in lastPath)
                        {
                            pathnode.pathmember = false;
                        }
                    }
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                battleMenuCancelAction();
            }
            break;

        case 10:
            //scanplace
            movementLocked = true;
            if ((selectedUnit != null) && (selectedUnit.selected) && (controls.horizontal != 0 || controls.vertical != 0))
            {
                if (controls.horizontal == -1 && controls.vertical == 0)
                {
                    selectedUnit.scanDirection    = 0;
                    selectedUnit.savedScanTargets = selectedUnit.getScanTargets2();
                }
                if (controls.horizontal == 0 && controls.vertical == -1)
                {
                    selectedUnit.scanDirection    = 1;
                    selectedUnit.savedScanTargets = selectedUnit.getScanTargets2();
                }
                if (controls.horizontal == 1 && controls.vertical == 0)
                {
                    selectedUnit.scanDirection    = 2;
                    selectedUnit.savedScanTargets = selectedUnit.getScanTargets2();
                }
                if (controls.horizontal == 0 && controls.vertical == 1)
                {
                    selectedUnit.scanDirection    = 3;
                    selectedUnit.savedScanTargets = selectedUnit.getScanTargets2();
                }
            }


            if (Input.GetButtonDown("Fire1"))
            {
                if ((selectedUnit != null) && (selectedUnit.selected))
                {
                    int enemyScan       = 0;
                    int enemyStrongScan = 0;
                    int relicScan       = 0;
                    int nestScan        = 0;

                    //disengage part 1
                    selectedUnit.lastNode = selectedUnit.thisNode;
                    selectedUnit.thisNode = selectedUnit.nextNode;
                    if (selectedUnit.heldRelic != null)
                    {
                        selectedUnit.heldRelic.thisNode = selectedUnit.nextNode;
                    }
                    ////gridMaster.addGas(-selectedUnit.temp_gas_usage);
                    selectedUnit.updatePosition();

                    selectedUnit.savedScanTargets = selectedUnit.getScanTargets2();
                    foreach (Node nnn in selectedUnit.savedScanTargets)
                    {
                        if (nnn.isThereAnEnemyHere())
                        {
                            if (nnn.enemyInThisNode.GetComponent <enemy_parent>().enemyClass.Equals(globals.nestName))
                            {
                                nestScan++;
                            }
                            else
                            {
                                if (nnn.enemyInThisNode.GetComponent <enemy_parent>().maxHealth > 20)
                                {
                                    enemyStrongScan++;
                                }
                                else
                                {
                                    enemyScan++;
                                }
                            }
                        }
                        if (nnn.isThereAnItemHere() && !nnn.isHQhere() && (!nnn.isThereAUnitHere() || (nnn.isThereAUnitHere() && nnn.itemInThisNode.state != 2)))
                        {
                            relicScan++;
                        }
                    }


                    state_selector = 11;
                    //actionLocked = true;
                    movementLocked = false;
                    menuScanResult.gameObject.SetActive(true);
                    menuScanResult.setValues(selectedUnit, enemyScan, enemyStrongScan, nestScan, relicScan);
                    //Debug.Log("Enemy: " + enemyScan + "Big-Enemy: " + enemyStrongScan + " Nest: " + nestScan + " Relic: " + relicScan);

                    //TODO
                    //mostrar enemigos y relics contados


                    //disengage code part 2

                    /*selectedUnit.selected = false;
                     * selectedUnit = null;
                     * actionLocked = false;
                     * //gridMaster.addGas(-globals.action_cost_scan);
                     * if (lastPath != null) {
                     *  foreach (Node pathnode in lastPath) {
                     *      pathnode.pathmember = false;
                     *  }
                     * }*/
                }
            }
            //cancel
            if (Input.GetButtonDown("Fire2"))
            {
                movementLocked = false;
                battleMenuCancelAction();
            }
            break;

        case 11:
            /*if (Input.GetButtonDown("Fire1") || Input.GetButtonDown("Fire2")) {
             *  closeScanMenu();
             * }*/
            break;
        }

        //Check if we have a non-zero value for horizontal or vertical

        int G_horizontal = 0;
        int G_vertical   = 0;

        if (!movementLocked)
        {
            if (controls.horizontal != 0 || controls.vertical != 0)
            {
                G_horizontal = controls.horizontal;
                G_vertical   = controls.vertical;
                //Debug.Log("horizontal: " + horizontal + " vertical: " + vertical);
            }



            if (G_horizontal == -1 && G_vertical == 0 && nextDirection(0))
            {
                //changeIcon();
                cursorNode         = cursorNode.leftNode;
                transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                //camScript.alignCamera(cursorNode, false);
            }
            if (G_horizontal == 0 && G_vertical == -1 && nextDirection(1))
            {
                //changeIcon();
                cursorNode         = cursorNode.downNode;
                transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                //camScript.alignCamera(cursorNode, false);
            }
            if (G_horizontal == 1 && G_vertical == 0 && nextDirection(2))
            {
                //changeIcon();
                cursorNode         = cursorNode.rightNode;
                transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                //camScript.alignCamera(cursorNode, false);
            }
            if (G_horizontal == 0 && G_vertical == 1 && nextDirection(3))
            {
                //changeIcon();
                cursorNode         = cursorNode.upNode;
                transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0);
                //camScript.alignCamera(cursorNode, false);
            }
        }


        /*if (controls.vertical != 0 ||
         *      controls.horizontal != 0 ||
         *      Input.GetButtonDown("Fire1") ||
         *      Input.GetButtonDown("Fire2")
         *  ) {
         *  gridMaster.updateAllNodes();
         * }*/

        //updategui();
    }
コード例 #3
0
    //Update
    public void Update()
    {
        nodeSquare.GetComponent <SpriteRenderer>().sprite = defaultSprite;
        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.white;

        /*
         *      if (gridMaster.cursorCode.cursorNode.Equals (gridMaster.cursorCode.playerCode.playerNode)) {
         *              if(gridMaster.cursorCode.highLightMoveableNodes(this)){
         *                      nodeSquare.GetComponent<SpriteRenderer> ().color = Color.blue;
         *              }
         *      }
         *      foreach (GameObject enemy in gridMaster.enemies) {
         *              EnemyParent enemyCode = (EnemyParent) enemy.GetComponent(typeof(EnemyParent));
         *              if(enemyCode.highLightSeenNodes(this)){
         *                      nodeSquare.GetComponent<SpriteRenderer> ().color = Color.red;
         *              }
         *      }
         *      //cursor potential sound
         *      if(gridMaster.cursorCode.highLightSoundNodes(this)){
         *              nodeSquare.GetComponent<SpriteRenderer> ().color = Color.green;
         *      }
         *
         */

        foreach (GameObject unit in gridMaster.units)
        {
            unit_parent unit_code = (unit_parent)unit.GetComponent(typeof(unit_parent));
            if (unit_code.selected)
            {
                switch (gridMaster.selector.state_selector)
                {
                case 11:
                    if (unit_code.checkScanTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 10:
                    if (unit_code.checkScanTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 9:
                    if (unit_code.checkBombTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 8:
                    if (unit_code.checkDropTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 5:
                    if (unit_code.checkHoldTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 4:
                    if (unit_code.checkAttackTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                case 3:
                    if (unit_code.checkDrillTargets(this, true))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    break;

                default:
                    if (unit_code.highLightMoveableNodes(this))
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                    }
                    if (pathmember)
                    {
                        nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                        nodeSquare.GetComponent <SpriteRenderer>().color  = Color.red;
                    }
                    break;
                }
            }
        }


        if (unitHQ_code.selected)
        {
            if (gridMaster.selector.state_selector == 7)
            {
                if (unitHQ_code.checkCreationSpaces(this, true))
                {
                    nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                    nodeSquare.GetComponent <SpriteRenderer>().color  = Color.green;
                }
            }
        }

        foreach (GameObject enemy in gridMaster.enemies)
        {
            enemy_parent enemy_code = (enemy_parent)enemy.GetComponent(typeof(enemy_parent));
            if (enemy_code.selected && !nodeOculto)
            {
                if (enemy_code.highLightAttackableNodes(this))
                {
                    nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                    nodeSquare.GetComponent <SpriteRenderer>().color  = Color.magenta;
                }
                if (enemy_code.highLightMoveableNodes(this))
                {
                    nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite;
                    nodeSquare.GetComponent <SpriteRenderer>().color  = Color.red;
                }
            }
        }

        /*
         * if (pathmember) {
         *  nodeSquare.GetComponent<SpriteRenderer>().sprite = focusedSprite;
         *  nodeSquare.GetComponent<SpriteRenderer>().color = Color.red;
         * }*/
    }