Пример #1
0
    public void Upgrade()
    {
        EFeatureType upgradedFeature = EFeatureType.None;

        switch (featureType)
        {
        case EFeatureType.Village:
            upgradedFeature = EFeatureType.Town;
            break;

        case EFeatureType.Town:
            upgradedFeature = EFeatureType.City;
            break;
        }

        if (upgradedFeature != EFeatureType.None)
        {
            FeatureCosts selectedFeatureCost = homeRegion.FeatureCosts[upgradedFeature.ToString()];

            if (selectedFeatureCost.VerifyCosts(homeRegion))
            {
                FeatureType = upgradedFeature;
                BuildFeature();
            }
            else
            {
                StartCoroutine(controller.FlashCursor());
            }
        }
    }
Пример #2
0
    public void StartRoad(Feature feature)
    {
        RoadBuildHelper(0, feature);

        controller             = feature.Controller;
        controller.CurrentRoad = gameObject;

        costOfRoad = controller.FeatureCosts["TradeRoute"];

        switch (feature.FeatureType)
        {
        case EFeatureType.Mine:
            movingResources.Add(EResources.Iron);
            break;

        case EFeatureType.Port:
            movingResources.Add(EResources.Water);
            movingResources.Add(EResources.UncountedPopulation);
            costOfRoad = controller.FeatureCosts["Aqueduct"];
            break;

        case EFeatureType.LumberMill:
            movingResources.Add(EResources.Wood);
            break;

        case EFeatureType.Quarry:
            movingResources.Add(EResources.Stone);
            break;

        case EFeatureType.Field:
            movingResources.Add(EResources.Grain);
            break;

        case EFeatureType.LivestockFarm:
            movingResources.Add(EResources.Meat);
            break;

        case EFeatureType.Well:
            movingResources.Add(EResources.Water);
            costOfRoad = controller.FeatureCosts["Aqueduct"];
            break;

        case EFeatureType.Village:
            movingResources.Add(EResources.Gold);
            movingResources.Add(EResources.UncountedPopulation);
            break;

        case EFeatureType.Town:
            movingResources.Add(EResources.Gold);
            movingResources.Add(EResources.UncountedPopulation);
            break;

        case EFeatureType.City:
            movingResources.Add(EResources.Gold);
            movingResources.Add(EResources.UncountedPopulation);
            break;
        }
    }
Пример #3
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            //Debug.Log("Clicked: " + gameObject.name);

            if (controller.CurrentFeature == EFeatureType.TradeRoute || controller.CurrentFeature == EFeatureType.Aqueduct)
            {
                StartCoroutine(controller.FlashCursor());
            }
            else if (controller.CurrentFeature != EFeatureType.None)
            {
                FeatureCosts selectedFeatureCost = featureCosts[controller.CurrentFeature.ToString()];

                Vector2 clickWorldPosition = Camera.main.ScreenToWorldPoint(eventData.position);

                RaycastHit hit;
                Physics.Raycast(clickWorldPosition, new Vector3(0, 0, 1), out hit, 1);

                if (selectedFeatureCost.VerifyCosts(this))
                {
                    if (controller.CurrentFeature != EFeatureType.Village && !hit.collider.name.Contains(controller.CurrentFeature.ToString()))
                    {
                        StartCoroutine(controller.FlashCursor());
                        return;
                    }
                    GameObject newFeature = Instantiate(featurePrefab,
                                                        new Vector3(clickWorldPosition.x, clickWorldPosition.y, 0),
                                                        Quaternion.identity);
                    newFeature.name = controller.CurrentFeature.ToString();
                    newFeature.GetComponent <Feature>().SetUpFeature(this, controller.CurrentFeature, controller);
                    newFeature.GetComponent <BoxCollider>().enabled = false;

                    features.Add(newFeature.gameObject);
                    controller.AddFeature(newFeature.GetComponent <Feature>());
                }
                else
                {
                    StartCoroutine(controller.FlashCursor());
                }
            }
        }
    }