예제 #1
0
    public override void perform(Vector2 startPos, Vector2 endPos)
    {
        slectedTiles.Clear();

        int xStart = (int)Mathf.Min(startPos.x, endPos.x);
        int yStart = (int)Mathf.Min(startPos.y, endPos.y);
        int xEnd   = (int)Mathf.Max(startPos.x, endPos.x);
        int yEnd   = (int)Mathf.Max(startPos.y, endPos.y);

        for (int x = xStart; x <= xEnd; x++)
        {
            for (int y = yStart; y <= yEnd; y++)
            {
                Tile t = map.getTile(MapLayer.GROUND, x, y);
                if (t != null)
                {
                    TilePrefab prefab = Resources.Load <TilePrefab>(t.PrefabPath);

                    if (prefab.GetComponent <T>() != null)
                    {
                        slectedTiles.Add(t);
                    }
                }
            }
        }

        if (onSelected != null && slectedTiles.Count > 0)
        {
            onSelected();
        }
    }
예제 #2
0
    // Use this for initialization
    void Awake()
    {
        Input.backButtonLeavesApp = true;
        self        = this;
        colorMap[0] = Color.green;
        colorMap[1] = Color.blue;
        colorMap[2] = new Color(0f, 1f, 1f);
        colorMap[3] = Color.black;
        colorMap[4] = Color.red;
        colorMap[5] = new Color(1f, 0f, 1f);
        colorMap[6] = new Color(1f, 1f, 0f);
        Mesh tileMesh = TilePrefab.GetComponent <MeshFilter>().sharedMesh;

        baseMainVerts = tileMesh.vertices;
        convertToSides(tileMesh, baseMainVerts, ref sideVerts);
        tileMesh.vertices = baseMainVerts;
        sideView          = false;
        inventory         = new Inventory(GameObject.FindGameObjectWithTag("inventory"), false);
        equipment         = new Inventory(GameObject.FindGameObjectWithTag("equipS"), true);

        myCam   = GameObject.FindGameObjectWithTag("Cam2").GetComponent <Camera> ();
        mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> ();

        soundUI    = myCam.transform.GetChild(1).GetComponent <AudioSource> ();
        soundEquip = myCam.transform.GetChild(2).GetComponent <AudioSource> ();

        playerLocation = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform> ();
        //playerAnim = playerLocation.GetComponent<Animator> ();
        //playerFollowL = GameObject.FindGameObjectWithTag ("PlayerFollow").GetComponent<Transform> ();
        UIInventory.SetActive(false);
        UINormal.SetActive(false);
        UIEdit.SetActive(false);
        UIMove.SetActive(false);
        UIChat.SetActive(false);
        UIStats.SetActive(false);
        UIHaS.SetActive(false);
        UICompass.SetActive(false);
        UIOptions.SetActive(false);
        chCam         = chatCam.GetComponent <Camera> ();
        chCam.enabled = false;
        //chatCam.SetActive (false);
        selBox  = GameObject.FindGameObjectWithTag("selectBox");
        selCirc = GameObject.FindGameObjectWithTag("selectCircle");
        selBox.SetActive(false);
        selCirc.SetActive(false);
        selectBox = selBox;
        foreach (EnemyType type in Enum.GetValues(EnemyType.archer.GetType()))
        {
            GameObject prefab = Resources.Load <GameObject>("Prefabs/enemy/" + type.ToString());
            enemyPrefabs.Add(type, prefab);
        }
    }