Пример #1
0
        // Use this for initialization
        void Start()
        {
            if (scaleObject == null)
            {
                _CheckSetting("not seted the halo obejct.", true);
            }

            tm = TurksManager.instance;
            if (tm == null)
            {
                _CheckSetting("not found the turk manager.", true);
            }

            if (showPointObject != null)
            {
                render = showPointObject.GetComponent <Renderer>();
            }

            if (showOrHideObject != null)
            {
                showOrHideObject.SetActive(false);
            }

            if (debugFlag)
            {
                jpSignal       = new JetPoint();
                jpSignal.trans = transform;
                jpSignal.size  = 0.1f;
            }
        }
Пример #2
0
        // Update is called once per frame
        void Update()
        {
            // Polling a new signal.
            if ((loadingSignal == null) && (bufferJetSignal.Count > 0))
            {
                loadingSignal = _LoadSignal();
                if ((loadingSignal != null) && (loadingSignal.GetSignal != null))
                {
                    JetPoint signal = loadingSignal.GetSignal;
                    _AdjectValve(signal.type, signal.force, signal.interval);
                }
            }

            if ((loadingSignal != null) && loadingSignal.flagHited)
            {
                // Change particle material.
                if ((particle != null) && (matHit != null))
                {
                    particle.GetComponent <ParticleSystemRenderer>().material = matHit;
                }
            }
            else
            {
                // Change the particle matierial.
                if ((particle != null) && (matUnhit != null))
                {
                    particle.GetComponent <ParticleSystemRenderer>().material = matUnhit;
                }
            }
        }
Пример #3
0
        void _ShowTheHitedPoint(bool _flagHit, Vector3 pos, Vector3 direction, float enableTime)
        {
            // Firstly, set the jet point.
            if (jetPoint == null)
            {
                // Get the quaternion from direction.
                Quaternion quaternion = Quaternion.identity;
                if (direction != Vector3.zero)
                {
                    quaternion = Quaternion.LookRotation(direction);
                }

                // Instance a jet point.
                GameObject objHiter = Instantiate(objectHiter, pos, quaternion, transform);
                jetPoint = new JetPoint(true, enableTime, jettingForce, forceInterval, jettingSize, forceType, objHiter.transform);

                // Setting jet prepoping
                if (jPrepoping != null)
                {
                    jPrepoping.jPoints.listPoint.Add(jetPoint);
                    jPrepoping.PrePoping();
                    //Debug.Log("pre poping");
                }
            }
            else
            {
                // Refresh the jet point.
                jetPoint.Refresh(_flagHit, enableTime, pos);
            }
        }
Пример #4
0
        public void Forcast()
        {
            JetPoint point = new JetPoint(true,
                                          Time.time + shootAI.GetRemainTime,
                                          force,
                                          forceInterval,
                                          forceAreaSize,
                                          forceType,
                                          shootAI._ballTarget);

            JetPrePoping prepoing = jprcontroller.GetPrePop();

            prepoing.jPoints.listPoint.Add(point);
            prepoing.PrePoping();
        }
Пример #5
0
        public void SetSignal(JetPoint jp)
        {
            //Debug.Log("set signal: " + jp);
            if (jp != null)
            {
                this.jpSignal = jp;

                // Show the hit point.
                if (showOrHideObject != null)
                {
                    showOrHideObject.SetActive(true);
                }
            }
            else
            {
                // Hide the hit point
                if (showOrHideObject != null)
                {
                    showOrHideObject.SetActive(false);
                }
            }
        }
Пример #6
0
 private int CompareJetPoint(JetPoint x, JetPoint y)
 {
     return(x.enableTime.CompareTo(y.enableTime));
 }
Пример #7
0
        IEnumerator _Setting()
        {
            // Stop to update.
            flagSetup = false;

            // Set the reading path.
            string path;

            if (pathRecorderFolder != "")
            {
                path = Application.dataPath + "/" + pathRecorderFolder + "/" + nameAnimation + ".txt";
            }
            else
            {
                path = Application.dataPath + "/" + nameAnimation + ".txt";
            }

            // Read the file.
            string[] listPos = null;
            try
            {
                listPos = File.ReadAllLines(path);
            }
            catch (FileNotFoundException e)
            {
                Debug.Log(e.ToString());
                yield break;
            }

            // Get the rate of recording.
            rateRecord = float.Parse(listPos[0]);
            timeEnd    = (listPos.Length - 1) * rateRecord + timeStart;

            Vector3    start = new Vector3();
            Vector3    end   = new Vector3();
            GameObject hitObject;

            string[] datas;

            // Parse the file.
            for (int i = 1; i < listPos.Length; i++)
            {
                datas = listPos[i].Split(' ');
                if (datas.Length == 6)
                {
                    start.x = float.Parse(datas[0]);
                    start.y = float.Parse(datas[1]);
                    start.z = float.Parse(datas[2]);

                    // Transform the point from local to world.
                    start = transRecorderBase.TransformPoint(start.x, start.y, start.z);

                    end.x = float.Parse(datas[3]);
                    end.y = float.Parse(datas[4]);
                    end.z = float.Parse(datas[5]);

                    // Transform the point from local to world.
                    end = transRecorderBase.TransformPoint(end.x, end.y, end.z);

                    listStartNode.Add(start);
                    listEndNode.Add(end);

                    // Prepare hited objects.
                    hitObject = Instantiate(objectHiter, start, Quaternion.identity, transform);
                    hitObject.SetActive(true);

                    // Set jet point.
                    JetPoint point = new JetPoint((timeStart + timeWaitToPlayAnimation + i * rateRecord), jettingForce, rateRecord, jettingSize, forceType, hitObject.transform);
                    listJetPoint.Add(point);

                    // Show debug line render.
                    if (debugHitedLineRender != null)
                    {
                        LineRenderer lr = Instantiate(debugHitedLineRender, transform).GetComponent <LineRenderer>();
                        if (lr != null)
                        {
                            Debug.Log("show debug hited line render.");
                            lr.positionCount = 2;
                            lr.SetPosition(0, start);
                            lr.SetPosition(1, end);
                        }
                    }
                }
                else
                {
                    _ChecksSetting("The file format does not correct. path: " + path, true);
                }
            }

            // Update hited position.
            _DectectHit();

            // Show the predicted points to jet.
            if (jPrepoping != null)
            {
                jPrepoping.jPoints.listPoint = listJetPoint;
                jPrepoping.PrePoping();
                //Debug.Log("Prepoping jetpoints");
            }

            // Recorve to update.
            flagSetup = true;
        }
Пример #8
0
        // Update is called once per frame
        void Update()
        {
            // Update aiming Canvas position.
            if ((aimingCanvas != null) && (projectorCamera != null))
            {
                Vector3    center = new Vector3(projectorCamera.pixelWidth / 2, projectorCamera.pixelHeight / 2, 0.0f);
                Ray        ray    = projectorCamera.ScreenPointToRay(center);
                RaycastHit hit;

                // Moveing the position.
                if (Physics.Raycast(ray, out hit, aimingDistance, aimingLayer))
                {
                    aimingCanvas.transform.position = hit.point;
                }

                // Looking the projector.
                aimingCanvas.transform.DOLookAt(projectorCamera.transform.position, 0.5f);
            }

            if (listHaloer.Count > 0)
            {
                //Debug.LogFormat("list haloer count: {0}", listHaloer.Count);
                float    zRotate            = 0.0f;
                HitPoint newHitPoint        = null;
                bool     showTheAimingImage = false;

                // Refresh the halo hit.
                for (int i = 0; i < listHaloer.Count; i++)
                {
                    zRotate = GetDirection(transform, listHaloer[i].hitPoint.transform, acceptableAngle, offsetAngle);

                    // In aiming.
                    if (zRotate == -1)
                    {
                        newHitPoint        = listHaloer[i].hitPoint;
                        showTheAimingImage = true;
                        if (listHaloer[i].uiTransform != null)
                        {
                            listHaloer[i].uiTransform.gameObject.SetActive(false);
                        }
                    }
                    // Out of range.
                    else
                    {
                        if (listHaloer[i].uiTransform != null)
                        {
                            listHaloer[i].uiTransform.DOLocalRotate(new Vector3(0, 0, zRotate), rotateDuration);
                            listHaloer[i].uiTransform.gameObject.SetActive(true);
                        }
                    }

                    //Debug.LogFormat("zRotate: {0}, transform: {1}, listHaloer{2}: {3}", zRotate, transform, i, listHaloer[i].hitPoint);
                }

                // Register the hit flag.
                if (newHitPoint != null)
                {
                    // Release the hit flag.
                    if ((lastHitPoint != null) && (lastHitPoint != newHitPoint))
                    {
                        lastHitPoint.flagHited = false;
                    }
                    lastHitPoint = newHitPoint;

                    // Registe the hit flag.
                    lastHitPoint.flagHited = true;
                }

                // Change the aiming image material
                if (lastHitPoint != null)
                {
                    JetPoint target = lastHitPoint.GetJetPoint();
                    if ((lastHitPoint.GetJetPoint() != null) && (target.trans != null))
                    {
                        float distance = Vector3.Distance(transform.transform.position, target.trans.position);
                        //Debug.Log("distance: " + distance);

                        // The projector is in the jeted distance.
                        if ((distance < target.GetJetDistance() + aimingDistanceOffset) && (distance > target.GetJetDistance() - aimingDistanceOffset))
                        {
                            if (aimingImage != null)
                            {
                                aimingImage.DOColor(inJetedDistanceColor, 0.1f);
                                //Debug.Log("in jeted distance.");
                            }
                        }
                        else
                        {
                            // The projector isnot in the jeted distance.
                            if (aimingImage != null)
                            {
                                aimingImage.DOColor(OutOfJetedDistanceColor, 0.1f);
                                //Debug.Log("not in jeted distance.");
                            }
                        }

                        string log = "now distance: " + distance.ToString("0.00") + "\ntarget distance: " + target.GetJetDistance().ToString("0.00");
                        if (debugLog != null)
                        {
                            debugLog.text = log;
                        }
                    }
                }
                else
                {
                } //end changeing the aiming image material.
            }     //end if
        }