示例#1
0
        private void Update()
        {
            Console.WriteLine("Enter Name to update: ");
            string name   = Console.ReadLine();
            Cactus cactus = cactusBusiness.GetCactusByName(name);

            if (cactus != null)
            {
                Console.WriteLine("Enter name: ");
                cactus.Name = Console.ReadLine();
                Console.WriteLine("Enter height: ");
                cactus.Height = decimal.Parse(Console.ReadLine());
                Console.WriteLine("Enter thorns: ");
                cactus.Thorns = Console.ReadLine();
                Console.WriteLine("Enter seasons Id: ");
                Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)");
                cactus.SeasonsId = int.Parse(Console.ReadLine());
                cactusBusiness.Update(cactus);
                Console.WriteLine("The cactus was updated successfully!");
            }
            else
            {
                Console.WriteLine("Cactus not found!");
            }
        }
示例#2
0
        public static void GetNewRoad()
        {
            Road road = new Road(new PointF(0 + 100 * 9, 200), new Size(100, 17));

            roads.Add(road);
            countDangerSpawn++;

            if (countDangerSpawn >= dangerSpawn)
            {
                Random r = new Random();
                dangerSpawn      = r.Next(5, 9);
                countDangerSpawn = 0;
                int obj = r.Next(0, 2);
                switch (obj)
                {
                case 0:
                    Cactus cactus = new Cactus(new PointF(0 + 100 * 9, 150), new Size(50, 50));
                    cactuses.Add(cactus);
                    break;

                case 1:
                    Bird bird = new Bird(new PointF(0 + 100 * 9, 110), new Size(50, 50));
                    birds.Add(bird);
                    break;
                }
            }
        }
示例#3
0
    public override void Grow(string name)
    {
        Debug.Log("are we starting to grow");
        if (GameManager.instance.GetTileUp(x, y).IsEmpty())
        {
            //Create plant and init
            if (GameManager.instance.GetTileUp(x, y).IsEmpty() && height < 6)
            {
                if ((height == 3 || height == 4))
                {
                    BranchOut();
                }

                if (distanceFromCenter == 0)
                {
                    Cactus newCactus = Instantiate(plantTileToCreate, new Vector3(x + 0.5f, (y + 1) + 0.5f, 0), Quaternion.identity).GetComponent <Cactus>();
                    newCactus.Init();
                    //Increase plant height attribute
                    newCactus.branchDirection    = branchDirection;
                    newCactus.height             = this.CaclulateHeight();
                    newCactus.distanceFromCenter = 0;
                    newCactus.plantTileToCreate  = plantTileToCreate;
                    newCactus.hasBeenWatered     = true;
                }
            }
        }
    }
示例#4
0
 private void Awake()
 {
     //reference to componenets
     body   = GetComponent <Rigidbody2D>();
     anim   = GetComponent <Animator>();
     cactus = GameObject.Find("Cactus").GetComponent <Cactus>();
 }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        int grass    = Grass.getSeedsOrSaplings(typeof(Grass));
        int shrub    = Shrub.getSeedsOrSaplings(typeof(Shrub));
        int leafTree = LeafTree.getSeedsOrSaplings(typeof(LeafTree));
        int firTree  = Grass.getSeedsOrSaplings(typeof(FirTree));
        int cactus   = Cactus.getSeedsOrSaplings(typeof(Cactus));

        countGrass.text    = grass.ToString();
        countShrub.text    = shrub.ToString();
        countLeafTree.text = leafTree.ToString();
        countFirTree.text  = firTree.ToString();
        countCactus.text   = cactus.ToString();

        if (grass == 0)
        {
            buttonGrass.GetComponent <Button>().interactable = false;
        }
        else
        {
            buttonGrass.GetComponent <Button>().interactable = true;
        }

        if (shrub == 0)
        {
            buttonShrub.GetComponent <Button>().interactable = false;
        }
        else
        {
            buttonShrub.GetComponent <Button>().interactable = true;
        }

        if (leafTree == 0)
        {
            buttonLeafTree.GetComponent <Button>().interactable = false;
        }
        else
        {
            buttonLeafTree.GetComponent <Button>().interactable = true;
        }

        if (firTree == 0)
        {
            buttonFirTree.GetComponent <Button>().interactable = false;
        }
        else
        {
            buttonFirTree.GetComponent <Button>().interactable = true;
        }

        if (cactus == 0)
        {
            buttonCactus.GetComponent <Button>().interactable = false;
        }
        else
        {
            buttonCactus.GetComponent <Button>().interactable = true;
        }
    }
示例#6
0
    // Update is called once per frame
    private void Update()
    {
        if (Input.anyKeyDown)
        {
            softPause = false;
        }
        if (softPause)
        {
            return;
        }
        if (Input.GetButtonDown("Cancel"))
        {
            Menu();
        }
        if (Time.timeSinceLevelLoad < Frequency)
        {
            return;                                              // Only do something every so "Frequency"
        }
        Text.GetComponent <Text>().text = string.Format("\nScore: {0}\t\nHP: {1}\t", Frequency, Dino.GetComponent <DinoController>().Health);
        int amountOfCacti = GameObject.FindGameObjectsWithTag("Cacti").Length;

        if (amountOfCacti >= Amount)
        {
            return;             // Do nothing if too many cacti are in the scene
        }
        Frequency += 1;         // Will use this as score as well as dificulty curve

        /*This spawns a small, medium or large gameobject (or cacti)
         */
        var seed = Random.Range(1, 4);         // Is this efficient? It probably does't matter

        switch (seed)
        {
        case 1:
            Debug.Log("Spawning Big");
            spawn_cacti(Obstaclebig);
            break;

        case 2:
            Debug.Log("Spawning Medium");
            spawn_cacti(Obstaclemedium);
            break;

        default:
            Debug.Log("Spawning small");
            spawn_cacti(Obstaclesmall);
            break;
        }

        /* Speed up Cacti here */
        foreach (var cacti in GameObject.FindGameObjectsWithTag("Cacti"))
        {
            Debug.Log(string.Format("Changing the speed of :{0}", cacti));
            Cactus cactiMotion = cacti.GetComponent <Cactus>();
            cactiMotion.X = 6 + Frequency * Difficulty / 100;
            Debug.Log(string.Format("Frequency :{0}", Frequency));
        }
    }
示例#7
0
        /// <summary>
        /// Конструктор класса <see cref="Cactus"/>
        /// </summary>
        public static void DefCactus()
        {
            Cactus cactus = new Cactus();

            cactus.Name       = "Цереус";
            cactus.Size       = 17.24;
            cactus.Difficulty = 3;
            Console.WriteLine($"Кактус\nНазвание: {cactus.Name}\nРазмер: {cactus.Size}\nСложность ухаживания: {cactus.DetectDifficulty(cactus.Difficulty)}");
        }
示例#8
0
 //resets position
 private void Respawn()
 {
     //create a new collider
     //Destroy(poly);
     //poly = this.gameObject.AddComponent<PolygonCollider2D>();
     //poly.isTrigger = true;
     this.transform.position = spawn + new Vector3(lastCactus.gameObject.transform.position.x + Random.Range(-spawnRandomMax, spawnRandomMax), 0f, 0f);
     lastCactus = this;
 }
示例#9
0
        /// <summary>
        /// Updates cactus.
        /// </summary>
        /// <param name="cactus">the cactus that will be updated</param>
        public void Update(Cactus cactus)
        {
            var item = context.Cactuses.Find(cactus.Id);

            if (item != null)
            {
                context.Entry(item).CurrentValues.SetValues(cactus);
                context.SaveChanges();
            }
        }
示例#10
0
        public void Update_Cactus()
        {
            var mockContext    = new Mock <GardenContext>();;
            var cactusBusiness = new CactusBusiness();
            var Cactus         = new Cactus()
            {
                Name = "Cactus1"
            };

            try { cactusBusiness.Update(Cactus); }
            catch { mockContext.Verify(m => m.Entry(It.IsAny <Cactus>()), Times.Once()); }
        }
示例#11
0
    public Cactus IsACactus(Node node)
    {
        Cactus cactus = null;

        m_cactus.TryGetValue(node, out cactus);

        if (cactus != null && !cactus.gameObject.activeSelf)
        {
            cactus = null;
        }

        return(cactus);
    }
示例#12
0
    void OnTriggerStay2D(Collider2D collide)
    {
        GameObject otherObject = collide.gameObject;

        if (otherObject.GetComponent <Cactus>())
        {
            Cactus otherCactus = otherObject.GetComponent <Cactus>();

            if (id < otherCactus.id)
            {
                movementDirection = otherCactus.movementDirection * -1f;
            }
        }
    }
示例#13
0
        public void Add_Cactus()
        {
            var mockSet     = new Mock <DbSet <Cactus> >();
            var cactus      = new Cactus();
            var mockContext = new Mock <GardenContext>();

            mockContext.Setup(m => m.Cactuses).Returns(mockSet.Object);

            var business = new CactusBusiness(mockContext.Object);

            business.Add(cactus);

            mockSet.Verify(m => m.Add(It.IsAny <Cactus>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
    public static int calculateFitness(List <Jumped> jumps, List <Cactus> cactus)
    {
        int    jumpedCactus = 0;
        Cactus nextCactus   = cactus.Find(c => c.position.x == GameObject.Find("cactus_1_first").transform.position.x);

        foreach (Jumped jump in jumps)
        {
            if (nextCactus != jump.nearestCactus)
            {
                nextCactus = jump.nearestCactus;
                jumpedCactus++;
            }
        }

        return(jumpedCactus);
    }
示例#15
0
        private void Add()
        {
            Cactus cactus = new Cactus();

            Console.WriteLine("Enter name: ");
            cactus.Name = Console.ReadLine();
            Console.WriteLine("Enter height: ");
            cactus.Height = decimal.Parse(Console.ReadLine());
            Console.WriteLine("Enter thorns: ");
            cactus.Thorns = Console.ReadLine();
            Console.WriteLine("Enter seasons Id: ");
            Console.WriteLine("(1-spring, 2-summer, 3-autumn, 4-winter)");
            cactus.SeasonsId = int.Parse(Console.ReadLine());
            cactusBusiness.Add(cactus);
            Console.WriteLine("The cactus was successfully added!");
        }
示例#16
0
        static void Main(string[] args)
        {
            Printer print = new Printer();
            Plant   p1    = new Rose(25, "red") as Rose;

            print.IAmPrinting(p1);
            Console.WriteLine("\n");
            Plant p2 = new Gladiolus(100, "green");

            print.IAmPrinting(p2);
            Plant p3 = new Cactus(1231, "black");

            Plant[] arr = new Plant[2];
            arr[0] = p1;
            arr[1] = p2

                     foreach (Plant item in arr)
            {
                Console.WriteLine("----------------------------------------------------------------");
                print.IAmPrinting(item);
            }


            Container b = new Container();

            b.byk = new List <Plant>();
            b.Add(p3);
            b.Add(p2);
            b.Add(p1);
            Console.WriteLine("\n");
            Console.WriteLine("\n");
            b.Info();

            b.PriceOfFlowers();

            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Controller cont = new Controller();

            cont.Search(b.byk);
            cont.PriceSorting(b.byk);
            b.Info();
        }
示例#17
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            dinosaur        = new Dinosaur(GraphicsDevice);
            floor           = new Floor(GraphicsDevice);
            cactus          = new Cactus(GraphicsDevice);
            cactus2         = new Cactus(GraphicsDevice, 300);
            bird            = new Bird(GraphicsDevice, 5000);
            collisonHandler = new CollisonHandler(dinosaur, new List <MyRectangle>()
            {
                cactus, cactus2
            });
            gameOverText = Content.Load <SpriteFont>("GameOverFont");
        }
示例#18
0
 private void Awake()
 {
     //Keeps track of furthest back cactus, uses that as reference point for respawning
     if (lastCactus == null)
     {
         lastCactus = this;
         this.gameObject.transform.position = spawn;
         cactiSprites = new Sprite[spriteCount];
         for (int i = 0; i < spriteCount; i++)
         {
             cactiSprites[i] = (Sprite)Resources.Load <Sprite>("Sprites/Obstacles/cactus" + i);
         }
     }
     else
     {
         Respawn();
     }
 }
示例#19
0
    //takes an index for new cacti sprite, resets sprite and collider
    //resets position
    private void Respawn(int index)
    {
        //Update sprite using index in cacti sprite array
        if (!(cactiSprites.Length <= index || cactiSprites[index] == null))
        {
            spriteRender.sprite = cactiSprites[index];
        }
        else
        {
            print("bad index");
        }

        //reset collider and position
        Destroy(poly);
        poly                    = this.gameObject.AddComponent <PolygonCollider2D>();
        poly.isTrigger          = true;
        this.transform.position = spawn + new Vector3(lastCactus.gameObject.transform.position.x + Random.Range(-spawnRandomMax, spawnRandomMax), 0f, 0f);
        lastCactus              = this;
    }
示例#20
0
    private void Awake()
    {
        instance = this;

        List <SpriteRenderer> renderers = new List <SpriteRenderer>(GetComponentsInChildren <SpriteRenderer>());

        for (int i = 0; i < renderers.Count; ++i)
        {
            OriginalSortOrders.Add(renderers[i], renderers[i].sortingOrder);
        }
        List <TextMeshPro> textrenderers = new List <TextMeshPro>(GetComponentsInChildren <TextMeshPro>());

        for (int i = 0; i < textrenderers.Count; ++i)
        {
            OriginalSortOrdersText.Add(textrenderers[i], textrenderers[i].sortingOrder);
        }
        OriginalZ      = gameObject.transform.localPosition.z;
        OriginPosition = gameObject.transform.position;
    }
示例#21
0
        private void CreateObstacle()
        {
            Random random      = new Random();
            int    tempForType = random.Next(1, 4);
            int    berdChance  = random.Next(0, 101);

            if (berdChance < 15)
            {
                Bird temp = new Bird(tempForType, windowWidth, bird1, bird2);
                berds.Add(temp);
            }
            else
            {
                Cactus temp = new Cactus(tempForType, windowWidth, cactusSmall, cactusBig, cactusSmallMany);
                cactuses.Add(temp);
            }

            randomAdd     = Math.Floor(maxRandomAdd);
            obstacleTimer = 0;
        }
示例#22
0
        void CreateObject(int x, int y)
        {
            if (start == true)
            {
                if (gamePole[x, y] == null && Cactus.poolCactus > 0)
                {
                    gamePole[x, y] = new Cactus(x, y);
                }
                else if (gamePole[x, y] != null)
                {
                    if (gamePole[x, y].Id == 2)
                    {
                        gamePole[x, y]     = null;
                        Cactus.poolCactus += 1;
                    }
                }

                if (gamePole[x, y] == null && Cactus.poolCactus == 0 && Player.poolPlayer > 0)
                {
                    gamePole[x, y] = new Player(x, y);
                }
                else if (gamePole[x, y] != null)
                {
                    if (gamePole[x, y].Id == 1)
                    {
                        gamePole[x, y]     = null;
                        Player.poolPlayer += 1;
                    }
                }
            }
            else
            {
                gogoPlayer(x, y);

                labelOdPlayer.Text = "Очки действия: " + Player.OD;
                if (Player.OD == 0)
                {
                    gogoBanditos();
                }
            }
        }
    Cactus getNextNearestCactus()
    {
        float  nearestDist   = float.PositiveInfinity;
        Cactus nearestCactus = null;

        foreach (Cactus c in cactus)
        {
            float cacX    = c.position.x;
            float playerX = GetComponent <Rigidbody2D> ().position.x;
            if (cacX > playerX)
            {
                float dist = cacX - playerX;
                if (dist < nearestDist)
                {
                    nearestDist   = dist;
                    nearestCactus = c;
                }
            }
        }

        return(nearestCactus);
    }
示例#24
0
        public void MakeOrder(OrderDTO orderDto)
        {
            Cactus cactus = Database.Cactuses.Get(orderDto.CactusId);

            if (cactus == null)
            {
                throw new ValidationException("Растение не найдено", "");
            }

            decimal sum   = new Discount(0.1m).GetDiscountedPrice(cactus.Price);
            Order   order = new Order
            {
                Date        = DateTime.Now,
                Address     = orderDto.Address,
                CactusId    = cactus.Id,
                Sum         = sum,
                PhoneNumber = orderDto.PhoneNumber
            };

            Database.Orders.Create(order);
            Database.Save();
        }
示例#25
0
 private void Start()
 {
     sl  = FindObjectOfType <SceneLoader>();
     cac = FindObjectOfType <Cactus>();
     if (sl.time <= 150f)
     {
         if (gameObject.GetComponent <Krasnal>() == null)
         {
             health += 50;
         }
         if (sl.time <= 90f)
         {
             if (gameObject.GetComponent <Krasnal>() == null)
             {
                 health += 50;
             }
             else if (gameObject.GetComponent <Krasnal>() != null)
             {
                 health += 100;
             }
         }
     }
 }
示例#26
0
    void OnCollisionEnter2D(Collision2D collider)
    {
        //We find any enemies in the scene
        Cactus enemy = collider.gameObject.GetComponent <Cactus>();

        //If the player collides with an enemy, the enemy reduces player's health by its own damage
        //If player's health is 0, the player dies
        if (enemy)
        {
            health -= enemy.getDamage();
            if (health <= 0)
            {
                Die();
            }
        }
        else
        {
            //Debug.Log("Floor");
            //When player collides with floor, the jump animation stops
            //This is because I dont know how to stop that animation
            anim.SetBool("isJumping", false);
        }
    }
    void playGenome(int genomeIndex)
    {
        float dist = getNextNearestCactus().position.x - GetComponent <Rigidbody2D> ().position.x;

        if (actualJumpGenome >= genomes[genomeIndex].jumps.Count)
        {
        }
        else if (dist <= genomes[genomeIndex].jumps[actualJumpGenome].distanceToNearestCactus.x && isGrounded)
        {
            GetComponent <Rigidbody2D> ().velocity = new Vector2(GetComponent <Rigidbody2D> ().velocity.x, jumpHeight);
            isGrounded = false;

            Cactus c    = getNextNearestCactus();
            Jumped jump = new Jumped {
                nearestCactus           = c,
                distanceToNearestCactus = c.position - GetComponent <Rigidbody2D> ().position
            };

            jumps.Add(jump);

            actualJumpGenome++;
        }
    }
示例#28
0
        public void MakeOrder(OrderDTO orderDto)
        {
            Cactus cactus = Database.Cactuses.Get(orderDto.PhoneId);

            // валидация
            if (cactus == null)
            {
                throw new ValidationException("Телефон не найден", "");
            }
                        // применяем скидку
                        decimal sum = new Discount(0.1m).GetDiscountedPrice(cactus.Price);
            Order order             = new Order
            {
                Date        = DateTime.Now,
                Address     = orderDto.Address,
                CactusID    = cactus.Id,
                Sum         = sum,
                PhoneNumber = orderDto.PhoneNumber
            };

            Database.Orders.Create(order);
            Database.Save();
        }
示例#29
0
    private void BranchOut()
    {
        if ((branchDirection == 5 || branchDirection == 0) && distanceFromCenter == 0)
        {
            branchDirection = Random.Range(-1, 2);
        }
        else if (distanceFromCenter == 0 && branchDirection != 5)
        {
            branchDirection = branchDirection *= -1;
        }

        switch (branchDirection)
        {
        case -1:
            if (GameManager.instance.GetTileLeft(x, y).IsEmpty() && distanceFromCenter > -2)
            {
                Debug.Log("it should go left ... ");
                Cactus newCactus = Instantiate(plantTileToCreate, new Vector3((x - 1) + 0.5f, y + 0.5f, 0), Quaternion.identity).GetComponent <Cactus>();
                newCactus.Init();
                newCactus.plantTileToCreate = plantTileToCreate;
                newCactus.branchDirection   = branchDirection;
                //Increase plant height attribute
                newCactus.height             = this.CaclulateHeight();
                newCactus.distanceFromCenter = distanceFromCenter - 1;
                newCactus.hasBeenWatered     = true;
            }
            else if (GameManager.instance.GetTileUp(x, y).IsEmpty() && distanceFromCenter <= -2)
            {
                Debug.Log("it should go left up... ");
                Cactus newCactus = Instantiate(plantTileToCreate, new Vector3(x + 0.5f, (y + 1) + 0.5f, 0), Quaternion.identity).GetComponent <Cactus>();
                newCactus.Init();
                newCactus.plantTileToCreate = plantTileToCreate;
                newCactus.branchDirection   = branchDirection;
                //Increase plant height attribute
                newCactus.height             = this.CaclulateHeight();
                newCactus.distanceFromCenter = distanceFromCenter;
                newCactus.hasBeenWatered     = true;
            }
            break;

        case 1:
            if (GameManager.instance.GetTileLeft(x, y).IsEmpty() && distanceFromCenter < 2)
            {
                Debug.Log("it should go right... ");
                Cactus newCactus = Instantiate(plantTileToCreate, new Vector3((x + 1) + 0.5f, y + 0.5f, 0), Quaternion.identity).GetComponent <Cactus>();
                newCactus.Init();
                newCactus.plantTileToCreate = plantTileToCreate;
                newCactus.branchDirection   = branchDirection;
                //Increase plant height attribute
                newCactus.height             = this.CaclulateHeight();
                newCactus.distanceFromCenter = distanceFromCenter + 1;
                newCactus.hasBeenWatered     = true;
            }
            else if (GameManager.instance.GetTileUp(x, y).IsEmpty() && distanceFromCenter >= 2)
            {
                Debug.Log("it should go right up... ");
                Cactus newCactus = Instantiate(plantTileToCreate, new Vector3(x + 0.5f, (y + 1) + 0.5f, 0), Quaternion.identity).GetComponent <Cactus>();
                newCactus.Init();
                newCactus.plantTileToCreate = plantTileToCreate;
                newCactus.branchDirection   = branchDirection;
                //Increase plant height attribute
                newCactus.height             = this.CaclulateHeight();
                newCactus.distanceFromCenter = distanceFromCenter;
                newCactus.hasBeenWatered     = true;
            }
            break;

        case 0:
            break;

        default:
            break;
        }
    }
示例#30
0
        public static Block GetBlockById(byte blockId)
        {
            Block block = null;

            if (CustomBlockFactory != null)
            {
                block = CustomBlockFactory.GetBlockById(blockId);
            }

            if (block != null) return block;

            if (blockId == 0) block = new Air();
            else if (blockId == 1) block = new Stone();
            else if (blockId == 2) block = new Grass();
            else if (blockId == 3) block = new Dirt();
            else if (blockId == 4) block = new Cobblestone();
            else if (blockId == 5) block = new Planks();
            else if (blockId == 6) block = new Sapling();
            else if (blockId == 7) block = new Bedrock();
            else if (blockId == 8) block = new FlowingWater();
            else if (blockId == 9) block = new StationaryWater();
            else if (blockId == 10) block = new FlowingLava();
            else if (blockId == 11) block = new StationaryLava();
            else if (blockId == 12) block = new Sand();
            else if (blockId == 13) block = new Gravel();
            else if (blockId == 14) block = new GoldOre();
            else if (blockId == 15) block = new IronOre();
            else if (blockId == 16) block = new CoalOre();
            else if (blockId == 17) block = new Log();
            else if (blockId == 18) block = new Leaves();
            else if (blockId == 19) block = new Sponge();
            else if (blockId == 20) block = new Glass();
            else if (blockId == 21) block = new LapisOre();
            else if (blockId == 22) block = new LapisBlock();
            else if (blockId == 23) block = new Dispenser();
            else if (blockId == 24) block = new Sandstone();
            else if (blockId == 25) block = new NoteBlock();
            else if (blockId == 26) block = new Bed();
            else if (blockId == 27) block = new GoldenRail();
            else if (blockId == 28) block = new DetectorRail();
            else if (blockId == 30) block = new Cobweb();
            else if (blockId == 31) block = new TallGrass();
            else if (blockId == 32) block = new DeadBush();
            else if (blockId == 35) block = new Wool();
            else if (blockId == 37) block = new YellowFlower();
            else if (blockId == 38) block = new Flower();
            else if (blockId == 39) block = new BrownMushroom();
            else if (blockId == 40) block = new RedMushroom();
            else if (blockId == 41) block = new GoldBlock();
            else if (blockId == 42) block = new IronBlock();
            else if (blockId == 43) block = new DoubleStoneSlab();
            else if (blockId == 44) block = new StoneSlab();
            else if (blockId == 45) block = new Bricks();
            else if (blockId == 46) block = new Tnt();
            else if (blockId == 47) block = new Bookshelf();
            else if (blockId == 48) block = new MossStone();
            else if (blockId == 49) block = new Obsidian();
            else if (blockId == 50) block = new Torch();
            else if (blockId == 51) block = new Fire();
            else if (blockId == 52) block = new MonsterSpawner();
            else if (blockId == 53) block = new OakWoodStairs();
            else if (blockId == 54) block = new Chest();
            else if (blockId == 55) block = new RedstoneWire();
            else if (blockId == 56) block = new DiamondOre();
            else if (blockId == 57) block = new DiamondBlock();
            else if (blockId == 58) block = new CraftingTable();
            else if (blockId == 59) block = new Wheat();
            else if (blockId == 60) block = new Farmland();
            else if (blockId == 61) block = new Furnace();
            else if (blockId == 62) block = new LitFurnace();
            else if (blockId == 63) block = new StandingSign();
            else if (blockId == 64) block = new WoodenDoor();
            else if (blockId == 65) block = new Ladder();
            else if (blockId == 66) block = new Rail();
            else if (blockId == 67) block = new CobblestoneStairs();
            else if (blockId == 68) block = new WallSign();
            else if (blockId == 69) block = new Lever();
            else if (blockId == 70) block = new StonePressurePlate();
            else if (blockId == 71) block = new IronDoor();
            else if (blockId == 72) block = new WoodenPressurePlate();
            else if (blockId == 73) block = new RedstoneOre();
            else if (blockId == 74) block = new LitRedstoneOre();
            else if (blockId == 75) block = new UnlitRedstoneTorch();
            else if (blockId == 76) block = new RedstoneTorch();
            else if (blockId == 77) block = new StoneButton();
            else if (blockId == 78) block = new SnowLayer();
            else if (blockId == 79) block = new Ice();
            else if (blockId == 80) block = new Snow();
            else if (blockId == 81) block = new Cactus();
            else if (blockId == 82) block = new Clay();
            else if (blockId == 83) block = new Reeds();
            else if (blockId == 85) block = new Fence();
            else if (blockId == 86) block = new Pumpkin();
            else if (blockId == 87) block = new Netherrack();
            else if (blockId == 88) block = new SoulSand();
            else if (blockId == 89) block = new Glowstone();
            else if (blockId == 90) block = new Portal();
            else if (blockId == 91) block = new LitPumpkin();
            else if (blockId == 92) block = new Cake();
            else if (blockId == 93) block = new UnpoweredRepeater();
            else if (blockId == 94) block = new PoweredRepeater();
            else if (blockId == 95) block = new InvisibleBedrock();
            else if (blockId == 96) block = new Trapdoor();
            else if (blockId == 97) block = new MonsterEgg();
            else if (blockId == 98) block = new StoneBrick();
            else if (blockId == 99) block = new BrownMushroomBlock();
            else if (blockId == 100) block = new RedMushroomBlock();
            else if (blockId == 101) block = new IronBars();
            else if (blockId == 102) block = new GlassPane();
            else if (blockId == 103) block = new Melon();
            else if (blockId == 106) block = new Vine();
            else if (blockId == 107) block = new FenceGate();
            else if (blockId == 108) block = new BrickStairs();
            else if (blockId == 109) block = new StoneBrickStairs();
            else if (blockId == 110) block = new Mycelium();
            else if (blockId == 111) block = new Waterlily();
            else if (blockId == 112) block = new NetherBrick();
            else if (blockId == 113) block = new NetherBrickFence();
            else if (blockId == 114) block = new NetherBrickStairs();
            else if (blockId == 115) block = new NetherWart();
            else if (blockId == 116) block = new EnchantingTable();
            else if (blockId == 117) block = new BrewingStand();
            else if (blockId == 120) block = new EndPortalFrame();
            else if (blockId == 121) block = new EndStone();
            else if (blockId == 122) block = new LitRedstoneLamp();
            else if (blockId == 123) block = new RedstoneLamp();
            else if (blockId == 126) block = new ActivatorRail();
            else if (blockId == 127) block = new Cocoa();
            else if (blockId == 128) block = new SandStoneStairs();
            else if (blockId == 129) block = new EmeraldOre();
            else if (blockId == 131) block = new TripwireHook();
            else if (blockId == 132) block = new Tripwire();
            else if (blockId == 133) block = new EmeraldBlock();
            else if (blockId == 134) block = new SpruceWoodStairs();
            else if (blockId == 135) block = new BirchWoodStairs();
            else if (blockId == 136) block = new JungleWoodStairs();
            else if (blockId == 139) block = new CobblestoneWall();
            else if (blockId == 140) block = new FlowerPot();
            else if (blockId == 141) block = new Carrots();
            else if (blockId == 142) block = new Potatoes();
            else if (blockId == 143) block = new WoodenButton();
            else if (blockId == 144) block = new Skull();
            else if (blockId == 145) block = new Anvil();
            else if (blockId == 146) block = new TrappedChest();
            else if (blockId == 147) block = new LightWeightedPressurePlate();
            else if (blockId == 148) block = new HeavyWeightedPressurePlate();
            else if (blockId == 151) block = new DaylightDetector();
            else if (blockId == 152) block = new RedstoneBlock();
            else if (blockId == 153) block = new QuartzOre();
            else if (blockId == 155) block = new QuartzBlock();
            else if (blockId == 156) block = new QuartzStairs();
            else if (blockId == 157) block = new DoubleWoodSlab();
            else if (blockId == 158) block = new WoodSlab();
            else if (blockId == 159) block = new StainedHardenedClay();
            else if (blockId == 161) block = new AcaciaLeaves();
            else if (blockId == 162) block = new AcaciaLog();
            else if (blockId == 163) block = new AcaciaStairs();
            else if (blockId == 164) block = new DarkOakStairs();
            else if (blockId == 167) block = new IronTrapdoor();
            else if (blockId == 170) block = new HayBlock();
            else if (blockId == 171) block = new Carpet();
            else if (blockId == 172) block = new HardenedClay();
            else if (blockId == 173) block = new CoalBlock();
            else if (blockId == 174) block = new PackedIce();
            else if (blockId == 175) block = new Sunflower();
            else if (blockId == 178) block = new DaylightDetectorInverted();
            else if (blockId == 183) block = new SpruceFenceGate();
            else if (blockId == 184) block = new BirchFenceGate();
            else if (blockId == 185) block = new JungleFenceGate();
            else if (blockId == 186) block = new DarkOakFenceGate();
            else if (blockId == 187) block = new AcaciaFenceGate();
            else if (blockId == 198) block = new GrassPath();
            else if (blockId == 199) block = new ItemFrame();
            else if (blockId == 243) block = new Podzol();
            else if (blockId == 244) block = new Beetroot();
            else if (blockId == 245) block = new Stonecutter();
            else if (blockId == 246) block = new GlowingObsidian();
            else if (blockId == 247) block = new NetherReactorCore();
            else
            {
                //				Log.DebugFormat(@"
                //	// Add this missing block to the BlockFactory
                //	else if (blockId == {1}) block = new {0}();
                //
                //	public class {0} : Block
                //	{{
                //		internal {0}() : base({1})
                //		{{
                //		}}
                //	}}
                //", "Missing", blockId);
                block = new Block(blockId);
            }

            return block;
        }
示例#31
0
    void Move(Vector2 direction)
    {
        jumpdst.Clear();

        Vector3 v3Dir = new Vector3(direction.x, 0, direction.y);
        Node    node  = Grid.inst.NodeFromWorldPoint(m_transform.position + v3Dir);

        if (node != null)
        {
            Rock nodeRock = LevelManager.inst.IsARock(node);

            if (!node.walkable || nodeRock != null)
            {
                return;                                     //can't push block
            }
            Pit nodePit = LevelManager.inst.IsAPit(node);
            if (nodePit != null)
            {
                FallIntoPit(node);
                return;
            }
            Cactus nodeCactus = LevelManager.inst.IsACactus(node);
            if (nodeCactus != null)
            {
                FallIntoCactus(node);
                return;
            }

            int  distance = 0;
            Node nextNode = null, previousNode = node;
            do
            {
                distance++;
                totalDst = distance;
                if (nextNode != null)
                {
                    previousNode = nextNode;
                }

                nextNode = Grid.inst.NodeFromWorldPoint(node.worldPosition + v3Dir * (distance));

                if (nextNode == null || nextNode == previousNode)
                {
                    break;
                }

                Rock nextRock = LevelManager.inst.IsARock(nextNode);

                if (nextRock != null)
                {
                    if (nextRock.breakable && distance > 1)
                    {
                        if (nextRock.durability == 1)
                        {
                            //nextRock.Broke();
                            GoTo(nextNode, nextRock, false);
                            break;
                        }
                        else
                        {
                            Node moveBlockTo     = Grid.inst.NodeFromWorldPoint(node.worldPosition + v3Dir * (distance + 1));
                            Rock moveBlockToRock = LevelManager.inst.IsARock(moveBlockTo);

                            if (moveBlockTo != null && moveBlockToRock == null)
                            {
                                //nextRock.Hit(moveBlockTo);
                                Cactus nextCactus = LevelManager.inst.IsACactus(moveBlockTo);
                                if (nextCactus != null)
                                {
                                    GoTo(previousNode, nextRock, true);
                                }
                                else
                                {
                                    GoTo(nextNode, nextRock, true, moveBlockTo);
                                }
                            }
                            else
                            {
                                //nextRock.Hit();
                                GoTo(previousNode, nextRock, true);
                            }
                        }
                        break;
                    }
                    else
                    {
                        if (distance == 1)
                        {
                            Debug.Log("Move one");
                            speedMul = .5f;
                        }

                        GoTo(previousNode);
                        break;
                    }
                }
                else
                {
                    Pit nextPit = LevelManager.inst.IsAPit(nextNode);
                    if (nextPit != null)
                    {
                        Node nextnextNode = Grid.inst.NodeFromWorldPoint(node.worldPosition + v3Dir * (distance + 1));
                        Pit  nextnextPit  = LevelManager.inst.IsAPit(nextnextNode);

                        if (nextnextPit != null)
                        {
                            FallIntoPit(nextnextNode);
                            return;
                        }
                        else
                        {
                            Rock nextnextRock = LevelManager.inst.IsARock(nextnextNode);
                            if (nextnextRock != null)
                            {
                                FallIntoPit(nextNode);
                                return;
                            }
                            else
                            {
                                Cactus nextCactus = LevelManager.inst.IsACactus(nextNode);
                                if (nextCactus != null)
                                {
                                    FallIntoCactus(nextNode);
                                    return;
                                }
                                else
                                {
                                    jumpdst.Add(distance);
                                    Debug.Log("Jump Above Pit: " + nextNode.worldPosition, nextPit.gameObject);
                                }
                            }
                        }
                    }
                    else
                    {
                        Cactus nextCactus = LevelManager.inst.IsACactus(nextNode);
                        if (nextCactus != null)
                        {
                            FallIntoCactus(nextNode);
                            return;
                        }
                    }
                }
            } while (nextNode != null);

            if (nextNode == null)
            {
                Debug.Log("Move null");
                GoTo(previousNode);
            }
        }
    }