Beispiel #1
0
    public void InsertDetailIntoModule()
    {
        isAllowedToRotate = false;

        RaycastHit2D rayHit2d = Physics2D.Raycast(currentPoint, currentPoint * 2);

        float distanceTemp = Head.localPosition.magnitude;

        if (rayHit2d.transform != null)
        {
            RepairModule module = rayHit2d.transform.GetComponent <RepairModule>();
            if (module.Repairtype == currentDetail.Robot.breakageType)
            {
                isDetailRepaierd = true;
                HeadAnimator.SetTrigger("Repair");
                PerformAction = ReturnFromInserting;
            }
            else
            {
                isRobotFuckedUp = true;
            }
        }
        else if (distanceTemp > 0.4f && distanceTemp != 0)
        {
            isDetailRepaierd = false;
            HeadAnimator.SetTrigger("ReturnFromInserting");
            PerformAction = ReturnFromInserting;
        }
    }
Beispiel #2
0
 public void FlipBackwards()
 {
     if (currentHeadAngle == 0)
     {
         HeadAnimator.SetTrigger("Put");
         PerformAction = PutDetailBack;
     }
 }
Beispiel #3
0
 void Start()
 {
     isAllowedToInput = false;
     isArrived        = false;
     PerformAction    = Idle;
     voltmeter.SetBreakageAngle(currentDetail.Robot.breakageAngle);
     if (currentDetail == null)
     {
         currentDetail = GameObject.FindGameObjectWithTag("Detail").GetComponent <Detail>();
     }
 }
Beispiel #4
0
    public void PutDetailBack()
    {
        float tempDistance = ((Vector2)currentDetail.transform.position - (Vector2)currentDetail.Robot.transform.position).magnitude;

        if (tempDistance <= 0.5f)
        {
            currentDetail.transform.SetParent(null);
            HeadAnimator.SetTrigger("ReturnFromPutting");
            PerformAction = ReturnFromPutting;
        }
    }
Beispiel #5
0
    public void Flip()
    {
        if (currentHeadAngle == 180 || currentHeadAngle == -180)
        {
            isDetectingProblem = false;
            isSolvingProblem   = true;

            HeadAnimator.SetTrigger("Idle");
            isAllowedToRotate = true;
            PerformAction     = Idle;
        }
    }
Beispiel #6
0
    void Update()
    {
        if (!isArrived)
        {
            float temp = ((Vector2)currentDetail.Robot.transform.position - new Vector2(0, 0)).magnitude;
            if (temp > 1)
            {
                isArrived = false;
            }
            else
            {
                isArrived = true;
            }
        }

        voltmeter.SetArrow(transform.eulerAngles.z);
        if (isArrived && PerformAction == Idle)
        {
            isAllowedToInput = true;
        }
        else
        {
            isAllowedToInput = false;
        }

        currentHeadAngle = Head.transform.localEulerAngles.z;
        currentPoint     = Head.transform.position;
        Rotate();
        PerformAction();

        if (Input.GetKeyDown(KeyCode.Space) && isAllowedToInput)
        {
            if (isDetectingProblem)
            {
                HeadAnimator.SetTrigger("Grab");
                PerformAction = GrabDetail;
            }
            if (isSolvingProblem)
            {
                isAllowedToRotate = false;
                HeadAnimator.SetTrigger("Insert");
                PerformAction = InsertDetailIntoModule;
            }
        }
    }
Beispiel #7
0
    public void ReturnFromInserting()
    {
        float distanceTemp = Head.localPosition.magnitude;

        if (distanceTemp <= 0.1f)
        {
            if (isDetailRepaierd)
            {
                HeadAnimator.SetTrigger("FlipBackwards");
                PerformAction = FlipBackwards;
            }
            else
            {
                HeadAnimator.SetTrigger("RepeatRepairing");
                isAllowedToRotate = true;
                PerformAction     = Idle;
            }
        }
    }
Beispiel #8
0
    public void GrabDetail()
    {
        isAllowedToRotate = false;

        currentDistance = (detailPoint - (Vector2)currentPoint).magnitude;

        if (currentDistance <= 1.5f)
        {
            if (isDetectingProblem && CheckIfAppropriateAngle())
            {
                currentDetail.transform.SetParent(Head.transform);
                currentDetail.transform.localPosition = new Vector2(0, -0.5f);
                isDetailPickedUp = true;
            }

            HeadAnimator.SetTrigger("ReturnFromGrabbing");
            PerformAction = ReturnFromGrabbing;
        }
    }
Beispiel #9
0
    public void ReturnFromPutting()
    {
        float tempDistance = Head.localPosition.y;

        if (tempDistance >= -0.1f)
        {
            isSolvingProblem = false;
            HeadAnimator.SetTrigger("Idle");
            PerformAction = Idle;

            if (isRobotFuckedUp)
            {
                repairStation.Repair_Robot_Success = 2;
            }
            else
            {
                repairStation.Repair_Robot_Success = 1;
            }
        }
    }
Beispiel #10
0
    public void ReturnFromGrabbing()
    {
        distanceToStart = (startPoint - currentPoint).magnitude;

        if (distanceToStart <= 1f)
        {
            if (isDetectingProblem)
            {
                if (isDetailPickedUp)
                {
                    HeadAnimator.SetTrigger("Flip");
                    PerformAction = Flip;
                }
                else
                {
                    HeadAnimator.SetTrigger("Idle");
                    PerformAction = Idle;
                }
            }
        }
    }