예제 #1
0
    void Start()
    {
        HideUI();
        HideTimer();
        HideExclamationMark();

        player = CameraController.Instance;
        if (player != null)
        {
            player.OnZoomToWorldView += ShowUI;
            player.OnZoomToPlanet    += HideUI;
        }

        PlanetReceources planet = transform.GetComponentInParent <Planet>().GetComponentInChildren <PlanetReceources>();

        if (planet != null)
        {
            planet.OnPeopleStartLackFood += ShowTimer;
            planet.OnPeopleStartDying    += ShowExplamationMark;


            planet.OnPeopleStopLackFood += HideTimer;
            planet.OnPeopleStopLackFood += HideExclamationMark;
        }
    }
예제 #2
0
    void UnloadTheShip(PlanetReceources targetPlanet)
    {
        UnitResources thisShipResources = GetComponent <UnitResources>();

        if (targetPlanet != null)
        {
            foreach (var resource in thisShipResources.GetResources())
            {
                targetPlanet.AddReceource(resource.Key, resource.Value);
            }
        }
        else
        {
            Debug.Log("The target planet has no PlanetResources component");
        }
        Destroy(this.gameObject);
    }
예제 #3
0
    public void UpdateDefeatStats()
    {
        var defeatStats = Resources.FindObjectsOfTypeAll <DefeatStats>();

        if (defeatStats.Length == 0)
        {
            Debug.LogError("THe scene is missing DefeastStats object");
            return;
        }

        var Planets = FindObjectsOfType <Planet>();

        foreach (var planet in Planets)
        {
            PlanetReceources planetReceources = planet.GetComponentInChildren <PlanetReceources>();
            defeatStats[0].AddLostPlanet(planet.GetComponent <UIInformation>());
        }
    }
예제 #4
0
    void Awake()
    {
        PlanetReceources planetResources = GetComponentInChildren <PlanetReceources>();

        seedNumber  = planetResources.GetRes(Receources.SEEDS);
        waterNumber = planetResources.GetRes(Receources.WATER);
        moneyNumber = planetResources.GetRes(Receources.MONEY);

        birthRateNumber = planetResources.getBirthRateNumber();
        birthRateTime   = planetResources.getBirthRateTime();
        deathRateTime   = planetResources.getDeathRateInteval();

        seedConsumptionAmount = planetResources.getSeedComsumptionAmount();
        seedConsumptionTime   = planetResources.getSeedComsumptionTime();

        waterConsumtionAmount = planetResources.getWaterComsumptionAmount();
        waterConsumtionTime   = planetResources.getWaterComsumptionTime();

        planetPopulation = planetResources.getPopulation();

        if (Farm != null)
        {
            seedProductionAmount = Farm.GetComponent <ReceourceZone>().GetProductionAmount();
            seedProductionTime   = Farm.GetComponent <ReceourceZone>().GetProductivityTime();
        }
        if (Water != null)
        {
            waterProductionAmount = Water.GetComponent <ReceourceZone>().GetProductionAmount();
            waterProductionTime   = Water.GetComponent <ReceourceZone>().GetProductivityTime();
        }
        if (Mine != null)
        {
            moneyProductionAmount = Mine.GetComponent <ReceourceZone>().GetProductionAmount();
            moneyProductionTime   = Mine.GetComponent <ReceourceZone>().GetProductivityTime();
        }
    }
예제 #5
0
 private void Start()
 {
     planetReceources = GetComponentInParent <Planet>()?.GetComponentInChildren <PlanetReceources>();
 }