Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        //---SceneTrigger
        if (collider.gameObject.layer == LayerMask.NameToLayer("SceneTrigger"))
        {
            PlayerStatus.isInInteractTrigger = true;
        }
        //---水中---
        if (collider.gameObject.layer == LayerMask.NameToLayer("WaterArea"))
        {
            water_area = collider.GetComponent <Water_Area>();

            for (int x = 0; x < 3; x++)
            {
                spriteRenderer[x].sortingLayerName = "Scene"; spriteRenderer[x].sortingOrder = -1;
            }
            speedLimit *= speedDownRate;
            rb2d.drag   = waterDrag;
            isInWater   = true;

            //跳入水面的水花
            if (rb2d.velocity.y < -1.5f)
            {
                float splashScale = Mathf.Lerp(0.2f, 0.8f, rb2d.velocity.y / -20f);

                GameObject splash = Instantiate(waterSplashFX, transform.position + new Vector3(0, 0.75f * splashScale, 0f), Quaternion.identity);

                Vector3 oriScale = splash.GetComponent <Transform>().localScale;
                splash.GetComponent <Transform>().localScale = oriScale * splashScale;

                Destroy(splash, 1f);
            }
        }
    }
        public void GetModelItem_Water_Area_Test()
        {
            Water_Area water_area = iwSvc.GetModelItem <Water_Area>(1, "water_areas", "water_areas", 1);

            Assert.IsNotNull(water_area, "null result, error happens.");
            Assert.AreEqual("1", water_area.id);

            Assert.AreEqual(AiwGeometryType.Polygon, water_area.geometry.Type);
            Assert.AreEqual(-122.59862145026804, (water_area.geometry as AiwPolygon).LinearRings[0].Coordinates[0].X, 0.000001);

            Assert.AreEqual(AiwGeometryType.NoGeometry, water_area.model_scale.Type);
        }
Exemplo n.º 3
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.layer == WaterLayerID)
        {
            water_area       = collision.GetComponent <Water_Area>();
            rb2d.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezeRotation;

            if (water_area.waveCrest - transform.position.y > 0.4f * GetComponent <BoxCollider2D>().size.y)
            {
                rb2d.AddForce(Vector2.up * FloatForce);
            }
            else if (water_area.waveCrest - transform.position.y > 0f)
            {
                rb2d.AddForce(Vector2.up * FloatForce * (water_area.waveCrest - transform.position.y / 1f));
            }
            InWater = true;
        }
    }
Exemplo n.º 4
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.layer == WaterLayerID)
        {
            water_area = collision.GetComponent <Water_Area>();
            rb2d.drag  = 3f;


            spriteRenderer.sortingLayerName = "Scene"; spriteRenderer.sortingOrder = -1;

            isInWater = true;
        }

        if (collision.gameObject.GetComponent <Thorns>() != null)
        {
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //Fibonacci number
            //var ret = Fibonacci.GetNthFib(6);

            //River
            //var inp = new int[,] {
            //              { 1, 0, 0, 1, 0 },
            //              { 1, 0, 1, 0, 0 },
            //              { 0, 0, 1, 0, 1 },
            //              { 1, 0, 1, 0, 1 },
            //              { 1, 0, 1, 1, 0 } };
            //var ret = RiverSize.GetRiverSize(inp);

            //Numbers to Roman numbers
            //var ret = RomanNumbers.ToRoman(409); //CDIX

            //// Boggle board
            //char[,] board =  {
            //    {'A', 'B', 'C', 'E' },
            //    { 'S', 'F', 'C', 'S' },
            //    { 'A', 'D', 'E', 'E' }
            //};
            //string word = "ABCCED";
            ////"ABCCED, true
            ////"SEE", true
            ////"ABCB", false
            //var ret = BoogleBoard.Exist(board, word);

            //NumberOfIslands.NumberOfIslandsSolution();

            //_1189_Maximum_Number_Of_Balloons.MaxNumerOfBalloons();
            //_1140_Remove_All_Adjacent_Duplicates.Remove_All_Adjacent_Duplicates();
            //_11_Container_With_Most_Water.Container_With_Most_Water();
            //Insertion_Sort.InsertionSort(new int[] { 8, 5, 2, 9, 5, 6, 3 });
            //Product_Sum.ProductResult(new List<object> { 5, 2, new List<object> { 7, -1 }, 3, new List<object> { 6, new List<object> { -13, 8 }, 4 } });
            //Two_Number_Sum.Solution(new int[] { 3, 5, -4, 8, 11, 1, -1, 6 }, 10);
            //Three_Number_Sum.ThreeNumberSum(new int[] { 12, 3, 1, 2, -6, 5, -8, 6 }, 0);
            //FakeBinary.FakeBin("45385593107843568");
            //Smallest_Difference.Solution();
            Water_Area.Solution();

            Console.ReadKey();
        }