예제 #1
0
    private void FindGoal(int[,] lvlBase)
    {
        taLvlCreator = FindObjectOfType(typeof(TimeAttackLevelCreator)) as TimeAttackLevelCreator;

        //Find mulige connections:
        List <string> lstPossibleConnections = FindPossibleConnections();

        if (lstPossibleConnections.Count > 0)
        {
            //Roll en random af de mulige connections:
            int nextPos = Random.Range(0, lstPossibleConnections.Count);

            //Gem den nye possition, i listen over connections, så vi kan spawne mindst en mulig løsning til mappet!:
            lstGameRoute.Add(lstPossibleConnections[nextPos]);


            //Sæt curr x og y, til den nye plads så vi kan starte forfra:
            currY = int.Parse(lstPossibleConnections[nextPos].Split(',')[0]);
            currX = int.Parse(lstPossibleConnections[nextPos].Split(',')[1]);

            taLvlCreator.lastGoalPositionX = currX;
            taLvlCreator.lastGoalPositionY = currY;

            SetRoute();
        }
        else
        {
            lvlGridPath = lvlGrid;
            FindRoute(lvlBase);
        }
    }
예제 #2
0
    public void CreateBackgrounds()
    {
        tALC    = gameObject.GetComponent <TimeAttackLevelCreator>();
        lvlGrid = tALC.lvlGrid;

        for (int x = 0; x < lvlGrid.GetLength(1); x++)
        {
            for (int y = 0; y < lvlGrid.GetLength(0); y++)
            {
                if (lvlGrid[y, x] >= 1)
                {
                    //N
                    if (lvlGrid.GetLength(0) > y + 1 && lvlGrid[y + 1, x] >= 1)
                    {
                        GameObject newBgN = GameObject.Instantiate(bgN, new Vector3((x - 4) * 1.6f, (y - 2) * 1.6f, 1), Quaternion.identity) as GameObject;
                        newBgN.transform.SetParent(GameObject.Find("Backgrounds").transform);
                    }

                    //NE
                    if (lvlGrid.GetLength(0) > y + 1 && lvlGrid.GetLength(1) > x + 1 && lvlGrid[y + 1, x + 1] >= 1)
                    {
                        //Når en NE linje, går over en SE linje, ser det dumt ud, så brug NEX til disse steder!
                        GameObject NELine;
                        if (lvlGrid[y + 1, x] >= 1 && lvlGrid[y, x + 1] >= 1)
                        {
                            NELine = bgNEX;
                        }
                        else
                        {
                            NELine = bgNE;
                        }

                        GameObject newBgNE = GameObject.Instantiate(NELine, new Vector3((x - 4) * 1.6f, (y - 2) * 1.6f, 1), Quaternion.identity) as GameObject;
                        newBgNE.transform.SetParent(GameObject.Find("Backgrounds").transform);
                    }

                    //E
                    if (lvlGrid.GetLength(1) > x + 1 && lvlGrid[y, x + 1] >= 1)
                    {
                        GameObject newBgE = GameObject.Instantiate(bgE, new Vector3((x - 4) * 1.6f, (y - 2) * 1.6f, 1), Quaternion.identity) as GameObject;
                        newBgE.transform.SetParent(GameObject.Find("Backgrounds").transform);
                    }

                    //SE
                    if (y > 0 && lvlGrid.GetLength(1) > x + 1 && lvlGrid[y - 1, x + 1] >= 1)
                    {
                        GameObject newBgSE = GameObject.Instantiate(bgSE, new Vector3((x - 4) * 1.6f, (y - 2) * 1.6f, 1), Quaternion.identity) as GameObject;
                        newBgSE.transform.SetParent(GameObject.Find("Backgrounds").transform);
                    }
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        touchManager = FindObjectOfType(typeof(TouchManager)) as TouchManager;
        taScoreMan   = FindObjectOfType(typeof(TimeAttackScoreManager)) as TimeAttackScoreManager;
        tALvlCreator = FindObjectOfType(typeof(TimeAttackLevelCreator)) as TimeAttackLevelCreator;
        taLvlUI      = FindObjectOfType(typeof(TimeAttackGUILevelUI)) as TimeAttackGUILevelUI;
        desMapEff    = FindObjectOfType(typeof(DestroyMapEffect)) as DestroyMapEffect;


        sceneCanvas = (Canvas)FindObjectOfType(typeof(Canvas));


        StartCoroutine(taLvlUI.CountDown());

        if (taLvlUI != null)
        {
            taLvlUI.ShowStarBar(true);
            taLvlUI.UpdateStarRequirement(numberOfConnectionsFor1star, tALvlCreator.lvlSize - 1); //minus 1 fordi start ikke tæller med!
        }
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        oneSec = 1 / maxSec;


        //Get the normale rect width of the stars:
        starNormaleSize     = star1RectTransform.rect.width;
        starMaxSize         = starNormaleSize * 1.25f;
        starNormaleRotation = star1RectTransform.rotation.z;

        displayNumber.number = (int)maxSec;

        if (objGameOver == null)
        {
            objGameOver = GameObject.Find("GameOver");
        }
        objGameOver.SetActive(false);

        touchManager         = FindObjectOfType(typeof(TouchManager)) as TouchManager;
        animatorShowGameOver = GetComponent <Animator>();
        tALvlC = FindObjectOfType(typeof(TimeAttackLevelCreator)) as TimeAttackLevelCreator;
    }