コード例 #1
0
    private void CreateTornado(Vector3 start, Vector3 end, TornadoDirection direction)
    {
        GameObject tornado = Instantiate(tornadoPrefab);

        tornado.transform.position              = start;
        tornado.GetComponent <Tornado>().speed  = speed;
        tornado.GetComponent <Tornado>().easing = 1;
        tornado.GetComponent <Tornado>().SetTarget(end);
    }
コード例 #2
0
    public void Init(float duration, TornadoDirection direction, List <ScarecrowPart> parts)
    {
        base.Init(duration);

        Vector3 start = Vector3.zero;
        Vector3 end   = Vector3.zero;

        _direction = direction;
        _parts     = parts;

        StartCoroutine(CreateExplosions());


        if (direction == TornadoDirection.FrontToBack)
        {
            start = new Vector3(minX, 4, 10);
            end   = new Vector3(-8, 3, 10);

            speed = ((end - start).magnitude * 3f) / duration;

            CreateTornado(start, end, TornadoDirection.LeftToRight);

            start = new Vector3(maxX, 4, 10);
            end   = new Vector3(8, 3, 10);

            speed = ((end - start).magnitude * 3f) / duration;

            CreateTornado(start, end, TornadoDirection.RightToLeft);
        }
        else
        {
            if (direction == TornadoDirection.LeftToRight)
            {
                start = new Vector3(minX, 4, 10);
                end   = new Vector3(-8, 3, 10);
            }
            else if (direction == TornadoDirection.RightToLeft)
            {
                start = new Vector3(maxX, 4, 10);
                end   = new Vector3(8, 3, 10);
            }

            speed = ((end - start).magnitude * 3f) / duration;

            CreateTornado(start, end, _direction);
        }
    }