Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Field  field          = null;
            string infectionsFile = null;
            bool   showHelp       = false;

            OptionSet p = new OptionSet()
                          .Add("h|?|help", (v) =>
            {
                showHelp = v != null;
            })
                          .Add("f|field=", (v) =>
            {
                if (v != null)
                {
                    field = new Field(v);
                }
            })
                          .Add("i|infections=", (v) => {
                if (v != null)
                {
                    infectionsFile = v;
                }
            })
                          .Add("nolog", (v) => {
                Logger.Instance.Disabled = true;
            });
            List <string> extra = p.Parse(args);

            if (showHelp)
            {
                Console.WriteLine(p.ToString());
            }
            else
            {
                if (field == null)
                {
                    field = new Field(SIZE_X, SIZE_Y, MIN_HEALTH, MAX_HEALTH);
                }

                Population infections =
                    (infectionsFile == null)
          ? new Population(POPULATION_SIZE)
          : new Population(POPULATION_SIZE, infectionsFile);

                Infection res = start(field, infections);

                Console.WriteLine("Winner: {0}", res.ToString());
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
    void Tick()
    {
        if (Infection != null)
        {
            timeSinceInfection++;

            if (!permanentlyInfected && Random.value < 0.01F / GetTraitValue("virus_resistance"))
            {
                immunity.Add(Infection.ToString());
                SetInfection(null);
                navMeshAgent.speed = GetTraitValue("movement_speed") * 3.5F;
            }
        }

        if (!IsInside() && lastPosition == transform.position)
        {
            stuckCounter++;

            if (stuckCounter > 5)
            {
                if (CurrentState == EntityState.Going_Home && Vector3.Distance(transform.position, home.transform.position) < 10F)
                {
                    EnterHome();
                }

                movingTarget   = null;
                targetPosition = NewTarget();
            }
        }
        else
        {
            stuckCounter = 0;
        }

        lastPosition = transform.position;

        if (!IsInside() && outdatedPath && navMeshAgent.isOnNavMesh)
        {
            navMeshAgent.SetDestination(targetPosition);
            outdatedPath = false;
        }

        if (!IsInside() && Random.value < GetTraitValue("cough_rate") * 0.05F)
        {
            Energy -= 3;
            Cough();
        }
    }