Example #1
0
    void CreateBot(ClawMovement parent)
    {
        RoboInfo robot = Instantiate(robotPrefab, startPositionBelt.transform.position, Quaternion.identity);

        robot.transform.parent        = parent.spawningPoint.transform;
        robot.transform.localPosition = new Vector3(0f, 0f, 0f);
        parent.exitOnBelt             = endPositionBelt.transform.position;
        parent.checkPortal            = checkPoint.transform.position;

        if (partOfBackground)
        {
            parent.partOfBackGround = true;
        }
        else
        if (!partOfBackground)
        {
            parent.partOfBackGround = false;
            int missingParts         = Random.Range(1, CurrentDifficulty + 1);
            List <RobotPiece> pieces = new List <RobotPiece>(robot.prefabPieces);
            for (int i = 0; i < missingParts; i++)
            {
                int random = Random.Range(0, pieces.Count);
                pieces[random].owned = false;
                pieces.Remove(pieces[random]);
            }

            parent.robot = robot;
            robot.UpdatePrefab();
        }
    }
Example #2
0
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Robot" || other.gameObject.tag == "RobotPiece")
        {
            robotInTrigger = null;
            //robotPieceInTrigger.highlight.SetActive(false);
            robotPieceInTrigger = null;
        }

        if (other.gameObject.tag == "Ground")
        {
            grounded = false;
        }
    }
Example #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Robot")// || )
        {
            robotInTrigger = other.gameObject.GetComponent <RoboInfo>();
        }
        else if (other.gameObject.tag == "RobotPiece")
        {
            robotPieceInTrigger = other.gameObject.GetComponent <RobotPiece>();
            // robotPieceInTrigger.highlight.SetActive(true);
        }

        if (other.gameObject.tag == "Ground")
        {
            grounded = true;
        }
    }
    void PutPiece(RoboInfo robot)
    {
        if (robot.completedPieces != robot.allPieces.Count)
        {
            for (int i = 0; i < robot.allPieces.Count; i++)
            {
                if (robot.allPieces[i].owned == false)
                {
                    for (int j = 0; j < playerPieces.Length; j++)
                    {
                        if (robot.allPieces[i].piece == playerPieces[j].piece && playerPieces[j].owned == true)
                        {
                            robot.allPieces[i].owned = true;
                            playerPieces[j].owned    = false;
                            robot.UpdatePrefab();
                            if (leftItem != null && leftItem.piece == playerPieces[j].piece)
                            {
                                Destroy(leftItem.gameObject);
                            }
                            else if (rightItem != null && rightItem.piece == playerPieces[j].piece)
                            {
                                Destroy(rightItem.gameObject);
                            }



                            //if (leftItem != null)
                            //{ Destroy(leftItem); }
                            //else if (rightItem != null)
                            //{ Destroy(rightItem); }
                            //else if (bodyItem != null)
                            //{
                            //    Destroy(bodyItem);
                            //}

                            break;
                        }
                    }
                }
            }
        }
    }