示例#1
0
    void Start()
    {
        //VectorLine.SetEndCap ("Arrow4", EndCap.Both, 0, 0, 2.0f, 1.0f, lineTex, frontTex);
        line           = new VectorLine("Line", linePoints, f_LineWidth, LineType.Discrete);
        line2          = new VectorLine("Line2", line2Points, f_LineWidth, LineType.Discrete);
        line.collider  = true;
        line2.collider = true;
        line.Draw3DAuto();
        line2.Draw3DAuto();
        line.rectTransform.gameObject.tag  = "CasualLine";
        line2.rectTransform.gameObject.tag = "CasualLine";
        lineScript                    = line.rectTransform.gameObject.AddComponent <IE_Line>();
        lineScript.f_Time             = f_CasualLineLifeTime;
        lineScript.f_InterpolateSpeed = f_CasualLineDestroySpeed;
        //lineScript.f_ColliderY = f_ColliderY;
        //  lineScript.f_MinColliderX = f_MinColliderX;
        lineScript2                    = line2.rectTransform.gameObject.AddComponent <IE_Line>();
        lineScript2.f_Time             = f_CasualLineLifeTime;
        lineScript2.f_InterpolateSpeed = f_CasualLineDestroySpeed;
        // lineScript2.f_ColliderY = f_ColliderY;
        //  lineScript2.f_MinColliderX = f_MinColliderX;

        linePoints.Add(new Vector3());
        linePoints.Add(new Vector3());
        linePoints.Add(new Vector3());
        linePoints.Add(new Vector3());
        line2Points.Add(new Vector3());
        line2Points.Add(new Vector3());
        line2Points.Add(new Vector3());
        line2Points.Add(new Vector3());
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D c)
    {
        if (c.CompareTag("CasualLine"))
        {
            IE_Line hitLine = c.GetComponent <IE_Line>();

            if (hitLine == null || !hitLine.b_ColliderActive)
            {
                return;
            }

            Vector2 difference = new Vector2(hitLine.points[3].x, hitLine.points[3].y) - new Vector2(hitLine.points[2].x, hitLine.points[2].y);
            v2_CurrentMoveVelocity = difference.normalized * v2_CurrentMoveVelocity.magnitude;

            int directionX = 1;
            if (v2_CurrentMoveVelocity.x < 0)
            {
                directionX = -1;
            }

            int directionY = 1;
            if (v2_CurrentMoveVelocity.y < 0)
            {
                directionY = -1;
            }
            v2_CurrentMoveVelocity += new Vector2(directionX * f_Casual_SpeedBoost, directionY * f_Casual_SpeedBoost);

            IE_GameControl.instance.PVO_CasualLineTaken();
            hitLine.PVO_ImmediateDestroy();
            as_CasualLine.PlayOneShot(ac_CasualLineClip);
            _Health.PVO_IncreaseHealth(f_Casual_HealthIncrease);
        }
        else if (b_BorderCollisionActive && c.CompareTag("RightBorder"))
        {
            if (b_CanReceiveDmg)
            {
                _Health.PVO_BorderHit();
            }
            IE_PostProcessManager.instance.PVO_BorderHit();
            as_BorderHit.PlayOneShot(ac_BorderHitDMG);
            v2_CurrentMoveVelocity  = Vector2.Reflect(v2_CurrentMoveVelocity, Vector2.right);
            v2_CurrentMoveVelocity *= f_Border_SpeedBoost;
        }

        else if (b_BorderCollisionActive && c.CompareTag("LeftBorder"))
        {
            if (b_CanReceiveDmg)
            {
                _Health.PVO_BorderHit();
            }
            IE_PostProcessManager.instance.PVO_BorderHit();
            as_BorderHit.PlayOneShot(ac_BorderHitDMG);
            v2_CurrentMoveVelocity  = Vector2.Reflect(v2_CurrentMoveVelocity, -Vector2.right);
            v2_CurrentMoveVelocity *= f_Border_SpeedBoost;
        }

        else if (b_BorderCollisionActive && c.CompareTag("UpBorder"))
        {
            if (b_CanReceiveDmg)
            {
                _Health.PVO_BorderHit();
            }
            IE_PostProcessManager.instance.PVO_BorderHit();
            as_BorderHit.PlayOneShot(ac_BorderHitDMG);
            v2_CurrentMoveVelocity  = Vector2.Reflect(v2_CurrentMoveVelocity, Vector2.up);
            v2_CurrentMoveVelocity *= f_Border_SpeedBoost;
        }

        else if (b_BorderCollisionActive && c.CompareTag("DownBorder"))
        {
            if (b_CanReceiveDmg)
            {
                _Health.PVO_BorderHit();
            }
            IE_PostProcessManager.instance.PVO_BorderHit();
            as_BorderHit.PlayOneShot(ac_BorderHitDMG);
            v2_CurrentMoveVelocity  = Vector2.Reflect(v2_CurrentMoveVelocity, -Vector2.up);
            v2_CurrentMoveVelocity *= f_Border_SpeedBoost;
        }

        else if (c.CompareTag("RandomDirection"))
        {
            as_BorderHit.PlayOneShot(ac_RandomDirHit);
            IE_PostProcessManager.instance.PVO_RandomHit();
            int randX = Random.Range(0.0f, 1.0f) > 0.5f ? 1 : -1;
            int randY = Random.Range(0.0f, 1.0f) > 0.5f ? 1 : -1;
            v2_CurrentMoveVelocity = new Vector2(randX * v2_InitialRandomVelocity.x, randY * v2_InitialRandomVelocity.y);
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
        else if (c.CompareTag("BlueObstacle"))
        {
            as_BorderHit.PlayOneShot(ac_BlueHit);
            IE_PostProcessManager.instance.PVO_BlueHit();
            _Health.PVO_IncreaseHealth(f_BlueObstacleHealth);
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
        else if (c.CompareTag("RedObstacle"))
        {
            as_BorderHit.PlayOneShot(ac_RedHit);
            IE_PostProcessManager.instance.PVO_RedHit();
            _Health.PVO_DmgExternal(f_RedObstacleDamage);
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
        else if (c.CompareTag("ShieldObstacle"))
        {
            IE_GameControl.instance.PVO_ShieldActivation(true);
            as_BorderHit.PlayOneShot(ac_ShieldHit);
            IE_PostProcessManager.instance.PVO_ShieldHit();
            if (co_ShieldTimer != null)
            {
                StopCoroutine(co_ShieldTimer);
            }

            co_ShieldTimer = StartCoroutine(CO_ShieldTimer());
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
        else if (c.CompareTag("ExtraLifeObstacle"))
        {
            IE_GameControl.instance.PVO_ExtraLifeAdded(1);
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
        else if (c.CompareTag("ExtraLife2Obstacle"))
        {
            IE_GameControl.instance.PVO_ExtraLifeAdded(2);
            c.GetComponent <IE_MultipleArrow>().PVO_Hit();
        }
    }
示例#3
0
    void Update()
    {
        if (!b_Drawn)
        {
            if (b_CanDrawNewLine && Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
            {
                b_CanUpdateLine  = true;
                b_CanDrawNewLine = false;
                i_LineCounter++;

                if (i_LineCounter == 3)
                {
                    i_LineCounter = 1;
                }

                if (i_LineCounter == 1)
                {
                    usedLine       = line;
                    usedLinePoints = linePoints;
                    usedLineScript = lineScript;

                    if (usedLineScript.co_Count != null)
                    {
                        usedLineScript.StopCoroutine(usedLineScript.co_Count);
                    }
                    if (usedLineScript.co_Destroy != null)
                    {
                        usedLineScript.StopCoroutine(usedLineScript.co_Destroy);
                    }

                    linePoints.Clear();
                    linePoints.Add(new Vector3());
                    linePoints.Add(new Vector3());
                    linePoints.Add(new Vector3());
                    linePoints.Add(new Vector3());
                }
                else
                {
                    usedLine       = line2;
                    usedLinePoints = line2Points;
                    usedLineScript = lineScript2;

                    if (usedLineScript.co_Count != null)
                    {
                        usedLineScript.StopCoroutine(usedLineScript.co_Count);
                    }
                    if (usedLineScript.co_Destroy != null)
                    {
                        usedLineScript.StopCoroutine(usedLineScript.co_Destroy);
                    }

                    line2Points.Clear();
                    line2Points.Add(new Vector3());
                    line2Points.Add(new Vector3());
                    line2Points.Add(new Vector3());
                    line2Points.Add(new Vector3());
                }
                usedLineScript.b_ColliderActive = false;

                //line.endCap = "Arrow4";

                // MAY CHANGE ACCORDING TO THE LINE TYPE
                usedLine.material = mat_Uncompleted;

                Vector3 mousePos = Input.mousePosition;
                mousePos.z        = 20;
                mousePos          = Camera.main.ScreenToWorldPoint(mousePos);
                startPosition     = mousePos;
                usedLinePoints[0] = mousePos;
            }
            else if (b_CanUpdateLine && Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved && Time.time > f_LastSet + f_SetPositionRate)
            {
                f_LastSet = Time.time;
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = 20;
                mousePos   = Camera.main.ScreenToWorldPoint(mousePos);


                if ((mousePos - startPosition).magnitude < f_MaxLineMagnitude)
                {
                    usedLinePoints[1] = mousePos;
                }
                else
                {
                    usedLinePoints[1] = startPosition + (mousePos - startPosition).normalized * f_MaxLineMagnitude;
                }

                float currentMag = (usedLinePoints[1] - startPosition).magnitude;
                usedLinePoints[2] = (usedLinePoints[0] + usedLinePoints[1]) / 2;
                Vector3 cross = Vector3.Cross(usedLinePoints[0], usedLinePoints[1]).normalized *currentMag *f_MidArrowLength;
                float   dot   = Vector3.Dot(cross, t_Ball.position - usedLinePoints[2]);

                if (dot > 0)
                {
                    cross *= -1;
                }

                usedLinePoints[3] = usedLinePoints[2] - cross;


                usedLine.Draw3D();
            }
            else if (Input.touchCount > 0 && (Input.GetTouch(0).phase == TouchPhase.Canceled || Input.GetTouch(0).phase == TouchPhase.Ended))
            {
                b_CanUpdateLine = false;
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = 20;
                mousePos   = Camera.main.ScreenToWorldPoint(mousePos);


                // WILL CHANGE ACCORDING TO THE LINE TYPE
                usedLineScript.myLine = usedLine;
                usedLineScript.points = usedLinePoints.ToArray();
                usedLineScript.b_DestroyHasStarted = false;
                if (usedLineScript.co_Count != null)
                {
                    usedLineScript.StopCoroutine(usedLineScript.co_Count);
                }
                usedLine.material = mat_Completed;
                usedLine.rectTransform.gameObject.tag = s_CasualLineTag;
                //lineScript.PVO_AddCollider(_ColliderPooler);
                usedLineScript.PVO_INIT();

                if (i_InitialDrawCount < 2)
                {
                    i_InitialDrawCount++;
                }
                usedLineScript.b_ColliderActive = true;

                b_CanDrawNewLine = true;
                b_Drawn          = true;
                f_Timer          = 0.0f;
            }
        }
        else
        {
            f_Timer += Time.deltaTime;
            if (f_Timer > f_DrawRate)
            {
                b_Drawn = false;
            }
        }
    }