Пример #1
0
    public static bool UpdateLine(char objType, int i, int j, int k)
    {
        GameObject drawnLine = null;

        if (objType == 'X')
        {
            drawnLine = MainGameScript.Grid_LinesX[i, j, k];
        }
        else if (objType == 'Y')
        {
            drawnLine = MainGameScript.Grid_LinesY[i, j, k];
        }
        else if (objType == 'Z')
        {
            drawnLine = MainGameScript.Grid_LinesZ[i, j, k];
        }

        if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
        {
            LineScript.Draw(objType, i, j, k);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #2
0
    void Start()
    {
        spriteRenderer = gameObject.GetComponent <SpriteRenderer>();

        Line       = GameObject.Find("LineHolder");
        lineScript = Line.GetComponent <LineScript>();

        squares      = GameObject.Find("Squares");
        squareScript = squares.GetComponent <Game>();

        circle     = Resources.Load <Sprite>("Sprites/Circle2");
        deadCircle = Resources.Load <Sprite>("Sprites/Deadcircle");

        setColor = lineScript.setColor;

        if (loadColors)
        {
            colorNum = Manager.circleList[num];

            lineScript.AddToCircleList(num, colorNum);

            spriteRenderer.color = setColor[colorNum];

            Color color = spriteRenderer.color;
            color.a = 0.5f;
            spriteRenderer.color = color;
        }

        else
        {
            NewColor();
        }

        SetSprite();
    }
Пример #3
0
    private float timeLastTurnEnded;                                           //what time did the last turn end?

    // Use this for initialization
    void Start()
    {
        //get the GameRules and the LineScript
        gameRules = gameObject.GetComponent <GameRulesScript> ();
        line      = gameObject.GetComponent <LineScript> ();

        //link the scripts
        ballScriptR1 = ballR1.GetComponent <BallScript> ();
        ballScriptR2 = ballR2.GetComponent <BallScript> ();
        ballScriptB1 = ballB1.GetComponent <BallScript> ();
        ballScriptB2 = ballB2.GetComponent <BallScript> ();

        //set default values for LastRed and LastBlue ball
        gameRules.LastRedBall  = ballR1;
        gameRules.LastBlueBall = ballB1;

        //get a starting position for the mouse cursor
        Vector3 posInScreen = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);

        posInWorld = Camera.main.ScreenToWorldPoint(posInScreen);

        //set up some other things
        ballsMoving = false;
        hitBuilding = true;
    }
Пример #4
0
    static public void Redo(GameObject _gO)
    {
        m_undoPos++;
        UndoItem uItem = m_undoObjects[m_undoPos - 1];

        _gO = uItem.GetObj();

        if (_gO.GetComponent <Rigidbody>() == null)
        {
            if (_gO.activeSelf)
            {
                _gO.SetActive(false);
            }
            else
            {
                _gO.SetActive(true);
            }

            return;
        }

        Vector2 temp = _gO.transform.position;

        _gO.transform.SetPositionAndRotation(new Vector3(uItem.GetPos().x, uItem.GetPos().y, 0), Quaternion.identity);
        uItem.SetPos(temp);

        if (_gO.layer == LayerMask.NameToLayer("Path"))
        {
            LineScript.ModifyLine(_gO);
        }
    }
Пример #5
0
    private IEnumerator DragObject()
    {
        while (Input.GetMouseButton(0))
        {
            // Position on the near clipping plane of the camera in world space
            Vector3 newMousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));

            // Position relative to the eye-point of the camera
            newMousePos -= Camera.main.transform.position;

            if (Input.GetKey(KeyCode.LeftShift) && m_object.layer != LayerMask.NameToLayer("Path"))
            {
                float cellWidth  = m_grid.transform.GetComponent <SpriteRenderer>().bounds.size.x / 20.2f;
                float cellHeight = m_grid.transform.GetComponent <SpriteRenderer>().bounds.size.y / 20.2f;

                float newX = Mathf.Round((Mathf.Abs(m_grid.GetComponent <SpriteRenderer>().bounds.min.x) + newMousePos.x) / cellWidth);
                newX = m_grid.GetComponent <SpriteRenderer>().bounds.min.x + 0.05f + (newX * cellWidth);
                float newY = Mathf.Round((Mathf.Abs(m_grid.GetComponent <SpriteRenderer>().bounds.min.y) + newMousePos.y) / cellHeight);
                newY = m_grid.GetComponent <SpriteRenderer>().bounds.min.y + (newY * cellHeight);

                m_object.transform.position = new Vector3(newX, newY, 0);
                m_curMousePos = new Vector2(newX, newY);
            }
            else
            {
                if (m_object.name == "Arrow Collider")
                {
                    m_object = LineScript.GetCurrentLine().GetComponentsInChildren <SphereCollider>()[0].gameObject;
                }
                else if (m_object.name == "Line")
                {
                    m_object = LineScript.GetCurrentLine();
                }

                float diffX = m_lastMouse.x - m_curMousePos.x;
                float diffY = m_lastMouse.y - m_curMousePos.y;
                Debug.Log(diffX + "\n" + diffY);
                //Vector3 oldPos = m_object.transform.position;
                //m_object.transform.position = new Vector3(m_curMousePos.x, m_curMousePos.y, 0);
                m_object.transform.SetPositionAndRotation(new Vector3(m_object.transform.position.x - diffX, m_object.transform.position.y - diffY, m_object.transform.position.z), Quaternion.identity);
                //Transform g = GameObject.Find("Guard L").transform;
                //float xAdded = oldPos.x - m_object.transform.position.x;
                //g.SetPositionAndRotation(new Vector3(g.position.x - xAdded, g.position.y - (oldPos.y - m_object.transform.position.y)), Quaternion.identity);
                m_curMousePos = newMousePos;

                if (m_object.layer == LayerMask.NameToLayer("Path"))
                {
                    LineScript.ModifyLine(m_object);
                }
                else
                {
                    LineScript.SetCurrentLine(null);
                }
            }

            yield return(0);
        }

        m_object = null;
    }
Пример #6
0
    private void DeleteObject()
    {
        GameObject curLine = LineScript.GetCurrentLine();

        curLine.SetActive(false);

        UndoScript.AddToUndo(curLine);
    }
Пример #7
0
 public void BringUpMenu(LineScript _ls)
 {
     lineScript = _ls;
     if (isUp)
         StartCoroutine (MenuClose());
     else
         StartCoroutine (MenuOpen());
 }
Пример #8
0
 public void ReadLine(LineScript ls)
 {
     if (ls)
     {
         if (reader != null)
         {
             StopCoroutine(reader);
         }
         reader = StartCoroutine(read(ls));
     }
 }
Пример #9
0
    public void refresh()
    {
        hook                = GameManager.instance.hook;
        player              = GameManager.instance.player;
        lineLengthBar       = UIGameManager.instance.lineLengthBar.GetComponent <Slider>();
        lineLengthBar.value = lineLengthBar.maxValue / 2;
        FishData fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id);

        UIGameManager.instance.lineLengthBar.gameObject.SetActive(true);
        fillBarSpeed   = ((lineLengthBar.maxValue / 10) * fillBarSpeedModifier) * fishData.fillBarModifier;
        unfillBarSpeed = ((lineLengthBar.maxValue / 10) * unfillBarSpeedModifier) * fishData.unfillBarModifier;
    }
Пример #10
0
        // Use this for initialization
        void Start()
        {
            timer = 0f;

            EventManager.StartListening("ENEMY_STUNNED", OnStun);
            EventManager.StartListening("ENEMY_UNSTUNNED", EndStun);

            EventManager.StartListening("SILENT_ACTIVATED", KeepThemSecrets);
            EventManager.StartListening("SILENT_DEACTIVATED", StartTalking);

            GameStatusScript = GameObject.Find("GameStatus").GetComponent <GameStatusScript>();
            lineScript       = GameObject.Find("PlayerSoundWave").GetComponent <LineScript>();
        }
Пример #11
0
    private void OnTriggerEnter(Collider other)
    {
        if (isErasing)
        {
            if (other.gameObject.tag == "Line")
            {
                LineScript line = other.GetComponent <LineScript>();
                DataLogger.Instance.LogActionData(this, line.OriginalOwner, line.photonView.Owner, "Line erased", line.ID);

                PhotonNetwork.Destroy(other.gameObject);

                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.3f);
            }
        }
    }
Пример #12
0
    public void Draw(Vector3 drawPosition)
    {
        if (TraceLines.Keys.Count == 0)
        {
            LineScript line = new LineScript(TraceLineSettings);
            TraceLines.Add(lineIndex, line);
            line.AddNewLineRenderer(this.transform, drawPosition, anchor);
        }
        else
        {
            //DebugManager.Instance.LogInfo($"{drawPosition}");
            TraceLines[0].AddPoint(drawPosition);
        }

        OnDraw?.Invoke();
    }
Пример #13
0
 public void BringUpMenu(LineScript _ls)
 {
     lineScript = _ls;
     if (isUp)
     {
     //			lineScript.gameObject.GetComponent<Collider> ().enabled = true;
     //			lineScript.enabled = true;
         StartCoroutine (MenuClose());
     }
     else
     {
     //			lineScript.enabled = false;
     //			lineScript.gameObject.GetComponent<Collider> ().enabled = false;
         StartCoroutine (MenuOpen());
     }
 }
Пример #14
0
    static public void AddToUndo(GameObject _gO, Vector2 _mousePos)
    {
        for (int i = 0; i < m_undoObjects.Count - m_undoPos; i++)
        {
            GameObject gO = m_undoObjects[m_undoObjects.Count - 1].GetObj();
            if (gO.layer == LayerMask.NameToLayer("Path"))
            {
                LineScript.AddToPathPool(gO);
            }
            m_undoObjects.RemoveAt(m_undoObjects.Count - 1);
        }

        m_undoPos++;
        UndoItem uItem = new UndoItem(_gO, _gO.transform.position);

        m_undoObjects.Add(uItem);
    }
Пример #15
0
    //public bool DeleteTie(NailScript connectedTo)
    //{
    //    LineScript temp = null;

    //    if (extremeOfLine == LineScript.Extremes.B)
    //        temp = tiedLine.Find(x => x.pointA == connectedTo);
    //    else if (extremeOfLine == LineScript.Extremes.A)
    //        temp = tiedLine.Find(x => x.pointB == connectedTo);

    //    if (temp != null)
    //    {
    //        if (thisNailRole == Role.Father)
    //        {
    //            FamilyManager.instance.RemoveOffspringFromID(connectedTo.parentWindow.assignedMemberID, this.parentWindow.assignedMemberID);
    //        }
    //        else if (thisNailRole == Role.Mother)
    //        {
    //            FamilyManager.instance.RemoveOffspringFromID(connectedTo.parentWindow.assignedMemberID, this.parentWindow.assignedMemberID);
    //        }
    //        else if (thisNailRole == Role.Offspring)
    //        {
    //            if (this.parentWindow.assignedMember.sex == Gender.Female)
    //            {
    //                connectedTo.parentWindow.assignedMember.motherID = -1;
    //            }
    //            else
    //            {
    //                connectedTo.parentWindow.assignedMember.fatherID = -1;
    //            }
    //        }

    //        if (tiedLine.Contains(temp))
    //            tiedLine.Remove(temp);
    //        temp.DeleteLine();
    //        return true;
    //    }
    //    else
    //    {
    //        return false;
    //    }
    //}

    public void DeleteConnection(int toID, LineScript andLine)
    {
        tiedLine.Remove(andLine);

        if (thisNailRole == Role.Father)
        {
            FamilyManager.instance.RemoveFatherFromID(parentWindow.assignedMemberID);
        }
        else if (thisNailRole == Role.Mother)
        {
            FamilyManager.instance.RemoveMotherFromID(parentWindow.assignedMemberID);
        }
        else if (thisNailRole == Role.Offspring)
        {
            FamilyManager.instance.RemoveOffspringFromID(parentWindow.assignedMemberID, toID);
        }
    }
Пример #16
0
    public override void HandleOnCollisionEnter2D(Collision2D other)
    {
        Ball       otherBall = other.gameObject.GetComponent <Ball>();
        LineScript line      = other.gameObject.GetComponent <LineScript>();

        AudioSource = GameObject.Find("VirusNormal");
        source      = AudioSource.GetComponent <AudioSource>();
        if (otherBall != null)
        {
            bool isCureBallHit = otherBall.ballType == BallType.CURE;
            if (isCureBallHit && !ball.isOriginalVirus)
            {
                TransformsToNormalBall();
                source.Play();
            }
        }
    }
Пример #17
0
    // Update is called once per frame
    public void InitiateCut(LineScript lineScript)                      // Called From LineScript on LineComplete
    {
        if (!cutComplete)                                               // Checking if Already cut in this session
        {
            Transform cutplane;
            Vector3   pointA, pointB, pointC;
            Plane     myplane;

            pointA  = lineScript.lineRenderer.GetPosition(0);
            pointB  = lineScript.lineRenderer.GetPosition(1);
            pointC  = pointA + (Camera.main.transform.forward * -10);   // Third point to get plane from line drawn
            myplane = new Plane(pointA, pointB, pointC);                // Creating plane from lin points plus 3rd point

            Vector3 dir   = (pointB - pointA).normalized;
            Vector3 point = pointA + (0.5f * dir);

            cutComplete = MeshCut.Cut(gameObject, point, myplane.normal);   // Calling MeshCut , will return true if line/plane intersects mesh
        }
    }
Пример #18
0
 public void SetTiedLine(LineScript to, NailScript otherExtreme)
 {
     if (otherExtreme != null)
     {
         UpdateConnection(to, otherExtreme);
     }
     //else
     //{
     //    switch(thisNailRole)
     //    {
     //        case Role.Father:
     //            parentWindow.assignedMember.fatherID = -1;
     //            break;
     //        case Role.Mother:
     //            parentWindow.assignedMember.motherID = -1;
     //            break;
     //    }
     //}
 }
Пример #19
0
    private void LogAnnotationData(string timestamp)
    {
        if (isLogging && annotationsStreamWriter != null)
        {
            foreach (GameObject line in GameObject.FindGameObjectsWithTag("Line"))
            {
                LineScript lineScript = line.GetComponent <LineScript>();
                Chart      parent     = line.GetComponentInParent <Chart>();

                annotationsStreamWriter.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}",
                                                  timestamp,
                                                  photonToParticipantDictionary[lineScript.OriginalOwner.ActorNumber],
                                                  photonToParticipantDictionary[lineScript.photonView.OwnerActorNr],
                                                  lineScript.GetLinePositions(),
                                                  (parent != null) ? parent.ID : ""
                                                  );
            }
        }
    }
Пример #20
0
    static public void AddToUndo(GameObject _gO)
    {
        int numOverUndo = m_undoObjects.Count - m_undoPos;

        for (int i = 0; i < numOverUndo; i++)
        {
            GameObject gO = m_undoObjects[m_undoObjects.Count - 1].GetObj();
            if (gO.layer == LayerMask.NameToLayer("Path"))
            {
                LineScript.AddToPathPool(gO);
            }
            m_undoObjects.RemoveAt(m_undoObjects.Count - 1);
        }

        m_undoPos++;
        UndoItem uItem = new UndoItem(_gO);

        m_undoObjects.Add(uItem);
    }
Пример #21
0
    // Use this for initialization
    void Start()
    {
        UIGameManager.instance.mainCameraLocation = transform;
        hook   = GameManager.instance.hook;
        player = GameManager.instance.player;
        GameManager.instance.fish = this;
        myRigidbody  = GetComponent <Rigidbody2D>();
        lineRenderer = hook.GetComponent <LineRenderer>();
        if (GameManager.instance.fishDetect.gameObject.activeSelf)
        {
            GameManager.instance.fishDetect.gameObject.SetActive(false);
        }

        fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id);
        patterns = fishData.patterns;

        //==== Random Pattern =====
        moveForce              = fishData.moveForce;                                             //based on the fish
        maxSpeed               = fishData.maxSpeed;                                              //based on the fish
        timeBetweenMove        = fishData.timeBetweenMove;                                       //based on the fish
        timeToMove             = fishData.timeToMove;                                            //based on the fish
        decelerateSpeed        = fishData.decelerateSpeed;                                       //based on the fish
        timeBetweenMoveCounter = Random.Range(timeBetweenMove * 0.75f, timeBetweenMove * 1.25f); //Randomizes a bit of the timer that the fish stops to move again
        timeToMoveCounter      = Random.Range(timeToMove * 0.75f, timeBetweenMove * 1.25f);      //Randomizes a bit of the timer that the fish keep moving

        //==== Circle Pattern =====
        angle       = 0;
        radius      = fishData.radius;
        circleSpeed = fishData.circleSpeed;

        //==== Square Pattern =====
        acceleration       = 2.5f;
        deceleration       = 5f;
        squarePatternReady = false;
        speed = 2f;

        //==== Overall =====
        waypointAux = false;
        InvokeRepeating("changePattern", 3F, 3F);
        changePattern();
        currentDrag = 0;
        color       = new Color32(255, 255, 255, 255);
    }
Пример #22
0
    // Use this for initialization
    void Start()
    {
        //get the car script component
        car = GetComponent <CarScript>();

        //get line script component
        line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>();

        //get the max velocity of the car
        maxCarVel = car.GetMaxVelocity();

        //get the steering(acceleration) scale of the car
        steeringValue = car.GetSteeringScale();

        //find the input and text objects in the scene and set them as variables here
        carPositionInputField  = GameObject.FindGameObjectWithTag("FuzzyCarPositionInputField");
        linePositionInputField = GameObject.FindGameObjectWithTag("FuzzyLinePositionInputField");
        velocityInputField     = GameObject.FindGameObjectWithTag("FuzzyVelocityInputField");
        steeringText           = GameObject.FindGameObjectWithTag("FuzzySteeringText").GetComponent <Text>();
    }
Пример #23
0
    private IEnumerator read(LineScript ls)
    {
        canvas.enabled   = true;
        movement.enabled = false;
        float waittime = (ls.time == 0f)?2f:ls.time;

        bubble.text = ls.line;

        if (ls.clip)
        {
            waittime   = ls.clip.length;
            audio.clip = ls.clip;
            audio.Play();
        }
        yield return(new WaitForSeconds(waittime));

        canvas.enabled   = false;
        reader           = null;
        movement.enabled = true;
    }
Пример #24
0
    public bool DeleteTie(LineScript temp)
    {
        //NailScript connectedTo = null;

        //if (extremeOfLine == LineScript.Extremes.B)
        //    connectedTo = temp.pointA;
        //else if (extremeOfLine == LineScript.Extremes.A)
        //    connectedTo = temp.pointB;

        if (temp != null)
        {
            //tiedLine.Remove(temp);
            temp.DeleteLine();
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #25
0
    private void Populate()
    {
        objectPool = new List <Element>();
        linePool   = new List <LineScript>();

        foreach (ElementData ed in GameHandler.dataHandler.GetElementData(currentExpression))
        {
            GameObject go = Instantiate(GameHandler.objectHandler.elements[(int)ed.type], panels);
            go.transform.localPosition = new Vector3(ed.positionX, ed.positionY, 0.0f);
            Element e = go.GetComponentInChildren <Element>();
            e.SetData(objectPool.Count, this);

            ReLabel(e);

            objectPool.Add(e);
        }

        int currentElement = 0;

        foreach (ElementData ed in GameHandler.dataHandler.GetElementData(currentExpression))
        {
            for (int i = 0; i < ed.inputs.Length; i++)
            {
                if (ed.inputs[i] != null)
                {
                    // Add line

                    // TODO - Make special line for bools

                    GameObject go = Instantiate(GameHandler.objectHandler.line, lines);

                    LineScript ls = go.GetComponent <LineScript>();
                    ls.SetConnect1(objectPool[currentElement].GetHandels()[i]);
                    ls.SetConnect2(objectPool[GameHandler.dataHandler.GetElementInputDestinationIndex(currentExpression, currentElement, i)].GetHandleOut());
                    ls.SetPlaced(false);
                }
            }

            currentElement++;
        }
    }
Пример #26
0
 /// <summary>
 /// 라인을 클릭했을 시 라인이 가지고 있던 유닛이 해당 라인에 소환이 됨
 /// </summary>
 /// <param name="line">전투가 벌어지는 라인</param>
 public void SpawnUnit(LineScript line)
 {
     Debug.Log("Spawn");
     newUnit.transform.SetParent(lineList[line.lineNumber].transform);
     if (playerNumber == 1)
     {
         newUnit.transform.localPosition = new Vector3(-650, -162.5f, 0);
     }
     else if (playerNumber == 2)
     {
         newUnit.transform.localPosition = new Vector3(650, -162.5f, 0);
     }
     unitSpawnButtonList[(int)newUnit.GetComponent <Unit>().getUnitType()].SettingData();
     if (checkClocking)
     {
         clockingButton.SettingData();
     }
     newUnit.SetActive(true);
     checkSpawnDoing = false;
     checkClocking   = false;
 }
Пример #27
0
    public void PinInteraction(NailScript pin)
    {
        if (!UI_Manager.editingInformation)
        {
            //if (currentInteraction == interactionMode.Tying)
            //{
            if (currentStatus == pinInteractionStatus.None)
            {
                currentStatus = pinInteractionStatus.Dragging;
                currentLine   = Instantiate(lineObject, this.transform).GetComponent <LineScript>();

                currentLine.SetA(pin);

                currentLine.SetReady();

                cancelButton.gameObject.SetActive(true);
            }
            else if (currentStatus == pinInteractionStatus.Dragging)
            {
                if (pin.CompatibleWithOtherExtreme(currentLine.pointA))
                {
                    currentStatus = pinInteractionStatus.None;

                    if (currentLine != null)
                    {
                        currentLine.SetB(pin);
                    }

                    cancelButton.gameObject.SetActive(false);
                }
            }
            //}
            //else
            //{
            //    pin.DeleteAllTies();
            //}
        }

        FamilyManager.instance.formulary.CloseFormulary();
    }
Пример #28
0
    // Use this for initialization
    void Start()
    {
        //get the car script component from the car
        car = GetComponent <CarScript>();

        //get the line script component from the line
        line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>();

        //get max velocity from the car script
        maxCarVel = car.GetMaxVelocity();

        //get the steering scale(acceleration) from the car script
        steeringValue = car.GetSteeringScale();

        //find the input field and text objects that we want to change in the scene and set the mas variables
        carPositionInputField  = GameObject.FindGameObjectWithTag("RuleBasedCarPositionInputField");
        linePositionInputField = GameObject.FindGameObjectWithTag("RuleBasedLinePositionInputField");
        velocityInputField     = GameObject.FindGameObjectWithTag("RuleBasedVelocityInputField");
        steeringText           = GameObject.FindGameObjectWithTag("RuleBasedSteeringText").GetComponent <Text>();

        //set specific values for the rules to use
        //distance variable
        FarLeftDist  = -1.5f;
        LeftDist     = -0.025f;
        RightDist    = 0.025f;
        FarRightDist = 1.5f;

        //velocity variable
        FastLeftVel  = -0.75f * maxCarVel;
        LeftVel      = -0.25f * maxCarVel;
        RightVel     = 0.25f * maxCarVel;
        FastRightVel = 0.75f * maxCarVel;

        //steering output variables
        SteerHardLeft  = -0.75f * steeringValue;
        SteerLeft      = -0.5f * steeringValue;
        SteerRight     = 0.5f * steeringValue;
        SteerHardRight = 0.75f * steeringValue;
    }
Пример #29
0
    public void Enter()
    {
        if (otherHandle.Count > 0 && (handleType == HandleType.In || handleType == HandleType.BoolIn))
        {
        }
        else
        {
            RectTransform trans = null;
            if (handleType == HandleType.BoolIn || handleType == HandleType.BoolOut)
            {
                trans = Instantiate(GameHandler.objectHandler.line, element.GetCallBack().lines).GetComponent <RectTransform>();
            }
            else
            {
                trans = Instantiate(GameHandler.objectHandler.line, element.GetCallBack().lines).GetComponent <RectTransform>();
            }
            trans.transform.position = transform.position;

            LineScript ls = trans.gameObject.GetComponent <LineScript>();
            element.GetCallBack().currentDrawingLine = ls;

            ls.SetConnect1(this);
        }
    }
Пример #30
0
    public void addRewardLoad()
    {
        LineScript load = lAllLine[checkpointline];

        NewGame(load._blockHealth, load._saveScore, load._maxAmmo, load._crystalsForGame);
    }
Пример #31
0
    void NewWave()
    {
        startPos.SetActive(true);
        startPosMain.transform.position = startPosNext.transform.position;
        startPosNext.SetActive(false);

        _first = true;

        GameObject newLine = RandomizeLine();
        LineScript script  = newLine.GetComponent <LineScript>();
        LineScript copy    = script;

        copy._blockHealth     = _blockHealth;
        copy._crystalsForGame = _crystalsForGame;
        copy._maxAmmo         = _maxAmmo;
        copy._saveScore       = _score;
        lAllLine.Add(copy);
        GameObject obj;

        for (int i = 0; i < 7; i++)
        {
            Vector3 pos = Camera.main.ScreenToWorldPoint(_firstSpawnPosition);
            int     id  = script.blocksId[i];
            if (id != 0)
            {
                obj = Instantiate(blocksPrefabs[id], canvas.transform);
            }
            else
            {
                obj = null;
            }
            if (obj != null)
            {
                if (obj.GetComponent <BlockScript>() != null)
                {
                    BlockScript blockScript = obj.GetComponent <BlockScript>();
                    blockScript.setParram(_blockHealth, pos, _blockId, this, blockSizeX);
                    blockScript.step = blockSizeX;
                    blockScript.movePosition();
                    blockScript.SetSize(blockSizeX);
                    lBlock.Add(blockScript);
                    _blockId++;
                }
                else
                {
                    BonusScript bonusScript = obj.GetComponent <BonusScript>();
                    bonusScript.setParram(this, _bonusId, pos, blockSizeX);
                    bonusScript.step = blockSizeX;
                    bonusScript.movePosition();
                    bonusScript.SetSize(blockSizeX);
                    lBonus.Add(bonusScript);
                    _bonusId++;
                }
            }

            _firstSpawnPosition.x += blockSizeX;


            //blockScript[i].setParram(_blockHealth, _blockId, this);
            //blockScript[i].step = blockSizeX;
            //blockScript[i].movePosition();
            //blockScript[i].SetSize(blockSizeX);
            //lBlock.Add(blockScript[i]);
            //_blockId++;
        }
        //for(int i = 0; i < bonusScript.Length; i++)
        //{
        //    bonusScript[i].setParram(this,_bonusId);
        //    bonusScript[i].step = blockSizeX;
        //    bonusScript[i].movePosition();
        //    bonusScript[i].SetSize(blockSizeX);
        //    lBonus.Add(bonusScript[i]);
        //    _bonusId++;
        //}
        // MovePositionsBlocks();

        _firstSpawnPosition.y = _firstSpawnY;
        _firstSpawnPosition.x = _firstSpawnX;
        lLine.Add(newLine);
        _canShoot = true;
        _blockHealth++;
        textScript.ammoCount.gameObject.SetActive(true);
        textScript.underLineAmmoText.SetActive(true);
        textScript.ammoCount.text = _maxAmmo.ToString();
        textScript.score.text     = Mathf.RoundToInt(_score).ToString();
        textScript.BestScore.text = "Best- " + Mathf.RoundToInt(_bestScore).ToString();
    }
Пример #32
0
 void OnGUI()
 {
     if (lineScript == null)
         return;
     style.fontSize = CurrentFontSize;
     style.normal.textColor = guiColor;
     style.normal.background = buttonBG;
     GUI.color = guiColor;
     var centroid = StickyScript.transformToObject(new Vector3(Screen.width / 2, 0, 0), gameObject);
     var scaleX = CurrentScale;
     var scaleY = (int)(CurrentScale * 0.2f);
     var offsetX = (int)(scaleX / 2);
     var offsetY = (int)(scaleY / 2);
     var ySpace = (int)(scaleY / 2) + scaleY;
     var GuiRect = (new Rect(centroid.x - offsetX, centroid.y - offsetY, scaleX, scaleY));
     if (GUI.Button(GuiRect, "Delete Handle", style))
     {
         lineScript.DeleteHandle (Vector3.zero, false);
         StartCoroutine (MenuClose());
     }
     GuiRect.y += ySpace;
     if (GUI.Button(GuiRect, "Insert Sticky", style))
     {
         lineScript.SplitLineSticky(transform.position);
         StartCoroutine (MenuClose());
     }
     GuiRect.y += ySpace;
     if (GUI.Button(GuiRect, "Delete Chain", style))
     {
         var sticky0 = lineScript.ThisChain.Sticky0;
         var sticky1 = lineScript.ThisChain.Sticky1;
         lineScript = null;
         sticky0.GetComponent<StickyScript>().destroyConnection(sticky1.GetComponent<StickyScript>(), true);
         StartCoroutine (MenuClose());
     }
     GuiRect.y += ySpace;
 }
Пример #33
0
    //Find a line that has not yet been drawn given some parameters, draw it
    private static bool DrawAvailLine(int MinX, int MaxX, int MinY, int MaxY, int MinZ, int MaxZ)
    {
        int        i, j, k;
        int        rndSeed   = new System.Random().Next(0, 3);
        GameObject drawnLine = null;

        //Loop through X lines, then Y lines, then Z lines
        if (rndSeed == 0)
        {
            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }
        }

        //Loop through Y lines, then Z lines, then X lines
        else if (rndSeed == 1)
        {
            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }

            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }
        }

        //Loop through Z lines, then X lines, then Y lines
        else
        {
            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }

            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }
        }

        return(false);
    }