void Awake()
 {
     gm = transform.GetComponentInParent<GhostMover> ();
     box = transform.GetChild (0);
     end = transform.GetChild (1);
     ogScale = box.localScale.y;
 }
    void Start()
    {
        ghost = GetComponent<GhostMover>();
        int startChains = Mathf.FloorToInt((ghost.maxDistance) / (chain.transform.localScale.x*0.85f))-1;

        for (int i = 0; i < startChains; i++) {
            Rigidbody2D rb = Instantiate<GameObject>(chain).GetComponent<Rigidbody2D>();
            chainList.Add(rb);
            HingeJoint2D hinge = (i == 0) ? ghost.graveTransform.GetChild (0).GetComponent<HingeJoint2D>() : chainList[i-1].GetComponent<HingeJoint2D>();
            hinge.connectedBody = rb;
            if (isLoop)
                rb.GetComponent<SpriteRenderer>().sprite = loopSprite;
            else
                rb.GetComponent<SpriteRenderer>().sprite = lineSprite;

            isLoop = !isLoop;
        }
        chainList [chainList.Count - 1].GetComponent<HingeJoint2D> ().connectedBody = transform.GetChild (0).GetChild (0).GetComponent<Rigidbody2D> ();
    }
        private void frmPacman_Load(object sender, EventArgs e)
        {
            ImageCreater imageCreater = new ImageCreater(grpBox_GameScreen);

            thePacman         = imageCreater.CreatePacman();
            ghosts            = imageCreater.CreateGhosts();
            ordinaryFoods     = imageCreater.CreateFoods();
            mapObjectOperator = new MapObjectOperator(grpBox_GameScreen, ordinaryFoods);
            pacmanMover       = new PacmanMover(thePacman, mapObjectOperator);
            ghostMovers       = new GhostMover[ghosts.Length];
            pacmanAI          = new PacmanAIOperator(thePacman, ghosts, mapObjectOperator, 5, ordinaryFoods);

            for (int ghostRecorder = 0; ghostRecorder < ghosts.Length; ghostRecorder++)
            {
                ghostMovers[ghostRecorder] = new GhostMover(ghosts[ghostRecorder], mapObjectOperator);
            }

            LoadGhostMovementUtility();
            LoadPacmanMovementUtility();
        }
 void Start()
 {
     gm = GameObject.Find ("Ghost").GetComponent<GhostMover> ();
 }