Exemplo n.º 1
0
 protected void Start()
 {
     map       = FindObjectOfType <MapNavBase>();
     mapSize   = map.mapHorizontalSize.ToString();
     minHeight = map.minNodeHeight.ToString();
     maxHeight = map.maxNodeHeight.ToString();
 }
Exemplo n.º 2
0
    protected void Start()
    {
        // get reference to the mapnav map
        map = GameObject.Find("Map").GetComponent <NavalMap> ();
        // 在Unity编辑器内运行时,不再运行触控墙程序
#if UNITY_EDITOR
        return;
#endif
#if UNITY_STANDALONE_WIN
        StartCoroutine(startTouchWall());
#endif
    }
Exemplo n.º 3
0
    protected bool unitMoving = false;                          // set when a unit is moving and no input should be accepted

    #endregion
    // ------------------------------------------------------------------------------------------------------------
    #region start

    protected void Start()
    {
        // get reference to the mapnav map
        map = GameObject.Find("Map").GetComponent <Sample4Map>();

        // also used in sample4b
        if (map == null)
        {
            map = GameObject.Find("Map").GetComponent <Sample4bMap>();
        }

        // in this sample I will simply spawn 10 units on random locations of the map
        for (int i = 0; i < 10; i++)
        {
            Sample4Tile selectedTile = null;

            // find a tile to place the unit on. I will randomly select one.
            // but I need to check if there is not already a unit on the
            // selected tile before accepting it.
            while (true)
            {
                int idx = Random.Range(0, map.grid.Length);

                // make sure this is a valid node
                if (map.ValidIDX(idx))
                {
                    // now check if there is not already a unit on it
                    selectedTile = map.grid[idx] as Sample4Tile;
                    if (selectedTile.unit == null)
                    {
                        // no unit on it, lets use it
                        break;
                    }
                }
            }

            // create the unit and place it on the tile
            GameObject go = (GameObject)Instantiate(unitFab);
            go.transform.position = selectedTile.position;
            go.layer = 9;             // in this sample Units must be in layer 9

            // be sure to tell the tile that this Unit is on it
            Sample4Unit unit = go.GetComponent <Sample4Unit>();
            unit.Resetunit();            // reset its moves now too
            unit.LinkWithTile(selectedTile);
            units.Add(unit);             // keep a list of all units for quick access
        }
    }