private void CreatePlantsCard()
    {
        Vector3 position = plantCard.transform.position;

        if (PlantsService.plants.Length > 0)
        {
            plantCard.SetActive(true);
        }
        else
        {
            noPlantsCard.SetActive(true);
        }

        foreach (Plant plant in PlantsService.plants)
        {
            Debug.Log("Request Status: " + plant._request.status);

            position = new Vector3(position.x, position.y, position.z);
            GameObject card = (GameObject)Instantiate(plantCard, position, Quaternion.identity);
            card.transform.SetParent(GameObject.Find("List").transform, false);

            PlantCard plantCardScript = card.GetComponent <PlantCard>();
            plantCardScript.UpdatePlantCard(plant);
        }

        plantCard.gameObject.SetActive(false);
        AlertsService.removeLoadingAlert();
    }
Esempio n. 2
0
        //鼠标是否进入卡牌或者阳光的范围的逻辑计算
        public bool enterCardOrSun(int x, int y)
        {
            //初始化鼠标坐标
            map.MouseX = x;
            map.MouseY = y;
            //判断
            for (int i = 0; i < map.Suns.Count; i++)
            {
                Sun sun = (Sun)map.Suns[i];
                if (sun.isContact(x, y))
                {
                    return(true);
                }
            }
            for (int i = 0; i < map.Plantscards.Count; i++)
            {
                PlantCard pc = (PlantCard)map.Plantscards[i];
                if (pc.isContact(x, y))
                {
                    //通知模型层应该绘制对植物的介绍
                    map.IsIntroduce = true;
                    map.Pc          = pc;
                    return(true);
                }
            }
            map.IsIntroduce = false;

            return(false);
        }
Esempio n. 3
0
        private void AnimateIncomingCardDuringSwipe(PlantCard nextCard, double percentFromCenter)
        {
            // opacity fading in
            nextCard.MainImage.Opacity = LimitToRange(percentFromCenter * 1.5, 0, 1);

            // scaling in
            nextCard.MainImage.Scale = LimitToRange(percentFromCenter * 1.1, 0, 1);

            var offset = _plantImageTranslationY + (_movementFactor * (1 - (percentFromCenter * 1.1)));

            nextCard.MainImage.TranslationY = LimitToRange(offset, _plantImageTranslationY, _plantImageTranslationY + _movementFactor);
        }
Esempio n. 4
0
 //是否点击卡牌
 public bool clickCard(int x, int y)
 {
     for (int i = 0; i < map.Plantscards.Count; i++)
     {
         PlantCard pc = (PlantCard)map.Plantscards[i];
         if (pc.isClick(x, y))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 5
0
        private void AnimateFrontCardDuringSwipe(PlantCard card, double percentFromCenter)
        {
            // Opacity of the front card during swipe
            MainCardView.CurrentView.Opacity = LimitToRange((1 - (percentFromCenter)) * 2, 0, 1);

            //Scaling on the main card during swipe
            card.MainImage.Scale = LimitToRange((1 - (percentFromCenter) * 1.5), 0, 1);

            // y offset of image during swipe
            card.MainImage.TranslationY = _plantImageTranslationY + (_movementFactor * percentFromCenter);

            // adjust opacity of image
            card.MainImage.Opacity = LimitToRange((1 - (percentFromCenter)) * 1.5, 0, 1);
        }
Esempio n. 6
0
        public override void Draw(Graphics g)
        {
            if (backgroundImage != null)
            {
                g.DrawImage(backgroundImage, -(int)(MyAPI.GamePanelX * 1.0), 0, 1400, 600);
            }
            for (int i = 0; i < plants.Count; i++)
            {
                Plant p = (Plant)plants[i];
                p.Draw(g);
            }

            for (int i = 0; i < zombies.Count; i++)
            {
                Zombie zombie = (Zombie)zombies[i];
                zombie.Draw(g);
            }

            for (int i = 0; i < cleaners.Count; i++)
            {
                Cleaner c = (Cleaner)cleaners[i];
                c.Draw(g);
            }


            for (int i = 0; i < plantscards.Count; i++)
            {
                PlantCard pc = (PlantCard)plantscards[i];
                pc.Draw(g);
            }

            for (int i = 0; i < bullets.Count; i++)
            {
                //Bullet b = (Bullet)bullets[i];
                ((Bullet)bullets[i]).Draw(g);
            }

            for (int i = 0; i < suns.Count; i++)
            {
                Sun sun = (Sun)suns[i];
                sun.Draw(g);
            }

            if (pb.IsAcitive != false)
            {
                pb.Draw(g);
            }
            if (shovel != null)
            {
                shovel.Draw(g);
            }
            if (sunBoard != null)
            {
                sunBoard.Draw(g);
            }
            if (noticeImage != null)
            {
                g.DrawImage(noticeImage, 900 / 2 - noticeImage.Width / 2 + 120,
                            600 / 2 - noticeImage.Height / 2, noticeImage.Width, noticeImage.Height);
            }

            //绘制介绍区域
            //if (isIntroduce)
            //{
            //    showIntroduce(g);
            //}
        }
Esempio n. 7
0
 public void initCard(PlantCard pc)
 {
     cb.initCard(pc);
 }
Esempio n. 8
0
 public void addCard(PlantCard pc)
 {
     plantscards.Add(pc);
     pc.Map = this;
 }