Beispiel #1
0
    private CityView CreateCityView(Transform parent, MapView mapView, City city, string prefabName)
    {
        var unitPrefab = Resources.Load <CityView>(prefabName);

        if (unitPrefab == null)
        {
            Debug.LogError("Can't load unit " + prefabName);
            return(null);
        }
        CityView cityView = Instantiate(unitPrefab);

        cityView.gameObject.SetActive(true);
        cityView.transform.parent = parent;
        cityView.Init(city, mapView.CellCoordToPosition(city.Coordinate));
        return(cityView);
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            Director director = Director.GetInstance();

            View cityView = new CityView();

            cityView.Init();

            Console.WriteLine("------------------------------------------------------------");
            DispatchCustomEvent("Login", "XXX登陆了");
            DispatchCustomEvent("Update", "XXX升级了");

            View userDataView = new UserDataView();

            userDataView.Init();

            Console.WriteLine("------------------------------------------------------------");
            DispatchCustomEvent("Update", "XXX升级了");
            DispatchCustomEvent("Build", "XXX建筑开始建造了");

            View resourceView = new ResourceView();

            resourceView.Init();

            Console.WriteLine("------------------------------------------------------------");
            DispatchCustomEvent("Update", "XXX升级了");
            DispatchCustomEvent("Build", "XXX建筑开始建造了");

            Console.WriteLine("------------------------------------------------------------");
            resourceView.Close();
            DispatchCustomEvent("Update", "XXX升级了");

            Console.WriteLine("------------------------------------------------------------");
            RemoveCustomEvent("Update");
            DispatchCustomEvent("Update", "XXX升级了");
        }