Esempio n. 1
0
        public void SetTraveler(int health_population, int infect_population, Sprite sprite, Village destination, Village originate, DiseaseSO disease, int timecost, OnReachDestiny reachCallback)
        {
            spriteRenderer.sprite  = sprite;
            this.health_population = health_population;
            this.infect_population = infect_population;

            this.destination = destination;
            this.originate   = originate;
            this.timecost    = timecost;
            this.timeSpent   = 0;

            possibleDisease = disease;

            this.reachCallback = reachCallback;

            transform.position = originate.transform.position;

            infectIndicatorSprite.enabled = (infect_population > 0);
        }
Esempio n. 2
0
        private void MoveToConnectVillage()
        {
            var       connectedVillages = _villageManager.FindAllConnectVillage(ID);
            DiseaseSO randomDisease     = null;

            //Apply Quarantine Skill
            if (actionHandler.GetValue(StatFlag.ActionStat.Quarantine, ID) > 0)
            {
                return;
            }

            if (diseases.Count > 0)
            {
                randomDisease = diseases[Random.Range(0, diseases.Count)];
            }

            foreach (var c_village in connectedVillages)
            {
                float travelerSpawnRate = 0.35f * ActionHandler.travelerRate;
                float rdnValue          = Random.Range(0, 1f);

                bool spawnTraveler = rdnValue < travelerSpawnRate;
                if (!spawnTraveler || c_village.isVillageDestroy)
                {
                    continue;
                }

                int totalLeavePopulation  = Mathf.RoundToInt(totalPopulation * travalerRate);
                int infectLeavePopulation = Mathf.RoundToInt(totalLeavePopulation * infectRate);

                //Tech Effect
                if (ActionHandler.infectedDetectionRate > rdnValue && infectLeavePopulation > 0)
                {
                    return;
                }

                _villageManager.CreateTravler(this, c_village, totalLeavePopulation, infectLeavePopulation, randomDisease);

                _healthpopulation -= totalLeavePopulation - infectLeavePopulation;
                _infectPopulation -= infectLeavePopulation;
            }
        }
        public void CreateTravler(Village originate, Village desitination, int health_population, int infect_population, DiseaseSO carryDisease)
        {
            if (spritePackerSo == null)
            {
                return;
            }

            var      travelObject = UtilityMethod.CreateObjectToParent(travelerHolders.transform, travelerPrefab.gameObject);
            Traveler traveler     = travelObject.GetComponent <Traveler>();
            Sprite   RandomSprite = spritePackerSo.FindSpriteByRandom();

            int timeCost = Random.Range(2, 5);

            traveler.SetTraveler(health_population, infect_population, RandomSprite, desitination, originate, carryDisease, timeCost, OnTravelersReachDestination);

            _travelers.Add(traveler);
        }