Exemple #1
0
 private void pbxInseminate_Click(object sender, EventArgs e)
 {
     //什么时候可以种植
     if (PlantState != PlantState.Nothing && PlantState != PlantState.Harvest && PlantState != PlantState.Inseminate)
     {
         MessageBox.Show("还未收获,无法播种!");
         return;
     }
     //
     this.PlantState = PlantState.Inseminate;
     this.cpbxSeed   = new CPictureBox();
     //
     this.cpbxSeed.BackColor             = System.Drawing.Color.Transparent;
     this.cpbxSeed.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
     this.cpbxSeed.Image    = ChuffedFarm.Properties.Resources.seed2;
     this.cpbxSeed.Size     = new System.Drawing.Size(ChuffedFarm.Properties.Resources.seed2.Width, ChuffedFarm.Properties.Resources.seed2.Height);//52.28
     this.cpbxSeed.Location = new System.Drawing.Point(this.pbxInseminate.Location.X - 50, this.pbxInseminate.Location.Y - 80);
     //
     this.cpbxSeed.TabStop      = true;
     this.cpbxSeed.IsInseminate = false;//刚刚创建种子实例,还未种下
     this.cpbxSeed.Click       += new System.EventHandler(this.cpbxSeed_Click);
     this.Controls.Add(this.cpbxSeed);
     //
     tipSeed.SetToolTip(this.cpbxSeed, "这是种子");
 }
Exemple #2
0
        private void pbxBlossomOut_Click(object sender, EventArgs e)
        {
            if (PlantState == PlantState.Nothing)
            {
                MessageBox.Show("还未播种,能开花吗?", "信息提示!");
                return;
            }

            if (PlantState == PlantState.Inseminate)
            {
                MessageBox.Show("刚刚播完种,还未生长,能开花吗?", "信息提示!");
                return;
            }
            if (PlantState == PlantState.MakeFruitage)
            {
                MessageBox.Show("正在结果,不能开花了!", "信息提示!");
                return;
            }
            if (PlantState == PlantState.Harvest)
            {
                MessageBox.Show("农场里都没有农作物了,怎么开花呀!", "信息提示!");
                return;
            }

            this.PlantState = PlantState.BlossomOut;
            IEnumerable <Control> cons = this.GetCPictureBoxes();

            foreach (CPictureBox cpbx in cons)
            {
                cpbx.Image = ChuffedFarm.Properties.Resources.bloom;
            }
        }
Exemple #3
0
        private void pbxVegetate_Click(object sender, EventArgs e)
        {
            if (PlantState == PlantState.Nothing)
            {
                MessageBox.Show("还未播种,怎么长啊", "信息提示!");
                return;
            }
            if (PlantState == PlantState.BlossomOut)
            {
                MessageBox.Show("正在开花,不能进入生长期!", "信息提示!");
                return;
            }
            if (PlantState == PlantState.MakeFruitage)
            {
                MessageBox.Show("正在结果,不能进入生长期!", "信息提示!");
                return;
            }

            if (PlantState == PlantState.Harvest)
            {
                MessageBox.Show("农场里都没有农作物了,怎么长呀!", "信息提示!");
                return;
            }

            this.PlantState = PlantState.Vegetate;

            IEnumerable <Control> cons = this.GetCPictureBoxes();

            foreach (CPictureBox cpbx in cons)
            {
                tipSeed.SetToolTip(cpbx, "");//已经开始生长,不再是种子,无需提示
                cpbx.Size  = new Size(ChuffedFarm.Properties.Resources.grow.Width, ChuffedFarm.Properties.Resources.grow.Height);
                cpbx.Image = ChuffedFarm.Properties.Resources.grow;
            }
        }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        setCantGoUp();


        stateChangeCountdown -= Time.deltaTime;

        if (stateChangeCountdown <= 0)
        {
            //Change the state to the next one
            if (!((currentState == PlantState.IdleFallen) && cantGoUp))
            {
                currentState         = Next(currentState);
                stateChangeCountdown = timeBetweenStates;
            }
        }
        else
        {
            //Animate current state
            if (currentState == PlantState.Rise)
            {
                float percentBetweenState = stateChangeCountdown / timeBetweenStates;
                float y = Mathf.Lerp(risenPosition.y, fallenPosition.y, percentBetweenState);
                transform.position = new Vector2(transform.position.x, y);
            }
            else if (currentState == PlantState.Fall)
            {
                float percentBetweenState = stateChangeCountdown / timeBetweenStates;
                float y = Mathf.Lerp(fallenPosition.y, risenPosition.y, percentBetweenState);
                transform.position = new Vector2(transform.position.x, y);
            }
        }
    }
Exemple #5
0
        private void pbxMakeFruitage_Click(object sender, EventArgs e)
        {
            if (PlantState == PlantState.Nothing)
            {
                MessageBox.Show("还未播种,能结果吗?", "信息提示!");
                return;
            }

            if (PlantState == PlantState.Inseminate)
            {
                MessageBox.Show("刚刚播完种,还未生长,能结果吗?", "信息提示!");
                return;
            }

            if (PlantState == PlantState.Vegetate)
            {
                MessageBox.Show("还处在生长期,并未开花,能结果吗?", "信息提示!");
                return;
            }

            if (PlantState == PlantState.Harvest)
            {
                MessageBox.Show("农场里都没有农作物了,怎么结果呀!", "信息提示!");
                return;
            }

            this.PlantState = PlantState.MakeFruitage;
            IEnumerable <Control> cons = this.GetCPictureBoxes();

            foreach (CPictureBox cpbx in cons)
            {
                cpbx.Image = ChuffedFarm.Properties.Resources.fruit;
            }
        }
Exemple #6
0
    void Update()
    {
        if (initialized)
        {
            PlantState state = plantInstance.GetCurrentState();
            if (state == PlantState.Default && plantData.instantIgnite)
            {
                Ignite(true);
            }

            if (state == PlantState.Depleted)
            {
                keepAliveDeltaTime += Time.deltaTime;
                if (keepAliveDeltaTime > plantData.keepAlive)
                {
                    Destroy(gameObject);
                }
            }

            if (plantInstance.DidStateChange())
            {
                UpdateDisplayMesh();
            }
        }
    }
Exemple #7
0
    public InteractionResult Harvest(Transform parent)
    {
        switch (currentPlantState)
        {
        case PlantState.NotReady:
            return(new InteractionResult(null, false, false));

        case PlantState.Harvestable:
            Destroy(currentPlant);
            bool destroyed = true;
            if (multipleHarvests)
            {
                currentPlantState = PlantState.NotReady;
                currentPlantPhase = afterHarvestStage;
                plantGrowth       = plantPhases[currentPlantPhase].requiredGrowth;
                currentPlant      = Instantiate(plantPhases[currentPlantPhase].gameObject, transform);
                destroyed         = false;
            }
            else
            {
                Destroy(gameObject);
                destroyed    = true;
                currentPlant = null;
            }
            return(new InteractionResult(Instantiate <Fruit>(fruit, parent), true, destroyed));

        case PlantState.Dead:
            Destroy(currentPlant);
            currentPlant = null;
            return(new InteractionResult(null, true, true));;
        }
        return(new InteractionResult(null, false, false));
    }
Exemple #8
0
        // Looks for target plants, and starts moving towards the first one it finds
        private bool ScanForTargetPlant()
        {
            try
            {
                ArrayList foundCreatures = Scan();

                if (foundCreatures.Count > 0)
                {
                    // Always move after closest plant or defend closest creature if there is one
                    foreach (OrganismState organismState in foundCreatures)
                    {
                        if (organismState is PlantState)
                        {
                            targetPlant = (PlantState)organismState;
                            BeginMoving(new MovementVector(organismState.Position, 2));
                            return(true);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                WriteTrace(exc.ToString());
            }
            return(false);
        }
Exemple #9
0
        // Looks for target plants, and starts moving towards the first one it finds
        bool ScanForTargetPlant()
        {
            try
            {
                // Find all Plants/Animals in range
                ArrayList foundAnimals = Scan();

                // If we found some Plants/Animals lets try
                // to weed out the plants.
                if (foundAnimals.Count > 0)
                {
                    foreach (OrganismState organismState in foundAnimals)
                    {
                        // If we found a plant, set it as our target
                        // then begin moving towards it.  Tell the
                        // caller we have a target.
                        if (organismState is PlantState)
                        {
                            targetPlant = (PlantState)organismState;
                            BeginMoving(new MovementVector(organismState.Position, 2));
                            return(true);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                WriteTrace(exc.ToString());
            }

            // Tell the caller we couldn't find a target
            return(false);
        }
Exemple #10
0
        public void UpdateTimeData(object sender, ElapsedEventArgs e)
        {
            TimeSpan timeElapsed = e.SignalTime - timeKeeper.StartTime;

            PlantState newPlantState = plant.CurrentPlantState;

            if (plant.PlantName != plantNameButton.Text)
            {
                plantNameButton.Text = plant.PlantName.ToString();
            }

            if (timeElapsed.TotalSeconds < 100)
            {
                newPlantState = PlantState.healthy;
            }
            else if (timeElapsed.TotalSeconds < 200)
            {
                newPlantState = PlantState.nothealthy;
            }
            else if (timeElapsed.TotalSeconds >= 200)
            {
                newPlantState = PlantState.withered;
            }

            if (newPlantState != plant.CurrentPlantState)
            {
                plant.CurrentPlantState = newPlantState;
                UpdateUI();
            }
        }
Exemple #11
0
 public void UseCurItems(ItemController.items curItem)
 {
     if (myWeatherController.curWeather == myWeatherController.weatherPairs[curItem])
     {
         curState = PlantState.Growing;
     }
 }
Exemple #12
0
 public void initialization()
 {
     curStage  = 0;
     curHealth = initHealth;
     curState  = PlantState.Growing;
     myPlantDisplay.initialization();
 }
Exemple #13
0
 public void Reset()
 {
     name        = "から";
     nowGrowth   = 0f;
     growthSpeed = 0f;
     quality     = 50;
     plantState  = PlantState.None;
 }
Exemple #14
0
 public void Plant()
 {
     if (plantState == PlantState.Fallow)
     {
         plantDirector.Play();
         plantState = PlantState.Planted;
     }
 }
Exemple #15
0
 public void Harvest()
 {
     if (plantState == PlantState.Grown)
     {
         harvestDirector.Play();
         plantState = PlantState.Fallow;
     }
 }
Exemple #16
0
 public void Grow()
 {
     if (plantState == PlantState.Planted)
     {
         growDirector.Play();
         plantState = PlantState.Grown;
     }
 }
Exemple #17
0
        /*
         * ~plant_1()
         * {
         *  AmmoList.Clear();
         *  m_g.Dispose();
         *  m_timer.Dispose();
         *  foreach(Bitmap bitmap in bitmap)
         *  {
         *      bitmap.Dispose();
         *  }
         * }
         *///尝试手动释放对象

        /*
         * public void LoadBitmap(string FileLocation)
         * {
         * bitmap = new Bitmap[12];
         * string Filename;
         * for (int i=0;i<=11;i++)
         * {
         * Filename = FileLocation + i.ToString() + ".png";
         * bitmap[i] = new Bitmap(Filename);
         * }
         * }
         */
        public void BeHit(int damage)
        {
            HP -= damage;
            if (HP <= 0)
            {
                NowPlantState = PlantState.Die;
            }
        }
Exemple #18
0
 public Plant(PlantState p = PlantState.DontUse)
 {
     name        = "から";
     nowGrowth   = 0f;
     growthSpeed = 0f;
     quality     = 50;
     plantState  = p;
     fertilizers = new List <FertilizerData>();
 }
Exemple #19
0
        private void Awake()
        {
            // Components
            touchAreaObserver = GetComponent <TouchAreaObserver>();
            lineRenderer      = GetComponent <LineRenderer>();

            // Coroutines
            state = PlantState.Growing;
        }
Exemple #20
0
 public void ConsumeFuel(float deltaTime)
 {
     fuel = fuel - (burnRate * deltaTime);
     if (fuel <= 0)
     {
         fuel         = 0;
         currentState = PlantState.Depleted;
     }
 }
Exemple #21
0
 public PlantStateHandler(DateTime startTime, PlantState currentState)
 {
     _statesDuration = new Dictionary <PlantState, TimeSpan>();
     _startTime      = startTime;
     CurrentState    = currentState;
     _statesDuration.Add(PlantState.Off, new TimeSpan(0));
     _statesDuration.Add(PlantState.OnRunning, new TimeSpan(0));
     _statesDuration.Add(PlantState.OnStopped, new TimeSpan(0));
 }
Exemple #22
0
        /// <summary>
        ///  Percentage of light reaching this plant.
        ///  We assume the sun moves from east to west directly overhead
        ///
        ///  We get a rough estimation like this:
        ///  Get all plants with a certain radius whose radius blocks any East-West vector that intersects
        ///  any part of the radius of the plant in question -- assume they block it completely
        ///  Figure out which blocks it at the highest angle.
        ///  Discount the amount of light the plant sees by angle / 180
        /// </summary>
        /// <param name="plant">The plant to get light for.</param>
        /// <returns>The amount of available light for the plant.</returns>
        public int GetAvailableLight(PlantState plant)
        {
            var maxX = plant.GridX + plant.CellRadius + 25;

            if (maxX > _gridWidth - 1)
            {
                maxX = _gridWidth - 1;
            }
            var overlappingPlantsEast = FindOrganismsInCells(plant.GridX + plant.CellRadius,
                                                             maxX, plant.GridY - plant.CellRadius,
                                                             plant.GridY + plant.CellRadius);

            var minX = plant.GridX - plant.CellRadius - 25;

            if (minX < 0)
            {
                minX = 0;
            }
            var overlappingPlantsWest = FindOrganismsInCells(minX, plant.GridX - plant.CellRadius,
                                                             plant.GridY - plant.CellRadius,
                                                             plant.GridY + plant.CellRadius);

            double maxAngleEast = 0;

            foreach (OrganismState targetPlant in overlappingPlantsEast)
            {
                if (!(targetPlant is PlantState))
                {
                    continue;
                }
                var currentAngle = Math.Atan2(((PlantState)targetPlant).Height,
                                              targetPlant.Position.X - plant.Position.X);
                if (currentAngle > maxAngleEast)
                {
                    maxAngleEast = currentAngle;
                }
            }

            double maxAngleWest = 0;

            foreach (OrganismState targetPlant in overlappingPlantsWest)
            {
                if (!(targetPlant is PlantState))
                {
                    continue;
                }
                var currentAngle = Math.Atan2(((PlantState)targetPlant).Height,
                                              plant.Position.X - targetPlant.Position.X);
                if (currentAngle > maxAngleWest)
                {
                    maxAngleWest = currentAngle;
                }
            }

            return((int)(((Math.PI - maxAngleEast + maxAngleWest) / Math.PI) * 100));
        }
Exemple #23
0
    public bool DidStateChange()
    {
        bool result = currentState != previousState;

        if (result)
        {
            previousState = currentState;
        }
        return(result);
    }
Exemple #24
0
    public void setSeeded()
    {
        if (m_pState > PlantState.seed)
        {
            return;
        }

        m_pState = PlantState.seed;
        animateToNextState();
    }
        public override void Move(float TimeElapsed)
        {
            Time += TimeElapsed;
            if (Time >= 10)
            {
                Time = 0;
            }
            if (Time < 2)
            {
                lethal    = true;
                shoot     = true;
                velocityY = -30;
                state     = PlantState.grow;
            }
            else if (Time < 4)
            {
                velocityY = 0;
                state     = PlantState.look;
            }
            else if (Time < 5)
            {
                if (shoot)
                {
                    Bullet bullet = new Bullet(new Rectangle(rectangle.X, rectangle.Y, 16, 16), null);
                    bullet.SetVelocity(new Vector2(scene.player.rectangle.X, scene.player.rectangle.Y), new Vector2(this.rectangle.X, this.rectangle.Y));
                    bullet.velocityX *= 3;
                    bullet.velocityY *= 3;
                    scene.QueryAddGameObject(bullet);
                    shoot = false;
                }
                state = PlantState.shoot;
            }
            else if (Time < 6)
            {
                state = PlantState.look;
            }
            else if (Time < 8)
            {
                velocityY = 30;
                state     = PlantState.grow;
            }
            else
            {
                lethal    = false;
                velocityY = 0;
            }
            rectangle.Y += velocityY * TimeElapsed;

            if (lethal && (GetHitSide || GetHitTopLeft || GetHitTopRight))
            {
                scene.player.GetHit(this);
            }

            //base.Move(TimeElapsed);
        }
Exemple #26
0
        public void GetAndSetStateWorksProperly()
        {
            // Given
            PlantState state = PlantState.Deceased;

            // When
            DomainObject.State = state;

            // Then
            DomainObject.State.Should().Be(state);
        }
Exemple #27
0
    public PlantInstance(PlantData plantData)
    {
        data = plantData;

        fuel     = plantData.GetInitialFuel();
        scale    = plantData.GetScale(fuel);
        burnRate = plantData.GetBurnRate();

        currentState  = PlantState.Default;
        previousState = currentState;
    }
Exemple #28
0
        public void GetPlantStateTest()
        {
            //ARRANGE
            var        plantState     = new PlantStates();
            PlantState plant          = PlantState.healthy;
            var        expectedResult = "healthy";

            //ACT
            PlantState result = plantState.GetPlantState(expectedResult);

            //ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #29
0
 public void SetPlantOnFire()
 {
     try
     {
         plantState = PlantState.Burning;
         plantRenderer.material.color = Color.red;
         StartCoroutine("BurningPlant");
     }
     catch (Exception e)
     {
         print(e.Message);
     }
 }
Exemple #30
0
        /// <summary>
        ///  Initializes a new state object with the given position and family generation
        /// </summary>
        /// <param name="position">The position of the new PlantState</param>
        /// <param name="generation">The family generation of the new Plant</param>
        /// <returns>A state object initialized to the given position and generation.</returns>
        public override OrganismState InitializeNewState(Point position, int generation)
        {
            // Need to start out hungry so they can't reproduce immediately and just populate the world
            var initialEnergy = EnergyState.Hungry;

            var newState = new PlantState(Guid.NewGuid().ToString(), this, generation, initialEnergy, InitialRadius)
            {
                Position = position
            };

            newState.ResetGrowthWait();
            return(newState);
        }
Exemple #31
0
 /*
  * Sets the plant to initialze to the adult state.
  */
 public void StartAsAdult ()
 {
     initialState = PlantState.Ripe;
 }
Exemple #32
0
 /*
  * Set the Plant's state to the specified state and render it.
  */
 private void SetPlantState (PlantState newState)
 {
     plantState = newState;
     if (newState == PlantState.Withered || (newState == PlantState.Ripe && !isRepickable)) {
         canBeWatered = false;
         ShowIfDry ();
     } else {
         canBeWatered = true;
     }
     RenderPlantState ();
 }
Exemple #33
0
        // Initialize the plant fields
        public override void Initialize()
        {
            animations = new List<Animation>();
            plantState = PlantState.NORMAL;
            health = 100;

            SetAnimation();
            SetPosition();
            base.Initialize();
        }
Exemple #34
0
 // Change plant state
 protected virtual void ChangeState(PlantState plantState)
 {
     this.plantState = plantState;
 }