Пример #1
0
    // Use this for initialization
    void Start()
    {
        map = WMSK.instance;


        map.OnProvinceClick += (int provinceIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked province " + map.provinces[provinceIndex].name);


        map.OnClick += (float x, float y, int buttonIndex) => {
            if (buttonIndex == 1)
            {
                return;
            }
            Vector2 provincePosition = new Vector2(x, y);
            if (map.ContainsWater(provincePosition))
            {
                Debug.Log("Yes, water!");
            }
            else
            {
                Debug.Log("Land");
            }
            int clickedIndex = map.GetProvinceIndex(provincePosition);
            assemblyCsharp.Province clickedProvince = provinces[clickedIndex];
            int provinceOwner = clickedProvince.getOwnerIndex();
            //  Debug.Log("Province Culture: " + clickedProvince.getCulture());
            Nation owner = nations[provinceOwner];
            Debug.Log("Nation name " + owner.getName());
            if (map.VGOLastHighlighted == null)
            {
                if (SelfProvinceGUI.activeSelf)
                {
                    SelfProvinceGUI.SetActive(false);
                }

                if (OtherProvinceGUI.activeSelf)
                {
                    OtherProvinceGUI.SetActive(false);
                }


                if (owner.IsHuman())
                {
                    ThisFillInData(clickedProvince);

                    SelfProvinceGUI.SetActive(true);
                }
                else
                {
                    NationName.text = owner.getName();
                    ThatFillInData(clickedProvince);
                    OtherProvinceGUI.SetActive(true);
                }
            }
        };
        upgradeDevelopment.onClick.AddListener(delegate { UpgradeDevelopment(); });
        upgradeRailway.onClick.AddListener(delegate { UpgradeRailway(); });
        upgradeFort.onClick.AddListener(delegate { UpgradeFort(); });
    }
Пример #2
0
        /// <summary>
        /// Creates ship. Main function called from button UI.
        /// </summary>
        void LaunchShip()
        {
            // Get a coastal city and a water entrypoint
            int     cityIndex = Random.Range(0, map.cities.Count);
            Vector2 cityPosition;
            Vector2 waterPosition = Misc.Vector2zero;
            int     safeAbort     = 0;

            do
            {
                cityIndex++;
                if (cityIndex >= map.cities.Count)
                {
                    cityIndex = 0;
                }
                cityPosition = map.cities [cityIndex].unity2DLocation;
                if (safeAbort++ > 8000)
                {
                    break;
                }
            } while (!map.ContainsWater(cityPosition, 0.0001f, out waterPosition));

            if (safeAbort > 8000)
            {
                return;
            }

            // Create ship
            if (ship != null)
            {
                DestroyImmediate(ship.gameObject);
            }
            ship = DropShipOnPosition(waterPosition);

            // Fly to the location of ship with provided zoom level
            map.FlyToLocation(waterPosition, 2.0f, 0.1f);

            // Enable move on click in this demo
            enableAddTowerOnClick = false;
            enableClickToMoveTank = false;
            enableClickToMoveShip = true;
        }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        map = WMSK.instance;


        map.OnClick += (float x, float y, int buttonIndex) =>
        {
            if (buttonIndex == 1)
            {
                return;
            }
            Vector2 provincePosition = new Vector2(x, y);
            int     clickedIndex     = map.GetProvinceIndex(provincePosition);
            if (map.ContainsWater(provincePosition))
            {
                return;
            }
            assemblyCsharp.Province clickedProvince = provinces[clickedIndex];
            int    provinceOwner = clickedProvince.getOwnerIndex();
            Nation owner         = nations[provinceOwner];
            //   Debug.Log("That 51");

            if (map.VGOLastHighlighted == null)
            {
                if (SelfProvinceGUI.activeSelf)
                {
                    SelfProvinceGUI.SetActive(false);
                }

                if (OtherProvinceGUI.activeSelf)
                {
                    OtherProvinceGUI.SetActive(false);
                }

                if (!owner.IsHuman())
                {
                    //     Debug.Log("That 69");
                    ThatFillInData(clickedProvince);
                    OtherProvinceGUI.SetActive(true);
                }
            }
        };
    }