Example #1
0
    void Awake()
    {
        curveMath = curve.GetComponent <BGCcMath>();
        rb        = GetComponent <Rigidbody>();

        // Replace();
    }
Example #2
0
    void Start()
    {
        this.cam = GameObject.FindGameObjectWithTag("MainCamera");
        this.Gamemaster = GameObject.FindGameObjectWithTag("GameController");
        this.gameMasterAttributes = this.Gamemaster.GetComponent<GameMaster>();
        this.waveSpawner = this.Gamemaster.GetComponent<Wavespawner>();

        this.bubble = transform.gameObject;
        this.bubbles = this.gameMasterAttributes.bubbles;
        this.curve = this.gameMasterAttributes.curve;
        this.mathe = this.curve.GetComponent<BGCcMath>();
        this.cursor = this.mathe.gameObject.AddComponent<BGCcCursor>();
        this.rigidBodyAttr = transform.GetComponent<Rigidbody>();

        this.rotationSpeed = 150;

        this.currentWaypoint = this.cursor.CalculateSectionIndex();

        this.movedBubbleRow = new Transform[this.bubbles.childCount];

        if (!this.isShooted)
        {
            this.checkBubbleState();
            if (!this.isFirstBubble)
            {
                this.bubble.GetComponent<MoveOnSpline>().distanceCalc = this.bubble.GetComponent<Bubble>().beforeBubble.GetComponent<MoveOnSpline>().distanceCalc - this.gameMasterAttributes.bubbleSizeAverage;
            }

        }

    }
Example #3
0
 // Use this for initialization
 void Start()
 {
     // Get the references to the flight path cursor movement
     flightPathSpeeds  = GameObject.Find("Flight Path").GetComponents <BGCcCursorChangeLinear>();
     flightPathCursors = GameObject.Find("Flight Path").GetComponents <BGCcCursor>();
     flightPathMath    = GameObject.Find("Flight Path").GetComponent <BGCcMath>();
     // Get the referneces to the info icons
     infoIcons = GameObject.Find("Info Icons");
     // Get reference to player
     playerController = GameObject.Find("Player Group").transform.GetChild(0).GetComponent <PlayerController>();
     playerAnim       = GameObject.Find("Player Group").transform.GetChild(0).GetComponent <AnimationController>();
     // Setup black screens; Duplicate the template so there's one for each display (max 8 displays, so just make the rest, displays 2-8)
     GameObject[] canvases = new GameObject[8];
     canvases[0]     = GameObject.Find("Canvas");
     blackScreens[0] = canvases[0].transform.GetChild(0).gameObject.GetComponent <Image>();
     for (int i = 1; i < 8; i++)
     {
         canvases[i] = Instantiate(canvases[0]);
         // Default display is 1. Set correct target display for canvases 2-8
         canvases[i].GetComponent <Canvas>().targetDisplay = i + 1;
         blackScreens[i] = canvases[i].transform.GetChild(0).gameObject.GetComponent <Image>();
     }
     // Setup game for the first time
     resetBird();
 }
Example #4
0
    void Start()
    {
        if (gameCtrl == null)
        {
            GameObject go = GameObject.Find("GameController");
            gameCtrl = (GameController)go.GetComponent(typeof(GameController));
        }
        startTime = Time.time;
        math1     = path1.GetComponent <BGCcMath>();

        // spawn enemies
        if (Enemy_Types.Length > 0)
        {
            for (int j = quantity - 1; j >= 0; j--)
            {
                Vector3    pos3 = GetPositionDist(j * spacing);
                GameObject item;
                if (randomize)
                {
                    item = Enemy_Types[Random.Range(0, Enemy_Types.Length)].gameObject;
                }
                else
                {
                    item = Enemy_Types[(enemyIndex++) % Enemy_Types.Length].gameObject;
                }
                GameObject go = (GameObject)Instantiate(item, pos3, Quaternion.identity); // local space coordinates
                go.transform.SetParent(transform, false);                                 // transform to world space by nesting with parent
                gameCtrl.EnemySpawned(go.GetInstanceID());
            }
        }
    }
        // Use this for initialization
        private void Start()
        {
            //init components
            curve        = gameObject.AddComponent <BGCurve>();
            curve.Closed = true;
            math         = gameObject.AddComponent <BGCcMath>();
            gameObject.AddComponent <BGCcVisualizationLineRenderer>();
            var lineRenderer = gameObject.GetComponent <LineRenderer>();

            lineRenderer.sharedMaterial = LineRendererMaterial;
            lineRenderer.SetWidth(.03f, .03f);
            var color = new Color(.2f, .2f, .2f, 1f);

            lineRenderer.SetColors(color, color);
            math.SectionParts = NumberOfSplits;

            //create curve's points
            for (var i = 0; i < NumberOfCurvePoints; i++)
            {
                var controlRandom = Random.Range(0, 3);
                var controlType   = BGCurvePoint.ControlTypeEnum.Absent;
                switch (controlRandom)
                {
                case 1:
                    controlType = BGCurvePoint.ControlTypeEnum.BezierIndependant;
                    break;

                case 2:
                    controlType = BGCurvePoint.ControlTypeEnum.BezierSymmetrical;
                    break;
                }
                curve.AddPoint(new BGCurvePoint(curve,
                                                Vector3.zero,
                                                controlType,
                                                RandomVector() * .3f,
                                                RandomVector() * .3f));
            }

            //init arrays
            oldPointPos      = new Vector3[NumberOfPointsToSeek];
            newPointPos      = new Vector3[NumberOfPointsToSeek];
            oldCurvePointPos = new Vector3[NumberOfCurvePoints];
            newCurvePointPos = new Vector3[NumberOfCurvePoints];

            InitArray(newCurvePointPos, oldCurvePointPos);
            InitArray(newPointPos, oldPointPos);

            //create objects
            objects = new GameObject[NumberOfPointsToSeek];
            for (var i = 0; i < NumberOfPointsToSeek; i++)
            {
                var clone = Instantiate(PointIndicator);
                clone.transform.parent = transform;
                objects[i]             = clone;
            }
            PointIndicator.SetActive(false);

            //init cycle
            InitCycle();
        }
Example #6
0
 // Start is called before the first frame update
 void Start()
 {
     particle.transform.position = new Vector3(curve[0].PositionWorld.x, curve[0].PositionWorld.y, particle.transform.position.z - 1f);
     fillrenderer = GetComponent <LineRenderer>();
     math         = curve.GetComponent <BGCcMath>();
     particle.gameObject.SetActive(true);
     game = game = (GameController)GameObject.FindGameObjectWithTag("gameController").GetComponent(typeof(IGameController));
 }
Example #7
0
 private void Start()
 {
     curve = GetComponent <BGCurve>();
     math  = curve.GetComponent <BGCcMath>();
     notes = new List <GameObject>();
     s     = DOTween.Sequence();
     s.Play();
 }
Example #8
0
 public void Init()
 {
     trackMath           = GetComponent <BGCcMath> ();
     LeftPoint           = trackMath.Curve.Points.First().PositionWorld;
     RightPoint          = trackMath.Curve.Points.Last().PositionWorld;
     LeftTrackPathUnits  = new List <TrackPathUnit> ();
     RightTrackPathUnits = new List <TrackPathUnit> ();
     PathLenght          = trackMath.GetDistance();
 }
Example #9
0
    void Start()
    {
        cam = currentCameraGO.Value.GetComponent <Camera>();

        curveMath     = curve.GetComponent <BGCcMath>();
        distanceDone  = 0;
        distanceTotal = curveMath.GetDistance();
        Compute();
    }
Example #10
0
    void CreateSplineComponents(GameObject splineObject)
    {
        spline            = splineObject.AddComponent <BGCurve>();
        spline.PointsMode = BGCurve.PointsModeEnum.GameObjectsTransform;
        math        = splineObject.AddComponent <BGCcMath>();
        math.Fields = BGCurveBaseMath.Fields.PositionAndTangent;
        cursor      = splineObject.AddComponent <BGCcCursor>();

        var field = spline.AddField(Keys.NORMAL_FIELD, BGCurvePointField.TypeEnum.Vector3);
    }
 public EffectDynamicCurve(GameObject target, float period, params Light[] lights)
     : base(period, period)
 {
     target.AddComponent <BGCurve>();
     math = target.AddComponent <BGCcMath>();
     math.Curve.Closed  = true;
     this.lights        = lights;
     fromDistanceRatios = new float[lights.Length];
     toDistanceRatios   = new float[lights.Length];
 }
Example #12
0
    // Update is called once per frame
    void Update()
    {
        if (activeWorldPath != null)
        {
            BGCcMath math = activeWorldPath.GetComponent <BGCcMath>();

            Vector3 tangent;
            worldBase.transform.position  = math.CalcPositionAndTangentByDistanceRatio(TimeManager.TurnRatio, out tangent);
            worldModel.transform.rotation = Quaternion.LookRotation(tangent, worldBase.transform.position);
        }
    }
Example #13
0
    public void Replace()
    {
        if (curveMath == null)
        {
            curveMath = curve.GetComponent <BGCcMath>();
        }

        Vector3 tangent;

        transform.position = curveMath.CalcPositionAndTangentByDistance(0, out tangent);
        transform.rotation = QuaternionExtensions.LookRotation(tangent);
    }
Example #14
0
        //Bruteforce method for checking results only. Do not use it.
        private static Vector3 CalcPositionByClosestPoint(BGCcMath math, Vector3 targetPoint, out float distance)
        {
            var sections      = math.Math.SectionInfos;
            var sectionsCount = sections.Count;
            var result        = sections[0][0].Position;
            var minDistance   = Vector3.SqrMagnitude(sections[0][0].Position - targetPoint);

            distance = 0;
            for (var i = 0; i < sectionsCount; i++)
            {
                var currentSection = sections[i];


                var points      = currentSection.Points;
                var pointsCount = points.Count;
                for (var j = 1; j < pointsCount; j++)
                {
                    var   point = points[j];
                    float ratio;

                    var closestPoint = CalcClosestPointToLine(points[j - 1].Position, point.Position, targetPoint, out ratio);

                    var sqrMagnitude = Vector3.SqrMagnitude(targetPoint - closestPoint);
                    if (!(minDistance > sqrMagnitude))
                    {
                        continue;
                    }


                    minDistance = sqrMagnitude;
                    result      = closestPoint;

                    if (ratio == 1)
                    {
                        var sectionIndex = i;
                        var pointIndex   = j;
                        if (j == pointsCount - 1 && i < sectionsCount - 1)
                        {
                            sectionIndex = i + 1;
                            pointIndex   = 0;
                        }
                        distance = sections[sectionIndex].DistanceFromStartToOrigin + sections[sectionIndex][pointIndex].DistanceToSectionStart;
                    }
                    else
                    {
                        distance = sections[i].DistanceFromStartToOrigin + Mathf.Lerp(currentSection[j - 1].DistanceToSectionStart, point.DistanceToSectionStart, ratio);
                    }
                }
            }
            return(result);
        }
Example #15
0
    // Start is called before the first frame update
    void Start()
    {
        // TODO: test this.sceneInfos validity
        this._sceneInstances = new List <GameObject>();
        // this._sceneGroupIndices = new List<SceneGroupInstanceInfo>();

        this._sceneInstancesTravellingOffset = this.sceneInstancesDepthOffset;

        this.sceneInstancesTravelCurveSolver = this.GetComponent <BGCcMath>();
        if (this.sceneInstancesTravelCurveSolver == null)
        {
            Debug.LogError("Could not find curve solver for Travel curve");
        }
    }
Example #16
0
    void Start()
    {
        rightView = true;

        math      = Curve.GetComponent <BGCcMath>();
        headPoint = Curve.Points[0];
        midPoint  = Curve.Points[1];
        tailPoint = Curve.Points[2];

        Length      = math.GetDistance();
        minDistance = Length * 0.5f;
        prevLength  = Length;

        //UpdateBones();
    }
Example #17
0
    private void Start()
    {
        math = Route.GetComponent <BGCcMath>();

        // Длина маршрута
        totalDistance = math.GetDistance();
        // Debug.Log("totalDistance = " + totalDistance);

        // добавляем +1 , чтобы не было в краях дистанции
        // Пример: дистанция 10, нужно 4 предметов, но не нужно в 0 и в 10;
        // получится как раз в координатах 2 4 6 8
        spawnDistance = totalDistance / (SpawnCount + 1);
        // Debug.Log("spawnDistance = " + spawnDistance);

        Spawn();
    }
Example #18
0
    void Start()
    {
        curve = GameObject.FindWithTag("TrackCurve").GetComponent <BGCcMath>();

        StaticEvents.NoteHitEvent.AddListener(OnNoteHit);
        StaticEvents.NoteMissEvent.AddListener(OnNoteMiss);

        config = configLoader.config;
        Debug.Log("AudioClip is " + "Music/" + PersistantData.SelectedSong);
        var audioClip = Resources.Load <AudioClip>("Music/" + PersistantData.SelectedSong);

        if (audioClip == null)
        {
            Debug.LogError("Failed to load AudioClip");
            SceneManager.LoadSceneAsync("Scenes/MenuScene");
        }

        AudioSource.clip = audioClip;
        Cursor.lockState = CursorLockMode.Locked;
    }
Example #19
0
    // Use this for initialization
    void Start()
    {
        curve        = GetComponent <BGCurve>();
        math         = GetComponent <BGCcMath>();
        cursor       = GetComponent <BGCcCursor>();
        cursorLinear = GetComponent <BGCcCursorChangeLinear>();

        //startingspeed = objectPrefab.GetComponent<XXXXXX>().speed;

        currentSpeed       = startingSpeed;
        speedBeforeStopped = startingSpeed;
        cursorLinear.Speed = startingSpeed;

        //distance = math.Math[pointListIndex].DistanceFromStartToOrigin;
        distance = math.Math.GetDistance(pointIndex);

        //Instantiate the object
        objectToMove = Instantiate(objectPrefab, curve[0].PositionWorld, Quaternion.Euler(0, 0, 0));

        //Sets the object so that the path moves the object
        GetComponent <BGCcCursorObjectTranslate>().ObjectToManipulate = objectToMove.transform;


        //Sets the overflow to the right one in BGCCursorChangeLinear
        switch (overflowType)
        {
        case OverflowType.Stop:
            cursorLinear.OverflowControl = BGCcCursorChangeLinear.OverflowControlEnum.Stop;
            break;

        case OverflowType.Cycle:
            cursorLinear.OverflowControl = BGCcCursorChangeLinear.OverflowControlEnum.Cycle;
            break;

        case OverflowType.PingPong:
            cursorLinear.OverflowControl = BGCcCursorChangeLinear.OverflowControlEnum.PingPong;
            break;
        }
    }
Example #20
0
    // Use this for initialization
    void Start()
    {
        move = GetComponent <Move>();
        seek = GetComponent <SteeringSeek>();

        // TODO 1: Calculate the closest point in the range [0,1] from this gameobject to the path
        math = path.GetComponent <BGCcMath>();

        Vector3 clospoint = math.Curve.Points[0].PositionWorld;

        for (int i = 0; i < math.Curve.PointsCount; i++)
        {
            Vector3 distance_tank = transform.position - clospoint;
            Vector3 distance      = transform.position - math.Curve.Points[i].PositionWorld;

            if (distance.magnitude < distance_tank.magnitude)
            {
                clospoint = math.Curve.Points[i].PositionWorld;
            }
        }

        currpoint = clospoint;
    }
Example #21
0
 private void Awake()
 {
     math          = route.GetComponent <BGCcMath>();
     startingSpeed = speed;
 }
Example #22
0
        // Start is called before the first frame update
        void Start()
        {
            _math = GetComponent <Rail>().Math;

            Populate();
        }
 // Use this for initialization
 private void Start()
 {
     curve = GetComponent <BGCurve>();
     math  = GetComponent <BGCcMath>();
     Reset();
 }
Example #24
0
 // Exécuté avant Start()
 void Awake()
 {
     Curve = GetComponent <BGCurve>();
     Math  = GetComponent <BGCcMath>();
 }
    /// <summary>
    /// Update the state of the player once they are no longer in contact with the ground
    /// </summary>
    void LeaveGround()
    {
        m_leavingGround  = true;
        m_touchingGround = false;
        m_rb.useGravity  = true;

        float angleDelta = Vector3.Angle(m_currentUp, Vector3.up);

        if (angleDelta <= m_maxAdhesionDelta)
        {
            m_currentUp = Vector3.up;
        }

        if (angleDelta >= m_maxAdhesionDelta + 5)
        {
            // If the player is not in vert mode
            if (!m_vert)
            {
                // Get the quarterpipe data from the last ramp touched (if possible)
                QuarterPipeData data   = m_lastRamp.GetComponent <QuarterPipeData>();
                Transform       parent = m_lastRamp.transform.parent;
                while (!data && parent != null)
                {
                    parent = parent.parent;
                    if (parent)
                    {
                        data = parent.GetComponent <QuarterPipeData>();
                    }
                }

                // If this ramp has coping
                if (data && data.m_rampData.Count > 0)
                {
                    // Default to the first coping
                    BGCcMath closestLip  = data.m_rampData[0];
                    float    closestDist = Vector3.Distance(transform.position, data.m_rampData[0].CalcPositionByClosestPoint(transform.position));

                    // For all the copings that belong to this ramp
                    foreach (var d in data.m_rampData)
                    {
                        // Find the coping that is nearest to the player
                        float newClosestDist = Vector3.Distance(transform.position, d.CalcPositionByClosestPoint(transform.position));
                        if (newClosestDist < closestDist)
                        {
                            closestLip  = d;
                            closestDist = newClosestDist;
                        }
                    }

                    // Set the current quarter pipe to the on that was found
                    m_currentQuaterPipe = closestLip;

                    // Grab a refference to the player's current velocity
                    Vector3 velocity = m_rb.velocity;

                    float signedAngle = Vector3.SignedAngle(m_moveDir, Vector3.up, transform.up);
                    if (Vector3.Dot(m_moveDir.normalized, Vector3.up) >= 0.85f)
                    {
                        // Rotate to make quarter pipes easier to ride
                        m_targetRotation += signedAngle;
                        velocity          = Vector3.zero;
                        velocity.y        = m_rb.velocity.y;
                        m_rb.velocity     = velocity;
                    }
                    else
                    {
                        // Reduce horizontal velocity
                        velocity.y    = 0;
                        velocity     /= 2;
                        velocity.y    = m_rb.velocity.y;
                        m_rb.velocity = velocity;
                    }

                    // The player is now in the vert mode
                    m_vert = true;
                }
            }
        }
    }
    public void Grind()
    {
        float sphereRad = 2f;

        // Perform a spherecast. If anything the cast touches has a rail, add it to a list of possible rails.
        Collider[] hitColliders = Physics.OverlapSphere(transform.position, sphereRad);
        if (hitColliders.Length > 0)
        {
            // Look through the list of rails and find the spline that is closest to the player.
            List <RailData> rails = new List <RailData>();

            foreach (var c in hitColliders)
            {
                Transform parent = c.transform;
                while (parent != null)
                {
                    RailData railData = parent.GetComponent <RailData>();
                    if (railData)
                    {
                        bool sameRail = false;
                        foreach (var rail in rails)
                        {
                            if (rail == railData)
                            {
                                sameRail = true;
                                break;
                            }
                        }
                        if (!sameRail)
                        {
                            rails.Add(railData);
                        }
                        break;
                    }
                    else
                    {
                        parent = parent.parent;
                    }
                }
            }

            if (rails.Count > 0)
            {
                // Default to the first rail
                BGCcMath closestRail = rails[0].m_railData[0];
                float    closestDist = Vector3.Distance(transform.position, rails[0].m_railData[0].CalcPositionByClosestPoint(transform.position));

                foreach (var rail in rails)
                {
                    foreach (var r in rail.m_railData)
                    {
                        // Find the coping that is nearest to the player
                        float newClosestDist = Vector3.Distance(transform.position, r.CalcPositionByClosestPoint(transform.position));
                        if (newClosestDist < closestDist)
                        {
                            closestRail = r;
                            closestDist = newClosestDist;
                        }
                    }
                }
                if (closestDist <= sphereRad)
                {
                    // If the player is facing away from its movement vector, change to switch. Otherwise, they are in the regular stance
                    float fwdVelDot = Vector3.Dot(transform.forward, m_rb.velocity);
                    if (m_switch && fwdVelDot > 0)
                    {
                        m_switch = false;
                        TrickManager.GetInstance().WriteToStanceTextBox("Regular");
                    }
                    else if (!m_switch && fwdVelDot < 0)
                    {
                        m_switch = true;
                        TrickManager.GetInstance().WriteToStanceTextBox("Switch");
                    }

                    // Find the vector in front of the player or under the player that best suits
                    m_moveDir     = (m_switch) ? -transform.forward : transform.forward;
                    m_currentRail = closestRail;
                    m_grinding    = true;
                }
            }
        }
    }