public void Update(GameTime gameTime)
        {
            // Fixture is removed from the body OR the body is Destroyed OR the fixture have a joint
            if (connectedFixture.GetBody() == null || connectedFixture.GetBody().GetFixtureList() == null
                || connectedFixture.GetUserData() is Branch)
                State = LeafState.Drop;

            if (State == LeafState.Grow)
            {
                scale = Math.Min(scale + 0.01f, 1f);

                rotation += rotaionDirection * (float)Math.PI / 1000;

                if (Math.Abs(rotation - oriRotation) > MaxRotation)
                {
                    rotation = oriRotation + rotaionDirection * MaxRotation;
                    rotaionDirection *= -1;
                }

                AABB aabb; connectedFixture.GetAABB(out aabb);
                position = aabb.GetCenter();
            }
            if (State == LeafState.Drop)
            {
                position += new Vector2(0, 1);
                rotation += rotaionDirection * (float)Math.PI / 700;

                if (position.Y > gameContent.viewport.Height * 1.5f) State = LeafState.Dead;
            }
        }
Exemplo n.º 2
0
        /// <summary>Initial constructor</summary>
        /// <param name="universe">The universe of this LeafLayer.</param>
        /// <param name="i">The index of this leaf Layer (0 based index, starts from the bottom of the plant).</param>
        public LeafLayer(Universe universe, int i, double cumulTTShoot, int roundedFinalNumber, double finalLeafNumber, double phyllochron, double deltaTTShoot, double deltaTTPhenoMaize, double cumulTTPhenoMaizeAtEmergence)
            : base(universe, i, cumulTTShoot)
        {
            LayerPhyllochron = phyllochron;

            IsSmallPhytomer = isSmallPhytomer(finalLeafNumber, roundedFinalNumber);

            if (!IsSmallPhytomer)
            {
                TTmat = PlagLL * LayerPhyllochron;
                TTsen = PsenLL * LayerPhyllochron;
            }
            else
            {
                TTmat = PlagSL * LayerPhyllochron;
                TTsen = PsenSL * LayerPhyllochron;
            }


            DeltaAI            = 0;
            DeltaDM            = 0;
            IsPrematurelyDying = false;
            MaxAI         = 0;
            State         = LeafState.Growing;
            exposedSheath = new ExposedSheath(universe);
            leafLamina    = new LeafLaminae(universe);
            interNode     = new InterNode(universe, roundedFinalNumber, IsSmallPhytomer, Index, PhytoNum);

            if (SwitchMaize)
            {
                maizeLeaf = new MaizeLeaf(universe, i, cumulTTPhenoMaizeAtEmergence, finalLeafNumber, deltaTTPhenoMaize);
            }
        }
Exemplo n.º 3
0
 public void FadePetal(float fadePercent)
 {
     petal.CrossFadeAlpha(fadePercent, 1.0f, true);
     if (fadePercent == 0.0f)
     {
         state = LeafState.Closed;
     }
 }
Exemplo n.º 4
0
 public void Reset()
 {
     if (petal != null)
     {
         petal.CrossFadeAlpha(1, 0.4f, true);
         state = LeafState.Opened;
     }
 }
Exemplo n.º 5
0
 public override void GoToState(ConfigLeafNode theLeafNode, LeafState nextState)
 {
     if (nextState == LeafState.DPAPIMACHINEEncrypted) return;
     string text = _isCommitted ? "<Reset Value>" : StringContent;
     switch (nextState)
     {
         case LeafState.DPAPIUSerEncrypted :
             theLeafNode.State = new DPAPIUserState(text);
             break;
         case LeafState.Plain:
             theLeafNode.State = new PlainLeafNodeState(text);
             break;
     }
 }
Exemplo n.º 6
0
        // #Andrea 01/12/2015 - renamed deltaTTShoot to deltaTTRemobilization
        ///Virtual method to init the Element at the beginning of a day step.
        public void InitDayStep(double deltaTTRemobilization, LeafState LLState, bool isPrematurelyDying)
        {
            N.InitDayStep();
            DM.InitDayStep();

            if ((LLState == LeafState.Mature ||
                 LLState == LeafState.Senescing) &&
                !isPrematurelyDying)
            {
                //N.InitDayStepDailyLabile(N.Labile * MaxLeafRRND * deltaTTShoot);  // pm 29 May 2013, replaced air temperature by canopy temperature - modified by #Andrea 01/12/2015
                N.InitDayStepDailyLabile(N.Labile * MaxLeafRRND * deltaTTRemobilization); // #Andrea 01/12/2015
            }
            else
            {
                N.InitDayStepDailyLabile(0);
            }

            DailyLabileSenescenceN = 0;
        }
Exemplo n.º 7
0
 ///<summary>Copy constructor</summary>
 ///<param name="universe">The universe of this leaf Layer.</param>
 ///<param name="toCopy">The leaf Layer to copy</param>
 public LeafLayer(Universe universe, LeafLayer toCopy)
     : base(universe, toCopy)
 {
     LayerPhyllochron   = toCopy.LayerPhyllochron;
     TTmat              = toCopy.TTmat;
     TTsen              = toCopy.TTsen;
     DeltaAI            = toCopy.DeltaAI;
     IsPrematurelyDying = toCopy.IsPrematurelyDying;
     MaxAI              = toCopy.MaxAI;
     State              = toCopy.State;
     IsSmallPhytomer    = toCopy.IsSmallPhytomer;
     exposedSheath      = (toCopy.exposedSheath != null) ? new ExposedSheath(universe, toCopy.exposedSheath) : null;
     leafLamina         = (toCopy.leafLamina != null) ? new LeafLaminae(universe, toCopy.leafLamina) : null;
     interNode          = (toCopy.interNode != null) ? new InterNode(universe, toCopy.interNode) : null;
     if (SwitchMaize)
     {
         maizeLeaf = (toCopy.maizeLeaf != null) ? new MaizeLeaf(universe, toCopy.maizeLeaf) : null;
     }
 }
 public abstract void GoToState(ConfigLeafNode theLeafNode, LeafState nextState);
Exemplo n.º 9
0
 private void Start()
 {
     petal = GetComponent <Image>();
     state = LeafState.Opened;
 }
 public void Drop()
 {
     State = LeafState.Drop;
 }
 public void setState(LeafState newState)
 {
     State = newState;
 }
 public void Drop()
 {
     if (State == LeafState.Grow)
     {
         if (revoJoint.GetBodyB().GetFixtureList() != null)
             world.DestroyJoint(revoJoint);
         State = LeafState.Drop;
     }
 }
        private void CreatBody()
        {
            State = LeafState.Drop;

            BodyDef bd = new BodyDef();
            bd.type = BodyType.Dynamic;
            CircleShape cShape = new CircleShape();
            cShape._radius = texture.Width / 2 - 3;
            cShape._p = new Vector2(0, cShape._radius + 1);
            FixtureDef fd = new FixtureDef();
            fd.density = 0.001f;
            fd.friction = 0.5f;
            fd.restitution = 0.0f;
            fd.shape = cShape;
            //fd.filter.groupIndex = -1;
            //fd.filter.categoryBits = 2;
            //fd.filter.maskBits = 4;

            body = world.CreateBody(bd);
            body.CreateFixture(fd);

            scale = 0;
        }
        public void Update(GameTime gameTime)
        {
            // Fixture is removed from the body OR the body is Destroyed OR the fixture have a joint
            if (State == LeafState.Grow && connectedFixture != null && (connectedFixture.GetBody() == null
                || connectedFixture.GetBody().GetFixtureList() == null
                || connectedFixture.GetUserData() is Branch))
                Drop();

            scale = Math.Min(scale + 0.008f, 1f);
            AddBranch = false;

            if (State == LeafState.Drop)
            {
                if (body.Position.Y > gameContent.viewport.Height * 1.5f) State = LeafState.Dead;

                bool groundContact = false;
                for (ContactEdge ce = body.GetContactList(); ce != null; ce = ce.Next)
                    if (ce.Contact.IsTouching() && ce.Other.GetType() == BodyType.Static)
                        groundContact = true;

                if (groundContact) time += (float)gameTime.ElapsedGameTime.TotalSeconds;
                else time = 0;

                if (time > MaxTime) State = LeafState.Dead; ;

                if (fallenFromAir && time > MaxTime / 2)
                {
                    State = LeafState.Dead;
                    CreateStem();
                }
            }

            if (State == LeafState.Dead)
            {
                if (body.GetFixtureList() != null) body.GetWorld().DestroyBody(body);

                else if (fallenFromAir && (stem == null || stem.body.GetFixtureList() == null))
                {
                    CreatBody();
                    body.Position = originalPostion;
                }
            }
        }
Exemplo n.º 15
0
        public void GoToState(ConfigLeafNode theLeafNode, LeafState nextState)
        {
            if (nextState == LeafState.Plain) return;

            EncryptedLeafNodeState newState = null;

            if (nextState == LeafState.DPAPIMACHINEEncrypted)
            {
                newState = new DPAPIMachineState(StringContent);
            }

            if (nextState == LeafState.DPAPIUSerEncrypted)
            {
                newState = new DPAPIUserState(StringContent);
            }
            theLeafNode.State = newState;
        }