コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please select the choice : [1-2]");
            Console.WriteLine("1.InputText");
            Console.WriteLine("2.WaterBlock");

            var choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                Console.WriteLine("Please input text.");
                var inputText   = Console.ReadLine();
                var countNumber = InputText.TextCalculator(inputText, true, true);
                Console.WriteLine("Count Number : " + countNumber);
                break;

            case 2:
                var regex = new Regex(@"[\d]");
                Console.WriteLine("Please input number.");
                var blocks = new List <int>();
                do
                {
                    var input = Console.ReadLine();
                    blocks.Add(regex.IsMatch(input) == false ? 0 : Int32.Parse(input));
                } while(blocks.Count < 5);
                var countWater = WaterBlock.WaterBlockCalculator(blocks.ToArray(), true);
                Console.WriteLine("Water in block : " + countWater);
                break;

            default:
                Console.WriteLine("Please input [1-2]");
                break;
            }
        }
コード例 #2
0
 static void Postfix(ref WaterBlock __instance)
 {
     if (PluginMain.IsEnabled)
     {
         __instance.m_MeshRenderer.material.color = PluginMain.waterColor;
     }
     else
     {
         __instance.m_MeshRenderer.material.color = PluginMain.origColor;
     }
 }
コード例 #3
0
 private void OnTriggerStay2D(Collider2D collider)
 {
     if (collider.gameObject.tag == "Water")
     {
         waterBlock = collider.gameObject.GetComponent <WaterBlock>();
         waterPush(waterBlock);
     }
     if (collider.gameObject.tag == "Water Edge")
     {
         stopVelocity();
     }
 }
コード例 #4
0
 IEnumerator Drink(WaterBlock water)
 {
     while (!Physics.OverlapSphere(transform.position, 1f).Contains(water.GetComponent <Collider>()))
     {
         navAgent.SetDestination(water.transform.position);
         yield return(new WaitForSeconds(1f));
     }
     while (Hydration < maxHydration)
     {
         Hydration += 0.03f;
         yield return(null);
     }
     activity = CreatureActivity.Idle;
     yield break;
 }
コード例 #5
0
 private void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.gameObject.tag == "Water")
     {
         //rb2d.angularVelocity = 0f;
         //rb2d.velocity = Vector2.zero;
         //gravityModifier = 1f;
         waterBlock = collider.gameObject.GetComponent <WaterBlock>();
         waterPush(waterBlock);
     }
     if (collider.gameObject.tag == "Water Edge")
     {
         stopVelocity();
     }
 }
コード例 #6
0
 public void WaterBlockTestNoFloor()
 {
     int[] blocks0 = { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
     Assert.Equal(0, WaterBlock.WaterBlockCalculator(blocks0, false));
     int[] blocks1 = { 1, 0, 3, 1, 1, 0, 2, 1, 2, 0, 1 };
     Assert.Equal(1, WaterBlock.WaterBlockCalculator(blocks1, false));
     int[] blocks2 = { 1, 0, 3, 1, 1, 0, 2, 1, 2, 1, 2 };
     Assert.Equal(2, WaterBlock.WaterBlockCalculator(blocks2, false));
     int[] blocks3 = { 2, 1, 3, 1, 1, 0, 2, 1, 2, 1, 1 };
     Assert.Equal(2, WaterBlock.WaterBlockCalculator(blocks3, false));
     int[] blocks4 = { 0, 1, 3, 1, 1, 0, 2, 1, 2, 1, 0 };
     Assert.Equal(1, WaterBlock.WaterBlockCalculator(blocks4, false));
     int[] blocks6 = { 1, 0, 3, 4, 5, 0, 5, 4, 3, 0, 1 };
     Assert.Equal(0, WaterBlock.WaterBlockCalculator(blocks6, false));
 }
コード例 #7
0
    public CreatureSight(Creature seeingCreature, Collider[] sphereOfView)
    {
        SourceCreature = seeingCreature;

        // temporary lists
        List <Creature>   creatures = new List <Creature>();
        List <FoodSource> food      = new List <FoodSource>();
        List <WaterBlock> water     = new List <WaterBlock>();

        foreach (Collider collider in sphereOfView)
        {
            if (collider == seeingCreature.GetComponent <Collider>())
            {
                continue;
            }
            Creature   creature   = collider.GetComponent <Creature>();
            FoodSource foodSource = collider.GetComponent <FoodSource>();
            WaterBlock waterBlock = collider.GetComponent <WaterBlock>();

            if (creature != null)
            {
                if (creature == seeingCreature)
                {
                    continue;
                }
                creatures.Add(creature);
            }
            if (foodSource != null)
            {
                if (foodSource.GetComponent <Creature>() != null && foodSource.GetComponent <Creature>().speciesName == SourceCreature.speciesName)
                {
                    continue;
                }
                food.Add(foodSource);
            }
            if (waterBlock != null)
            {
                water.Add(waterBlock);
            }
        }


        Creatures = creatures.ToArray();
        Food      = food.ToArray();
        Water     = water.ToArray();
    }
コード例 #8
0
    private void waterPush(WaterBlock waterBlock)
    {
        if (waterBlock.direction == WaterBlock.Direction.Left || waterBlock.direction == WaterBlock.Direction.Right)
        {
            gravityModifier = 1f;
        }
        else if (waterBlock.direction == WaterBlock.Direction.Down)
        {
            gravityModifier = 2f;
        }
        else
        {
            gravityModifier = -0.05f;
        }

        Vector2 waterDirection = directionToVector(waterBlock.direction);

        rb2d.AddForce(new Vector2(waterMoveSpeed * waterDirection.x, waterMoveSpeed * waterDirection.y));
    }
コード例 #9
0
ファイル: World.cs プロジェクト: AFreiberger5/Simulation
 void Start()
 {
     waterBlock   = EditorWater;
     m_WorldArray = new Block[40, 8, 40];
     GenerateTerrain();
 }
コード例 #10
0
 static void Postfix(ref WaterBlock __instance)
 {
     PluginMain.origColor = __instance.m_MeshRenderer.material.color;
 }
コード例 #11
0
        public Chunk Create()
        {
            var chunk     = new Chunk(dimension, address);
            var heightMap = new HeightMap(dimension.Seed.Dimension.Value, address, MaxHeight);
            var biomeMap  = new BiomeMap(dimension.Seed.Temperature.Value, dimension.Seed.Humidity.Value, address);

            heightMap.Generate();
            biomeMap.Generate();

            for (int x = 0; x < Chunk.Size; x++)
            {
                for (int z = 0; z < Chunk.Size; z++)
                {
                    var yMax      = heightMap[x, z];
                    var yMaxValue = Mathf.RoundToInt(yMax);
                    if (yMaxValue > MaxHeight)
                    {
                        yMaxValue = MaxHeight;
                    }

                    for (int y = 0; y <= yMaxValue; y++)
                    {
                        BaseBlock block;
                        if (y > WaterHeight + 10)
                        {
                            block = new StoneBlock();
                        }
                        else if (y > WaterHeight + 0)
                        {
                            block = new GrassBlock();
                        }
                        else
                        {
                            block = new SandBlock();
                        }
                        if (y >= WaterHeight)
                        {
                            var biome = biomeMap[x, z];
                            if (biome == "desert")
                            {
                                block = new SandBlock();
                            }
                            else if (biome == "stone")
                            {
                                block = new StoneBlock();
                            }
                            else if (biome == "grass")
                            {
                                block = new GrassBlock();
                            }
                            else
                            {
                                block = new GrassBlock();
                            }
                        }
                        else
                        {
                            block = new SandBlock();
                        }
                        chunk[x, y, z] = block;
                    }

                    for (int y = yMaxValue + 1; y < Chunk.Depth; y++)
                    {
                        BaseBlock block;
                        if (y < WaterHeight)
                        {
                            block = new WaterBlock();
                        }
                        else
                        {
                            block = new AirBlock();
                        }
                        chunk[x, y, z] = block;
                    }
                }
            }

            return(chunk);
        }
コード例 #12
0
 private Block FindBlock(Color c)
 {
     if (c == StandardGroundBlock.GetColor())
     {
         return(new StandardGroundBlock());
     }
     else if (c == DarkGroundBlock.GetColor())
     {
         return(new DarkGroundBlock());
     }
     else if (c == StandardAirBlock.GetColor())
     {
         return(new StandardAirBlock());
     }
     else if (c == DarkAirBlock.GetColor())
     {
         return(new DarkAirBlock());
     }
     else if (c == CoinBoxBlock.GetColor())
     {
         return(new CoinBoxBlock());
     }
     else if (c == PowerUpgradeBoxBlock.GetColor())
     {
         return(new PowerUpgradeBoxBlock());
     }
     else if (c == EmptyBoxBlock.GetColor())
     {
         return(new EmptyBoxBlock());
     }
     else if (c == StandardHillBlock.GetColor())
     {
         return(new StandardHillBlock());
     }
     else if (c == DarkHillBlock.GetColor())
     {
         return(new DarkHillBlock());
     }
     else if (c == PipeBlock.GetColor())
     {
         return(new PipeBlock());
     }
     else if (c == CastleBlock.GetColor())
     {
         return(new CastleBlock());
     }
     else if (c == CrazyCoinBoxBlock.GetColor())
     {
         return(new CrazyCoinBoxBlock());
     }
     else if (c == EndlessCrazyCoinBoxBlock.GetColor())
     {
         return(new EndlessCrazyCoinBoxBlock());
     }
     else if (c == StandardCeilingBlock.GetColor())
     {
         return(new StandardCeilingBlock());
     }
     else if (c == DarkCeilingBlock.GetColor())
     {
         return(new DarkCeilingBlock());
     }
     else if (c == StandardPillarBlock.GetColor())
     {
         return(new StandardPillarBlock());
     }
     else if (c == MushroomPlatformBlock.GetColor())
     {
         return(new MushroomPlatformBlock());
     }
     else if (c == CastleGroundBlock.GetColor())
     {
         return(new CastleGroundBlock());
     }
     else if (c == LavaBlock.GetColor())
     {
         return(new LavaBlock());
     }
     else if (c == FireBoxBlock.GetColor())
     {
         return(new FireBoxBlock());
     }
     else if (c == SolidCloudBlock.GetColor())
     {
         return(new SolidCloudBlock());
     }
     else if (c == BeanStalkBoxBlock.GetColor())
     {
         return(new BeanStalkBoxBlock());
     }
     else if (c == UnderwaterGroundBlock.GetColor())
     {
         return(new UnderwaterGroundBlock());
     }
     else if (c == WaterBlock.GetColor())
     {
         return(new WaterBlock());
     }
     else if (c == BillBlasterBlock.GetColor())
     {
         return(new BillBlasterBlock());
     }
     else
     {
         return(null);
     }
 }
コード例 #13
0
 public void WaterBlockTestHasFloor()
 {
     int[] blocks = { 1, 0, 3, 1, 1, 0, 2, 1, 2, 0, 1 };
     Assert.Equal(7, WaterBlock.WaterBlockCalculator(blocks, true));
 }
コード例 #14
0
    void BuildChunk()
    {
        bool dataFromFile = Load();

        chunkData = new Block[World.chunkSize, World.chunkSize, World.chunkSize];
        for (int z = 0; z < World.chunkSize; z++)
        {
            for (int y = 0; y < World.chunkSize; y++)
            {
                for (int x = 0; x < World.chunkSize; x++)
                {
                    Vector3 pos    = new Vector3(x, y, z);
                    int     worldX = (int)(x + chunk.transform.position.x);
                    int     worldY = (int)(y + chunk.transform.position.y);
                    int     worldZ = (int)(z + chunk.transform.position.z);

                    if (dataFromFile)
                    {
                        chunkData[x, y, z] = new Block(bd.matrix[x, y, z], pos, chunk.gameObject, this);
                        continue;
                    }

                    int surfaceHeight = Utils.GenHeight(worldX, worldZ);
                    if (worldY < 5)
                    {
                        chunkData[x, y, z] = new BedRockBlock(pos, chunk.gameObject, this);
                    }
                    else if (worldY <= Utils.GenStoneHeight(worldX, worldZ))
                    {
                        if (Utils.fBM3D(worldX, worldY, worldZ, 0.01f, 2) < 0.4f && worldY < 40)
                        {
                            chunkData[x, y, z] = new DiamondBlock(pos, chunk.gameObject, this);
                        }
                        if (Utils.fBM3D(worldX, worldY, worldZ, 0.03f, 3) < 0.41f && worldY < 20)
                        {
                            chunkData[x, y, z] = new RedStoneBlock(pos, chunk.gameObject, this);
                        }
                        else
                        {
                            chunkData[x, y, z] = new StoneBlock(pos, chunk.gameObject, this);
                        }
                    }
                    else if (worldY == surfaceHeight)
                    {
                        if (Utils.fBM3D(worldX, worldY, worldZ, 0.175f, 2) < 0.35f && worldY >= 65)
                        {
                            chunkData[x, y, z] = new TreeBlock(TreeBlock.TreeType.PINE, false, true, pos, chunk.gameObject, this);
                        }
                        else
                        {
                            chunkData[x, y, z] = new GrassBlock(pos, chunk.gameObject, this);
                        }
                        // chunkData[x, y, z] = new GrassBlock(pos, chunk.gameObject, this);
                    }
                    else if (worldY < surfaceHeight)
                    {
                        chunkData[x, y, z] = new DirtBlock(pos, chunk.gameObject, this);
                    }
                    else
                    {
                        chunkData[x, y, z] = new AirBlock(pos, chunk.gameObject, this);
                    }

                    if (chunkData[x, y, z].bType != Block.BlockType.WATER && Utils.fBM3D(worldX, worldY, worldZ, 0.08f, 3) < 0.42f)
                    {
                        chunkData[x, y, z] = new AirBlock(pos, chunk.gameObject, this);
                    }
                    if (worldY < 65 && chunkData[x, y, z].bType == Block.BlockType.AIR)
                    {
                        chunkData[x, y, z] = new WaterBlock(pos, fluid.gameObject, this);
                    }
                    if (worldY == 0)
                    {
                        chunkData[x, y, z] = new BedRockBlock(pos, chunk.gameObject, this);
                    }

                    status = ChunkStatus.DRAW;
                }
            }
        }
    }