Ejemplo n.º 1
0
    private IEnumerator DoParabola()
    {
        var bullet = transform;

        while (_animationTime <= AnimationDuration)
        {
            _animationTime += Time.deltaTime;
            var newPos = MathParabola.Parabola(Origin, _realTarget, 10f, _animationTime * AnimationSpeed);
            bullet.position = newPos;
            bullet.LookAt(_realTarget);
            bullet.Rotate(Vector3.right, 90 * _animationTime / AnimationDuration);
            yield return(null);
        }

        var inRange = Physics.OverlapSphere(transform.position, 5f);
        var minions = inRange.Select(c => c.GetComponent <Minions>()).Where(m => m != null).ToArray();

        foreach (var minion in minions)
        {
            if (minion)
            {
                minion.takeDmg(Damage);
            }
        }

        Instantiate(explosion, transform.position, Quaternion.identity);
        Destroy(gameObject);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        ///////////////////////////////////// 타겟의 사이즈 변화주는 것
        transform.localScale += target_scale;
        if (transform.localScale.x >= 1.7) // 너무 커지면 줄이고
        {
            target_scale = new Vector3(-0.005f, -0.005f, 0);
        }
        else if (transform.localScale.x <= 1.3) // 너무 작아지면 키우고
        {
            target_scale = new Vector3(0.005f, 0.005f, 0);
        }

        ///////////////////////////////////// 타겟 움직임 그려내는 것
        if (Animation % duration < 0.02)                // 새로운 루프 시작할 때 타겟 위치, 이동범위 재 설정
        {
            startPoint.x = Random.RandomRange(-8f, 8f); // 시작점 좌표 지정
            startPoint.y = Random.RandomRange(-5f, 5f);

            width  = Random.RandomRange(3f, 8f); // 너비, 높이 지정
            height = Random.RandomRange(2f, 6f);
        }

        Animation += Time.deltaTime;
        Animation  = Animation % duration; // 루프를 위한 설정

        transform.position = MathParabola.Parabola(startPoint, Vector3.left * width, height, Animation / duration);
        //transform.Rotate += 1;
    }
Ejemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     interpolate += Time.deltaTime;
     interpolate  = interpolate % destTime;
     //transform.position = MathParabola.Parabola(Vector3.zero, Vector3.forward * 10f, 5f, Animation / destTime);
     transform.position = MathParabola.Parabola(Vector3.zero, target.position, height, interpolate / destTime);
 }
Ejemplo n.º 4
0
    private void Update()
    {
        if (shouldMoveToTarget && currentObj != null)
        {
            this.currentObj.gameObject.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            this.currentObj.gameObject.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;

            Animation += Time.deltaTime;

            Animation = Animation % 2f;

            this.currentObj.gameObject.transform.position = MathParabola.Parabola(this.currentObj.gameObject.transform.position, target.gameObject.transform.position, .3f, Animation / 8f);
            //this.currentObj.gameObject.transform.position = Vector3.MoveTowards(this.currentObj.gameObject.transform.position, this.target.gameObject.transform.position, 5f * Time.deltaTime);
            //this.currentObj.GetComponent<Rigidbody>().detectCollisions = true;
            if (Vector3.Distance(this.currentObj.gameObject.transform.position, this.target.gameObject.transform.position) < 1)
            {
                shouldMoveToTarget = false;
                currentObj         = null;
                Animation          = 0;
            }
        }

        if (this.HasPuzzleFinished() && !hasPlayedPuzzleAnimation)
        {
            StartCoroutine(ExecuteAfterTime(4));
            this.hasPlayedPuzzleAnimation = true;
        }
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        List <Vector3> path = new List <Vector3>();

        float distance = 0;
        float pathTime = 0;

        for (int i = 0; i < 100; i++)
        {
            time    += Time.deltaTime * speed;
            time    %= 5f;
            pathTime = time / 5f;

            if (time < prevTime)
            {
                break;
            }

            Vector3 point = MathParabola.Parabola(Vector3.zero, endPosition, height, time / 5f);
            path.Add(point);

            if (i > 0)
            {
                distance += Vector3.Distance(point, path[i - 1]);
            }

            prevTime = time;
        }
        time = prevTime = 0;

        //float pathTime = distance / (speed * Time.deltaTime);
        print(pathTime);
    }
Ejemplo n.º 6
0
    private void MoveReticleToCollisionPoint()
    {
        RaycastHit raycastHit;
        Vector3    pointA, pointB;
        LayerMask  layerMask = LayerMask.GetMask("EnemyHitbox", "OceanHitbox");

        for (int i = 0; i < 13; i++)
        {
            pointA = MathParabola.Parabola(
                cannonballOrigin.transform.position,
                reticleAim.transform.position,
                parabolaHeight,
                i / 10f);

            pointB = MathParabola.Parabola(
                cannonballOrigin.transform.position,
                reticleAim.transform.position,
                parabolaHeight,
                (i + 1) / 10f);

            if (Physics.Raycast(
                    pointA,
                    (pointB - pointA).normalized,
                    out raycastHit,
                    (pointA - pointB).magnitude,
                    layerMask))
            {
                reticleVisual.transform.position = raycastHit.point;
                reticleVisual.transform.rotation = Quaternion.LookRotation(raycastHit.normal);
                Debug.DrawLine(pointA, pointB, Color.red);
                break;
            }
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        animation += Time.deltaTime;

        animation = animation % 5;

        transform.position = MathParabola.Parabola(Vector3.zero, Vector3.forward * 10f, 5f, animation / 5f);
    }
Ejemplo n.º 8
0
    void ball1()
    {
        Animation += Time.deltaTime;

        Animation = Animation % 7f;   //  sec loop

        transform.localPosition = MathParabola.Parabola(Vector3.zero, Vector3.forward * -7f, 2f, Animation / 1f);
    }
Ejemplo n.º 9
0
 private void SetCannonbarrelRotation()
 {
     cannonballBarrelPivot.transform.LookAt(MathParabola.Parabola(
                                                cannonballOrigin.transform.position,
                                                reticleAim.transform.position,
                                                parabolaHeight,
                                                0.4f));
 }
Ejemplo n.º 10
0
 // Update is called once per frame
 void Update()
 {
     Animation         += Time.deltaTime;
     Animation          = Animation % 5f;
     transform.position = MathParabola.Parabola(PosInit, PosEnd, 1f, Animation / 4f);
     if (transform.position.y < -5.0f)
     {
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 11
0
 private void DrawTrajectoryArc()
 {
     for (float i = 1; i <= _numberOfTrajectoryElements; i++)
     {
         Vector3 currentPisiton = MathParabola.Parabola(_start, _end, Height, i / (float)_numberOfTrajectoryElements);
         _trajectoryElements[(int)i - 1].transform.position = currentPisiton;
         Vector3 nextPosition = MathParabola.Parabola(_start, _end, Height, (i + 1) / (float)_numberOfTrajectoryElements);
         float   angle        = Mathf.Atan2(nextPosition.y - currentPisiton.y, nextPosition.x - nextPosition.x);
         _trajectoryElements[(int)i - 1].transform.eulerAngles = new Vector3(0, (Mathf.Rad2Deg * angle) - 90, 0);
     }
 }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (TargetPosition != StartPosition)
        {
            AnimationTime += Time.deltaTime;
            AnimationTime  = Math.Min(AnimationTime, CompletionTime);

            _rigidbody2D.position =
                MathParabola.Parabola(StartPosition, TargetPosition + TargetTrajectoryOffset, Height,
                                      AnimationTime / CompletionTime);
        }
    }
Ejemplo n.º 13
0
    void Update()
    {
        _animation += Time.deltaTime;
        _animation  = _animation % divisor;
        transform.GetChild(0).position = MathParabola.Parabola(transform.position, posFreezy.position, 3f, _animation / divisor);

        if (transform.GetChild(0).position == posFreezy.position)
        {
            Debug.Log("destrui");
            Destroy(gameObject);
        }
    }
Ejemplo n.º 14
0
    void Update()
    {
        Animation += Time.deltaTime;

        Animation = Animation % 5f;



        Vector3 start = new Vector3(x, y, z);

        transform.position = MathParabola.Parabola(start, Vector3.forward * 10f, 5f, Animation / 5f);
    }
    private void ChangeJumpPosition()
    {
        jumpDelta += Time.deltaTime;

        transform.position = MathParabola.Parabola(startJumpPosition, endJumpPosition, 3f, Mathf.Clamp01(jumpDelta / 0.75f));

        if (jumpDelta / 0.75f >= 1.0f)
        {
            isJumping = false;
            agent.Warp(transform.position);
        }
    }
Ejemplo n.º 16
0
    IEnumerator ParabolaJump(Vector3 end, string dir)
    {
        float t = Time.deltaTime;

        while (t < Config.JUMP_TIME)
        {
            transform.position = MathParabola.Parabola(rb.position, end, Config.JUMP_HEIGHT, t / Config.JUMP_TIME, dir);
            t += Time.deltaTime;
            yield return(null);
        }
        transform.position = end;
    }
Ejemplo n.º 17
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (ziemia == 0 && p1.transform.localScale.x < 2.7f)
     {
         Animation += Time.deltaTime;
         Animation  = Animation % 5f;
         //if(ParabolaGrow.throw1.x>-6)
         transform.position = MathParabola.Parabola(startPosition, ParabolaGrow.throw1, ParabolaGrow.throw2 + 2, Animation / 1.5f);
         //else
         //transform.position = MathParabola.Parabola(startPosition,new Vector2(-6,0), .3f, Animation / 1.5f);
     }
 }
    // Update is called once per frame
    void Update()
    {
        animation += Time.deltaTime;

        //(animation / speed)는 0 과 1 사이의 보간계수이므로 animation은 speed를 넘지 않아야한다.
        if (animation > inversedSpeed)
        {
            //목표지점에서 물리를 무시하고 멈추고 싶다면 animation = inversedSpeed; 를 쓰자.
            return;
        }

        transform.position = MathParabola.Parabola(initialPos, initialPos + transform.forward * reach, height, animation / inversedSpeed);
    }
Ejemplo n.º 19
0
    void Update()
    {
        _animation += Time.deltaTime;
        _animation  = _animation % divisor;
        transform.GetChild(0).position = MathParabola.Parabola(transform.position, posFreezy.position, 3f, _animation / divisor);

        Debug.Log(MathParabola.Parabola(transform.position, posFreezy.position, 3f, _animation / divisor));

        if (Vector3.Distance(transform.GetChild(0).position, posFreezy.position) < 1)
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;
        timer  = Mathf.Clamp(timer, 0, 6);

        if (timer == 0)
        {
            if (notOnGround == false)
            {
                Instantiate(Turret, transform.position + new Vector3(0, -.65f), Quaternion.Euler(0, rotation, 0));
                if (rotation == 0)
                {
                    GameObject.Find("Gnome Turret(Clone)").GetComponent <Turret>().shootRotation = 1;
                }
                Destroy(gameObject);
            }

            if (notOnGround == true)
            {
                canhitObj = true;
            }
        }

        if (hitObj == true)
        {
            Instantiate(Turret, transform.position + new Vector3(0, -.65f), Quaternion.Euler(0, rotation, 0));
            if (rotation == 0)
            {
                GameObject.Find("Gnome Turret(Clone)").GetComponent <Turret>().shootRotation = 1;
            }

            Destroy(gameObject);
        }
        Animation += Time.deltaTime;

        Animation = Animation % 5f;

        transform.position = MathParabola.Parabola(new Vector3(PlayersX, PlayersY, 0), endPoint, 2.5f, Animation / 1.5f);
        hitColliders       = Physics.OverlapSphere(transform.position, 1f);

        foreach (Collider nearbyObj in hitColliders)
        {
            if (canhitObj == true)
            {
                if (nearbyObj.tag == "Ground" || nearbyObj.tag == "Wall")
                {
                    hitObj = true;
                }
            }
        }
    }
Ejemplo n.º 21
0
 private void Parabola()
 {
     if (Vector3.Distance(transform.position, rampPoints[1].position) <= parabolaFinishThreshold)
     {
         onRampJump   = false;
         onFinishRamp = true;
     }
     else
     {
         Animation         += Time.deltaTime;
         Animation          = Animation % 5f;
         transform.position = MathParabola.Parabola(rampPoints[0].position, rampPoints[1].position, rampJumpHeight, Animation / rampJumpSpeed);
     }
 }
Ejemplo n.º 22
0
    private void doParabolaUpdate(string direction)
    {
        float dynamicSpeed = journeyLength / movementDuration;

        // Distance moved equals elapsed time times speed..
        float distCovered = (Time.time - startTime) * dynamicSpeed;

        // Fraction of journey completed equals current distance divided by total distance.
        float fractionOfJourney = distCovered / journeyLength;

        // Set our position as a fraction of the distance between the markers.
        transform.position = MathParabola.Parabola(startTrajectory.position, endTrajectory.position, 0.5f, fractionOfJourney, direction);
        transform.rotation = Quaternion.Lerp(startTrajectory.rotation, endTrajectory.rotation, fractionOfJourney);
    }
Ejemplo n.º 23
0
    private void FixedUpdate()
    {
        paraboleVariable += Time.deltaTime;
        paraboleVariable  = paraboleVariable % divisor;

        if (startPosition == position1)
        {
            if (transform.position.y <= startPosition.y + 0.1f)
            {
                animator.SetBool("Jump", false);
                position1 = target.position;
                position2 = startPosition;
                waiting   = true;
                oposite   = true;
            }
        }
        else
        {
            if (transform.position.y <= startPosition.y + 0.1f)
            {
                animator.SetBool("Jump", false);
                position2 = target.position;
                position1 = startPosition;
                waiting   = true;
                oposite   = false;
            }
        }
        elapse += Time.deltaTime;
        if (elapse >= timeWaitting)
        {
            waiting = false;
            animator.SetBool("Jump", true);
            elapse = 0f;
            if (oposite)
            {
                transform.localScale = new Vector3(-localScale.x, localScale.y, localScale.z);
                transform.position   = position2;
            }
            else
            {
                transform.localScale = localScale;
                transform.position   = position1;
            }
        }
        if (!waiting)
        {
            transform.position = MathParabola.Parabola(position1, position2, heigth, paraboleVariable / ajustador);
        }
    }
Ejemplo n.º 24
0
    private void DisplayParabolaTrajectory()
    {
        Vector3[] linePoints = new Vector3[11];

        for (int i = 0; i <= 10; i++)
        {
            linePoints[i] = MathParabola.Parabola(
                cannonballOrigin.transform.position,
                reticleAim.transform.position,
                parabolaHeight,
                i / 10f);
        }

        lineRenderer.SetPositions(linePoints);
    }
Ejemplo n.º 25
0
    public void Move()
    {
        transform.position = MathParabola.Parabola(spawnPoint, endPoint, arcHeight, moveInterpolator);
        moveInterpolator  += Time.deltaTime / 4;
        if (moveInterpolator > 0.2)
        {
            ChangeState(BAStates.ATTACK);
        }

        if (moveInterpolator > 1)
        {
            isAttacking = false;
            StopAllCoroutines();
            pooler.ReturnToPool(this.gameObject);
        }
    }
Ejemplo n.º 26
0
    void Update()
    {
        Animation += Time.deltaTime;
        if (Animation > flightTime)
        {
            ReportImpact();
            ObjectPoolHelper.Destroy(gameObject);
        }

        Animation          = Animation % flightTime;
        transform.position = MathParabola.Parabola(
            startPosition,
            endPosition,
            maxHeight,
            Animation / flightTime);
    }
Ejemplo n.º 27
0
    IEnumerator TransferToBoatParabola(Vector3 startPos, Vector3 endPos)
    {
        float dist = 0;

        transform.Find("ParticleHolder").GetComponent <ParticleSystem>().Play();
        Debug.Log("Moving into Boat");
        dist = Vector3.Distance(transform.position, endPos);
        while (dist > 0.1f)
        {
            parabolaAnimation += Time.deltaTime;
            parabolaAnimation  = parabolaAnimation % 5f;
            if (spacebarDown)
            {
                endPos = Boat_LP.Instance.cargoPosition.position;
                Debug.Log("we're inside the parabola loop");
                dist = Vector3.Distance(transform.position, endPos);
                transform.position = MathParabola.Parabola(startPos, endPos, 1.2f, parabolaAnimation / 5f);
            }
            else
            {
                canceledParabola   = true;
                dist               = Vector3.Distance(transform.position, startPos);
                transform.position = MathParabola.Parabola(transform.position, startPos, 1.2f, parabolaAnimation / 5f);
                Debug.Log("Canceled Parabola");
            }
            yield return(null);
        }
        transform.Find("ParticleHolder").GetComponent <ParticleSystem>().Stop();

        if (canceledParabola)
        {
            Debug.Log("Canceled Parabola so we're returning to start position.");
            transform.position = startPos;
            canceledParabola   = false;
            PlayerGaze.Instance.ClearGaze();
            yield break;
        }

        transform.position = endPos;
        animalStatus       = BankStatus.Boat;
        transform.SetParent(Boat_LP.Instance.transform.Find("Boat"));
        transform.GetComponent <Collider>().enabled = false;
        Boat_LP.Instance.cargo = gameObject;
        PlayerGaze.Instance.ClearGaze();
        Debug.Log("Made it to the part where the boat Cargo is set...");
    }
Ejemplo n.º 28
0
    IEnumerator BeginJump(Vector3 endPos)
    {
        Vector3 beginPos = transform.position;

        float jumpElapsed = 0;

        float ratio = 0;

        active = false;

        MFPP.Audio.Play3D(hopSound, gameObject.transform, Toolbox.Instance.soundEffectsVolume, 1f);

        while (jumpElapsed < jumpDuration)
        {
            jumpElapsed += Time.deltaTime;

            ratio = jumpElapsed / jumpDuration;

            transform.position = MathParabola.Parabola(beginPos, endPos, jumpHeight, (TweeningFunctions.EaseMiddle(ratio) + ratio) / 2f);
            //Vector3.Lerp(beginPos, endPos, TweeningFunctions.EaseInOutCubic(elapsed/jumpDuration));
            yield return(null);
        }

        transform.position = endPos;
        hopParticles.Play();
        if (Toolbox.Instance.PlayerInLaser())
        {
            MFPP.Audio.Play3D(thudSound, transform, Toolbox.Instance.soundEffectsVolume, 1f);
        }

        waypointIndex++;

        rotationTimer = 0f;


        if (repeat && waypointIndex == waypoints.Length)
        {
            waypointIndex = 0;
        }

        if (waypointIndex < waypoints.Length)
        {
            //Debug.LogError("Going to next");
            active = true;
        }
    }
Ejemplo n.º 29
0
        private void Update()
        {
            if (!isActive)
            {
                return;
            }

            m_Animation += Time.deltaTime;
            m_Animation %= speedFlight;

            m_Transform.position = MathParabola.Parabola(startPoint, endPoint, height, m_Animation / speedFlight);

            if (Vector3.Distance(m_Transform.position, endPoint) < 0.5f)
            {
                isActive = false;
            }
        }
Ejemplo n.º 30
0
 private void ThrowRock()
 {
     if (RockSpawned != null)
     {
         _animation += Time.deltaTime * 2.0f;
         _animation  = _animation % 5;
         RockSpawned.transform.position = MathParabola.Parabola(_trajectoryElements[0].transform.position, _end, Height, _animation);
         if (RockSpawned.transform.position.y < -1)
         {
             RockSpawned.transform.position = new Vector3(RockSpawned.transform.position.x, 0.0f,
                                                          RockSpawned.transform.position.z);
         }
     }
     else
     {
         _animation = 0.0f;
     }
 }