/// <summary>
        /// 
        /// </summary>
        /// <param name="radius">in angstroems (1e(-10)mm)</param>
        /// <param name="temperature"></param>
        /// <param name="density"></param>
        public Habitat(double radius, double temperature, double density, double centerX, double centerY, double desire, double desireRadious )
        {
            this.Temperature = temperature;
            this.Density = density;
            this.Volume = Math.PI * radius * radius;
            this.Density_Current = density;
            this.Radius = radius;
            this.Desire = desire;
            this.DesireRadius = desireRadious;
            Logger = new Logger();

            NewBindingListeners = new List<NewBindingListener>();

            Molecules = new MoleculeContainer(this);
            Molecules.AddMoleculeAddedListener(new MoleculeAddListener(this));

            this.CondensationCenter = new Molecule(this, Molecule.InitMoleculeType.Center);
            this.CondensationCenter.Position.X = centerX;
            this.CondensationCenter.Position.Y = centerY;
            Molecules.Add(CondensationCenter);

            Thread = new Thread(new ThreadStart(this.Start));
        }
Exemple #2
0
    private static void CarsContainerCheck(MoleculeContainer target, Animator animator, MoleculeCar[] cars)
    {
        foreach (var car in cars)
        {
            if (car.State == MoleculeCar.CarState.Waiting)
            {
                var carCargos = car.gameObject.GetComponentsInChildren<MoleculeCarCargo>();

                foreach (var cargo in carCargos)
                {
                    if (!cargo.IsLoaded && cargo.Formula == target.ContainerFormula && target.CollectCount > 5 && !target.IsAnimated)
                    {
                        /*
                        var go = (GameObject)Instantiate(ContainerPrefab, Vector3.zero, Quaternion.identity);
                        go.transform.parent = cargo.gameObject.transform;
                        go.transform.position = cargo.gameObject.transform.position;
                        go.transform.localPosition = Vector3.zero;
                        go.transform.localScale = Vector3.one * 0.001f;
                        */
                        target.IsAnimated = true;

                        target.gameObject.transform.parent = null;
                        var throwTo = target.gameObject.AddComponent<ThrowBehavior>();
                        throwTo.Projectile = target.gameObject.transform;
                        throwTo.Target = cargo.gameObject.transform;
                        throwTo.firingAngle = 45f;
                        var currentCar = car;
                        var currentCargo = cargo;
                        throwTo.AfterThrowAction = new Action(() =>
                        {
                            target.transform.parent = currentCargo.transform;
                            target.transform.position = currentCargo.gameObject.transform.position;
                            target.transform.localPosition = Vector3.zero;
                            target.transform.localScale = Vector3.one * 0.001f;
                            // target.Get(10);
                            currentCargo.IsLoaded = true;
                            if (!target.CanGet(1))
                            {
                                if (animator != null)
                                    animator.ResetTrigger(enoughsourcestrigger);
                            }

                            var stopPoint = GameObject.Find("StopPoint" + currentCar.Index);
                            var coin = stopPoint.GetComponentInChildren<MoleculeCoin>();
                            coin.BornCoin();
                        });
                    }
                }

            }
        }
    }