示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            // Create Yoba in selected location
            Vector3 SpawnPos = cachedCamera.ScreenToWorldPoint(Input.mousePosition);
            SpawnPos.z = 0.0f;

            // Don't create if we hit existed Yoba
            if (!Physics2D.OverlapCircle(SpawnPos, 1.0f))
            {
                GameObject AnotherYoba = GameObject.Instantiate(settings.Yoba, SpawnPos, Quaternion.identity);
                AnotherYoba.layer = 8 + Mathf.FloorToInt(Random.Range(0.0f, 2.1f));
                AnotherYoba.transform.localScale = new Vector3(0.05f, 0.05f, 1.0f);

                Yoba yobaSoul = AnotherYoba.GetComponent <Yoba>();
                if (yobaSoul != null)
                {
                    float TheScaleOfYoba = Mathf.Lerp(settings.MinYobaSize, settings.MaxYobaSize, Random.value);
                    yobaSoul.ScaleSmooth(new Vector3(TheScaleOfYoba, TheScaleOfYoba, 1.0f));
                }
                else
                {
                    // missing component
                    Debug.LogError("YOBA BEZ DUSHI, ALLO!");
                }
            }
        }
    }
示例#2
0
        private void StartRolling()
        {
            double nRotation = 360 * 450 / 2 / Math.PI / 25;

            // Constant speed
            Random          rnd  = new Random();
            int             temp = rnd.Next(4, 100);
            DoubleAnimation da   = new DoubleAnimation(0, 900, TimeSpan.FromSeconds(temp));

            da.RepeatBehavior = RepeatBehavior.Forever;
            da.AutoReverse    = true;
            Yoba.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, nRotation, TimeSpan.FromSeconds(temp));
            da.RepeatBehavior = RepeatBehavior.Forever;
            da.AutoReverse    = true;
            yobaRotate.BeginAnimation(RotateTransform.AngleProperty, da);

            // Acceleration
            temp = rnd.Next(4, 100);
            da   = new DoubleAnimation(0, 900, TimeSpan.FromSeconds(temp));
            da.AccelerationRatio = 1.0;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            YobaAnime.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, nRotation, TimeSpan.FromSeconds(temp));
            da.AccelerationRatio = 1.0;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            animeYobaRotate.BeginAnimation(RotateTransform.AngleProperty, da);

            // Decelaration
            temp = rnd.Next(4, 100);
            da   = new DoubleAnimation(0, 900, TimeSpan.FromSeconds(temp));
            da.DecelerationRatio = 0.6;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            ellipse3.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, nRotation, TimeSpan.FromSeconds(temp));
            da.DecelerationRatio = 0.6;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            ellipse3Rotate.BeginAnimation(RotateTransform.AngleProperty, da);

            // Acceleration + Deceleration
            temp = rnd.Next(4, 100);
            da   = new DoubleAnimation(0, 900, TimeSpan.FromSeconds(temp));
            da.DecelerationRatio = 0.6;
            da.AccelerationRatio = 0.4;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            yoba4.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, nRotation, TimeSpan.FromSeconds(temp));
            da.DecelerationRatio = 0.6;
            da.AccelerationRatio = 0.4;
            da.RepeatBehavior    = RepeatBehavior.Forever;
            da.AutoReverse       = true;
            yoba4Rotate.BeginAnimation(RotateTransform.AngleProperty, da);
        }