コード例 #1
0
    private void StartGame()
    {
        // showing interstitial
        if (lastAddsTime + gameSettings.interstitialShowingDelay < Time.realtimeSinceStartup)
        {
            AdsManager.ShowInterstitial(interstitialType);

            lastAddsTime = Time.realtimeSinceStartup;
        }

        reviveUsed           = false;
        firstStageCompleted  = false;
        currentItemsAbsorbed = 0;
        currentLevel         = GameSettingsPrefs.Get <int>("current level");

        levelState = LevelState.First;
        LevelController.instance.LoadLevel(currentLevel);
        UIController.instance.InitLevel(currentLevel);
        CameraController.instance.InitCameraOnFirstStage();
        ColorsController.SetRandomPreset();

        GroundGenerator.InitPlayground();

        waitingForTap = true;

        // ads
        bannerType        = AdsManager.GetBannerType();
        interstitialType  = AdsManager.GetInterstitialType();
        rewardedVideoType = AdsManager.GetRewardedVideoType();

        AdsManager.RequestInterstitial(interstitialType);
        AdsManager.RequestRewardBasedVideo(rewardedVideoType);

        AdsManager.ShowBanner(bannerType);
    }
コード例 #2
0
 void Start()
 {
     gg      = GameObject.FindGameObjectWithTag("GroundGenerator").GetComponent <GroundGenerator>();
     player  = GameObject.FindGameObjectWithTag("Player");
     enemies = GameObject.FindGameObjectsWithTag("Enemy").ToList();
     random  = new System.Random();
 }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        //return;
        Time.timeScale = 1f;
        DB             = gameObject.GetComponent <DatabaseController>().LoadDB();
        CanvasObj      = GameObject.Find("Canvas");

        NearInteractablePrompt = GameObject.Find("Canvas/PROMPT");

        ShopMenu = GameObject.Find("Canvas/SHOPMENU");
        ShopMenu.SetActive(false);

        GG = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
        GG.NewMap();

        Player = GameObject.Find("Player");
        Shop   = GameObject.FindObjectOfType <ShopBehaviour>().gameObject;
        Shop.GetComponent <ShopBehaviour>().ShuffleStock();

        Clock = GameObject.Find("Canvas/CLOCK");

        HelpMenu = GameObject.Find("Canvas/HELPMENU");
        HelpMenu.SetActive(false);

        PauseMenu = GameObject.Find("Canvas/PAUSEMENU");
        PauseMenu.SetActive(false);
    }
コード例 #4
0
ファイル: LevelProcessor.cs プロジェクト: pwilken/UnityMario
    void AddGenerators(List <IGenerator> generators)
    {
        LevelInfo levelInfo = new LevelInfo();

        levelInfo.columns          = columns;
        levelInfo.rows             = rows;
        levelInfo.playerHeight     = playerHeight;
        levelInfo.maxJumpHeight    = maxJumpHeight;
        levelInfo.maxJumpLength    = maxJumpLength;
        levelInfo.minGroundHeight  = minGroundHeight;
        levelInfo.minGroundLength  = minGroundLength;
        levelInfo.maxGroundLength  = maxGroundLength;
        levelInfo.gapProbability   = gapProbability;
        levelInfo.steepProbability = steepProbability;
        levelInfo.blockProbability = blockProbability;

        GroundGenerator   groundGenerator   = new GroundGenerator(levelInfo);
        ObstacleGenerator obstacleGenerator = new ObstacleGenerator(levelInfo);
        BlockGenerator    blockGenerator    = new BlockGenerator(levelInfo);
        ItemGenerator     itemGenerator     = new ItemGenerator(levelInfo);

        generators.Add(groundGenerator);
        generators.Add(obstacleGenerator);
        generators.Add(blockGenerator);
        generators.Add(itemGenerator);
    }
コード例 #5
0
 void Start()
 {
     player      = GameObject.FindGameObjectWithTag("Player");
     gg          = GameObject.FindGameObjectWithTag("GroundGenerator").GetComponent <GroundGenerator>();
     newPosition = transform.position;
     playerX     = player.transform.position.x;
 }
コード例 #6
0
    private void Update()
    {
        if (!isTouchActive)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            prevPosition   = Input.mousePosition;
            targetPosition = holeTransform.position;
        }

        if (Input.GetMouseButton(0))
        {
            Vector3 touchDelta    = Input.mousePosition - prevPosition;                                                                                                                 // screen touch delta
            Vector3 positionDelta = touchDelta * pixelToPlayground * touchSens;                                                                                                         // world touch delta
            positionDelta = new Vector3(positionDelta.x, 0f, positionDelta.y * heightToWidthCoef);                                                                                      // normalized world delta

            targetPosition = targetPosition + positionDelta;                                                                                                                            // target position

            targetPosition = new Vector3(Mathf.Clamp(targetPosition.x, leftBound, rightBound), 0f, Mathf.Clamp(targetPosition.z, bottomBound + stageOffsetZ, topBound + stageOffsetZ)); // clamped to playground bounds

            holeTransform.position = Vector3.Lerp(holeTransform.position, targetPosition, 0.3f);                                                                                        // lerped position

            GroundGenerator.UpdateGround();

            prevPosition = Input.mousePosition;
        }
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        me  = this;
        box = GetComponent <BoxCollider2D>();
        rb  = GetComponent <Rigidbody2D>();

        tex = new Texture2D(groundWidth, groundHeight);

        tiles       = new int[groundWidth, groundHeight];
        newTiles    = new int[groundWidth, groundHeight];
        tileObjects = new GameObject[groundWidth, groundHeight];

        trickleCounters = new int[2];

        generateMapData();
        CA();
        shrinePass();
        cleanupTiles();
        trickled = false;

        if (Master.me.numShrines == 0)
        {
            spawnShrine(Random.Range(6, groundWidth - 6), Random.Range(6, 20));
        }

        wall1.transform.position = new Vector3(0, transform.position.y, transform.position.z);
        wall2.transform.position = new Vector3(groundWidth, transform.position.y, transform.position.z);
        wall3.transform.position = new Vector3(groundWidth / 2, 0, transform.position.z);
        setPlayerPos();
    }
コード例 #8
0
ファイル: EventsManager.cs プロジェクト: gbersac/zappy_42
 void Start()
 {
     em        = this.GetComponent <EventsManager> ();
     msgBox    = Instantiate <MessagesBox>(msgBox);
     map       = ground.GetComponent <GroundGenerator> ();
     eggs      = new List <Egg> ();
     teams     = new List <Team> ();
     functions = new Dictionary <string, System.Action <string> > ();
     functions.Add("BIENVENUE", ft_bienvenue);
     functions.Add("msz", ft_mapsize);
     functions.Add("bct", ft_content_map);
     functions.Add("tna", ft_team_name);
     functions.Add("pnw", ft_new_player);
     functions.Add("ppo", ft_player_position);
     functions.Add("plv", ft_player_level);
     functions.Add("pin", ft_player_inventory);
     functions.Add("pex", ft_player_expulse);
     functions.Add("pbc", ft_player_broadcast);
     functions.Add("pic", ft_player_incantation);
     functions.Add("pie", ft_player_end_incantation);
     functions.Add("pfk", ft_player_lays);
     functions.Add("pdr", ft_player_vomit);
     functions.Add("pgt", ft_player_picks);
     functions.Add("pdi", ft_player_died);
     functions.Add("enw", ft_new_egg_pos);
     functions.Add("eht", ft_egg_born);
     functions.Add("edi", ft_egg_died);
     functions.Add("ebo", ft_player_replaces_egg);
     functions.Add("sgt", timeUnit);
     functions.Add("seg", ft_end);
     functions.Add("smg", recMessage);
     functions.Add("suc", unknownCommand);
     functions.Add("sbp", badArgs);
 }
コード例 #9
0
 private void Awake()
 {
     instance = this;
     holeHalf = HOLE_DIAMETER * 0.5f;
     instance.InitGroundMesh();
     instance.IntitBackSea();
 }
コード例 #10
0
    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        Vector3 spawnPosition           = startPoint.position;
        int     tilesWithNoObstaclesTmp = tilesWithoutObstacles;

        for (int i = 0; i < tilesToPreSpawn; i++)
        {
            spawnPosition -= tilePrefab.startPoint.localPosition;
            Platform spawnedTile = Instantiate(tilePrefab, spawnPosition, Quaternion.identity) as Platform;
            if (tilesWithNoObstaclesTmp > 0)
            {
                spawnedTile.DeactivateAllObstacles();
                tilesWithNoObstaclesTmp--;
            }
            else
            {
                spawnedTile.ActivateRandomObstacle();
            }

            spawnPosition = spawnedTile.endPoint.position;
            spawnedTile.transform.SetParent(transform);
            spawnedTiles.Add(spawnedTile);
        }
    }
コード例 #11
0
    // Use this for initialization
    void Start()
    {
        Instance = this;
        manager  = Manager.Instance;
        List <Vector2> voidCoords  = new List <Vector2> ();
        List <Vector2> waterCoords = new List <Vector2> ();
        List <Vector2> grassCoords = new List <Vector2> ();

        Vector2[] patches = new Vector2[manager.Width * manager.Height];
        for (int z = 0; z < manager.Height; z++)
        {
            for (int x = 0; x < manager.Width; x++)
            {
                patches [z * manager.Width + x] = new Vector2(x, z);
            }
        }
        patches = patches.OrderBy(item => manager.Randomizer.Next()).ToArray();
        int voidCount  = patches.Length * VoidPercentage / 100;
        int waterCount = (patches.Length - voidCount) * WaterPercentage / 100;

        for (int i = 0; i < voidCount; i++)
        {
            voidCoords.Add(patches [i]);
        }
        for (int i = voidCount, sz = voidCount + waterCount; i < sz; i++)
        {
            waterCoords.Add(patches [i]);
        }
        for (int i = voidCount + waterCount, sz = patches.Length; i < sz; i++)
        {
            grassCoords.Add(patches [i]);
        }

        for (int z = 0; z < manager.Height; z++)
        {
            for (int x = 0; x < manager.Width; x++)
            {
                GameObject tmp;
                if (voidCoords.Contains(new Vector2(x, z)))
                {
                    tmp = Instantiate(VoidPrefab, new Vector3(x, 0, z), Quaternion.identity, transform);
                    VoidList.Add(tmp);
                }
                else if (waterCoords.Contains(new Vector2(x, z)))
                {
                    tmp = Instantiate(WaterPrefab, new Vector3(x, 0, z), Quaternion.identity, transform);
                    WaterList.Add(tmp);
                }
                else
                {
                    tmp = Instantiate(GrassPrefab, new Vector3(x, 0, z), Quaternion.identity, transform);
                    GrassList.Add(tmp);
                }
                Manager.Instance.Patches [x, z] = tmp;
            }
        }
        time = Time.time;
    }
コード例 #12
0
ファイル: Wander.cs プロジェクト: Ton-X/HungryBehaviour_Demo
 public override void Start()
 {
     gm           = Object.FindObjectOfType <GameManager>();
     ground       = gm.GetComponent <GroundGenerator>();
     aStar        = gm.GetComponent <AStarPathfinding>();
     wanderEditor = editorNode as WanderEditor;
     btree        = go.GetComponent <BTreeExecutor>().btRuntime;
     btree.btRuntimeParams.boolParams["WanderingEnabled"] = true;
 }
コード例 #13
0
    public override void Start()
    {
        GameManager gm = Object.FindObjectOfType <GameManager>();

        ground = gm.GetComponent <GroundGenerator>();
        aStar  = gm.GetComponent <AStarPathfinding>();

        btree = go.GetComponent <BTreeExecutor>().btRuntime;
    }
コード例 #14
0
ファイル: NbackGenerator.cs プロジェクト: nchou001/Popz
    public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int difficulty = navigationDifficulty;
        int scale = 10;

        // Generate beginning so character doesnt fall
        if (generateCount == 0) {
            for (int i = 0; i < 5; ++i) {
                ggen.GenerateGround (i, 0, grid, tc);
                ggen.GenerateGround (i, 7, grid, tc);
            }
        }
        ++generateCount;

        // Entry for prototype platforms generation
        if (platforms) {
            GenerateNbackInGridPlatforms(grid, tc, ggen);
            return;
        }

        // Generate Nback collectibles
        int x = lastGridOffset;
        for ( ; x < grid.numCellsX; x += rate) {
            int rand = Random.Range(0, 2);
            int y = rand == 0 ? 1 : 6;
            Transform h = GenerateNbackObjectInGrid(x, y, grid, tc);
        }

        // Generate ground and potholes
        for (int i = 0; i < grid.numCellsX; ++i) {
            // For floor
            // Generate ground (NOT pothole) by scale and difficulty
            if (grid.containsObject(i, 0)) {
                Debug.Log ("Grid Contains at: " + i);
                continue;
            }
            int cap = Mathf.Min (4, grid.numCellsX - i + 1);
            int roll = Random.Range (1, cap);

            while (!ggen.GenerateWideGround(i, 0, roll, grid, tc)) {
                roll = Random.Range (1, 4);
            }

        //			int rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				ggen.GenerateGround (i, 0, grid, tc);
        //			}
        //
        //			// For Ceiling
        //			rand = Random.Range(0, 100);
        //			if (rand > difficulty * scale) {
        //				//ggen.GenerateGround (i, 7, grid, tc);
        //			}
        }
        lastGridOffset = x - grid.numCellsX;
    }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Generate"))
        {
            GroundGenerator theBigG = (GroundGenerator)target;
            theBigG.Generate();
        }
    }
コード例 #16
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GroundGenerator generator = (GroundGenerator)target;

        if (GUILayout.Button("Generate island"))
        {
            generator.GenerateIsland();
        }
        if (GUILayout.Button("Randomize tiles"))
        {
            generator.EditorGenerate(10, 10);
        }
    }
コード例 #17
0
    // Use this for initialization
    void Start()
    {
        playerController = Player.GetComponent <PlayerController> ();
        groundGenerator  = Ground.GetComponent <GroundGenerator> ();

        hiscore = loadHiScore();
        createInitialStructure();

        CheckpointText.enabled = false;
        GameOverText.enabled   = false;
        PlayAgainButton.gameObject.SetActive(false);
        HiScoreImage.enabled = false;
        DifficultyText.text  = "Difficulty: Easy";
        DifficultyText.color = Color.green;
    }
コード例 #18
0
    private IEnumerator MoveHoleToNextStage(Transform holeTransform)
    {
        TouchController.instance.Deactivate();
        DeactivateFirstStageObstacles();
        OpenGates();

        float playgroundCenter   = GroundGenerator.PlaygroundCenter;
        WaitForFixedUpdate delay = new WaitForFixedUpdate();

        while (Mathf.Abs(holeTransform.position.x - playgroundCenter) > 0.01f)
        {
            holeTransform.position = Vector3.MoveTowards(holeTransform.position, holeTransform.position.SetX(playgroundCenter), 2f * Time.fixedDeltaTime);
            GroundGenerator.UpdateGround();

            yield return(delay);
        }

        HoleBehabiour.EnableAroundHoleMesh();
        holeTransform.position = holeTransform.position.SetX(playgroundCenter);

        float nextStageStartZ = GroundGenerator.PLAYGROUND_HEIGHT + GroundGenerator.GROUNDS_OFFSET + GroundGenerator.HOLE_INITIAL_OFFSET_Z;

        CameraController.instance.MoveToSecondStage();
        GroundGenerator.stopVerticalMeshGen = true;

        while (Mathf.Abs(holeTransform.position.z - nextStageStartZ) > 0.01f)
        {
            holeTransform.position = Vector3.MoveTowards(holeTransform.position, holeTransform.position.SetZ(nextStageStartZ), 4f * Time.fixedDeltaTime);
            GroundGenerator.UpdateGround();

            GroundGenerator.UpdateConnectingPath();

            yield return(delay);
        }

        ActivateFirstStageObstacles();
        HoleBehabiour.DisableAroundHoleMesh();
        GameController.OnSecondStageReached();

        GroundGenerator.stopVerticalMeshGen = false;
        GroundGenerator.RecalculateNormals();
        GroundGenerator.UpdateGround();
    }
コード例 #19
0
ファイル: NbackGenerator.cs プロジェクト: nchou001/Popz
    // Entry for prototype platforms generation
    public void GenerateNbackInGridPlatforms(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int x = lastGridOffset;
        int topY = grid.numCellsY - 2;
        int midY = topY / 2;
        for ( ; x < grid.numCellsX; x += rate) {
            int roll = Random.Range (0, 4);
            int placement = roll == 0 ? 1 : (roll == 1 ? midY + 1: topY + 1);
            Transform h = GenerateNbackObjectInGrid(x, placement, grid, tc);
        }
        lastGridOffset = x - grid.numCellsX;

        for (int y = 0; y <= grid.numCellsY; ++y) {
            ggen.GenerateGround(y, topY, grid, tc);
            ggen.GenerateGround(y, midY, grid, tc);
            ggen.GenerateGround(y, 0, grid, tc);
        }

        return;
    }
コード例 #20
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            this.enabled = false;
        }

        gr = GetComponent <Ground>();
        spawnPosTransform = transform.Find("SpawnPos");

        prevChunk = Instantiate(chunkPref, Vector3.zero, Quaternion.identity, transform).transform;
        for (int i = 0; i < gr.chunksInScene - 1; i++)
        {
            GenerateNewChunk();
        }
    }
コード例 #21
0
ファイル: NbackGenerator.cs プロジェクト: b-huynh/Popz
    public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int difficulty = navigationDifficulty;
        int scale      = 10;

        // Generate beginning so character doesnt fall
        if (generateCount == 0)
        {
            for (int i = 0; i < 5; ++i)
            {
                //ggen.GenerateGround (i, 0, grid, tc);
                //ggen.GenerateGround (i, 7, grid, tc);
            }
        }
        ++generateCount;

        // Entry for prototype platforms generation
        if (platforms)
        {
            GenerateNbackInGridPlatforms(grid, tc, ggen);
            return;
        }

        // Generate Nback collectibles
        int x = lastGridOffset;

        for ( ; x < grid.numCellsX; x += rate)
        {
            int rand = Random.Range(0, 2);
            int y    = rand == 0 ? 1 : 6;
            //int y = 1;
            Transform h = GenerateNbackObjectInGrid(x, y, grid, tc);
        }

        ggen.GenerateGrounds(grid, tc, 0, false, 60);
        ggen.GenerateGrounds(grid, tc, 7, true);

        lastGridOffset = x - grid.numCellsX;
    }
コード例 #22
0
ファイル: TerrainGenerator.cs プロジェクト: b-huynh/Popz
    // Use this for initialization
    void Start()
    {
        gameMngr = FindObjectOfType(typeof(PopzGameManager)) as PopzGameManager;

        // Set up references to object generators and grid
        grid           = GameObject.FindGameObjectWithTag("Grid").GetComponent <Grid> ();
        platformGen    = GameObject.FindGameObjectWithTag("PlatformGen").GetComponent <PlatformGenerator> ();
        collectibleGen = GameObject.FindGameObjectWithTag("CollectibleGen").GetComponent <CollectibleGenerator> ();
        groundGen      = GameObject.FindGameObjectWithTag("GroundGen").GetComponent <GroundGenerator> ();
        nbackGen       = FindObjectOfType(typeof(NbackGenerator)) as NbackGenerator;
        player         = GameObject.FindGameObjectWithTag("Player").GetComponent <Player> ();

        // Position generator and box collider
        Vector3 bottomLeft = Camera.main.ScreenToWorldPoint(new Vector3(0f, 0f, 0f));
        Vector3 topRight   = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth, Camera.main.pixelHeight, 0f));

        bottomLeft.y = Camera.main.GetComponent <FixedHeight> ().height - (topRight.y - bottomLeft.y) / 2f;
        BoxCollider2D boxCol    = gameObject.GetComponent <BoxCollider2D> ();
        float         boxHeight = topRight.y - bottomLeft.y;
        float         boxWidth  = 1f;

        boxCol.size        = new Vector2(boxWidth, boxHeight);
        boxCol.offset      = new Vector2(-boxWidth, boxHeight / 2f);
        transform.position = new Vector3(bottomLeft.x, bottomLeft.y, 0f);

        BoxCollider2D chunkBoxCol    = terrainChunk.GetComponent <BoxCollider2D> ();
        float         chunkBoxWidth  = 2f * ((float)grid.numCellsX) * grid.cellSizeX;
        float         chunkBoxHeight = topRight.y - bottomLeft.y;

        chunkBoxCol.size      = new Vector2(chunkBoxWidth, chunkBoxHeight);
        chunkBoxCol.offset    = new Vector2(chunkBoxWidth / 2f, chunkBoxHeight / 2f);
        chunkBoxCol.isTrigger = true;

        genPlants    = false;
        genPlatforms = false;

        //Debug.Log (transform.position);
        GenerateTerrain(transform.position);
    }
コード例 #23
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Obstacle"))
     {
         if (!invincibleMode)
         {
             GroundGenerator ground = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
             effectSource.PlayOneShot(bumpEffect);
             ground.lostTheGame();
         }
         else
         {
             other.gameObject.SetActive(false);
         }
     }
     if (other.gameObject.CompareTag("Star"))
     {
         GroundGenerator ground = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
         ground.invincibleMode = true;
         invincibleMode        = true;
         rend.material         = speedMat;
         effectSource.PlayOneShot(starEffect);
         if (!speedMusic.isPlaying)
         {
             speedMusic.volume = 1;
             speedMusic.Play();
             mainMusic.volume = 0;
         }
         other.gameObject.SetActive(false);
         invincibleStart = Time.time;
     }
     if (other.gameObject.CompareTag("Food"))
     {
         GroundGenerator ground = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
         ground.score++;
         effectSource.PlayOneShot(feedEffect);
         other.gameObject.SetActive(false);
     }
 }
コード例 #24
0
ファイル: NbackGenerator.cs プロジェクト: b-huynh/Popz
    // Entry for prototype platforms generation
    public void GenerateNbackInGridPlatforms(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        int x    = lastGridOffset;
        int topY = grid.numCellsY - 2;
        int midY = topY / 2;

        for ( ; x < grid.numCellsX; x += rate)
        {
            int       roll      = Random.Range(0, 4);
            int       placement = roll == 0 ? 1 : (roll == 1 ? midY + 1: topY + 1);
            Transform h         = GenerateNbackObjectInGrid(x, placement, grid, tc);
        }
        lastGridOffset = x - grid.numCellsX;

        for (int y = 0; y <= grid.numCellsY; ++y)
        {
            ggen.GenerateGround(y, topY, grid, tc);
            ggen.GenerateGround(y, midY, grid, tc);
            ggen.GenerateGround(y, 0, grid, tc);
        }

        return;
    }
コード例 #25
0
 void Start()
 {
     groundGen = GameObject.Find("GAME_MANAGER").GetComponent<GroundGenerator>();
 }
コード例 #26
0
 void Awake()
 {
     groundGenerator = GetComponent <GroundGenerator>();
     groundGenerator.GenerateLevel();
 }
コード例 #27
0
    // Update is called once per frame
    void Update()
    {
        if (invincibleMode)
        {
            if (Time.time - invincibleStart >= invicibleTimeMax)
            {
                invincibleMode = false;
                rend.material  = normalMat;
                speedMusic.Stop();
                speedMusic.volume = 0;
                mainMusic.volume  = 0.5f;
                GroundGenerator ground = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
                ground.invincibleMode = false;
            }
        }

        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);
            if (t.phase == TouchPhase.Began)
            {
                isSwipping     = true;
                touchOriginPos = t.position;
            }
            if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled)
            {
                isSwipping = false;
            }
            //Vector2 deltaPos = new Vector2(t.deltaPosition.x / 1000000000, 0);
            //slideSnake(deltaPos);
        }

        if (isSwipping && Input.touchCount > 0)
        {
            Vector2 currentPos = Input.touches[0].position;
            Vector2 deltaPos   = new Vector2(currentPos.x - touchOriginPos.x, 0);
            slideSnake(deltaPos);

            touchOriginPos = currentPos;
        }

        if (Input.GetMouseButtonDown(0))
        {
            isTouching     = true;
            touchOriginPos = Input.mousePosition;
        }

        if (Input.GetMouseButtonUp(0))
        {
            isTouching = false;
        }

        if (isTouching)
        {
            Vector2 currentPos = Input.mousePosition;
            Vector2 deltaPos   = new Vector2(currentPos.x - touchOriginPos.x, 0);
            slideSnake(deltaPos);

            touchOriginPos = currentPos;
        }
        if (GetComponent <Transform>().position.y <= -2)
        {
            GroundGenerator ground = GameObject.Find("GroundGenerator").GetComponent <GroundGenerator>();
            ground.lostTheGame();
        }
    }
コード例 #28
0
 // Start is called before the first frame update
 void Start()
 {
     player          = FindObjectOfType <PlayerControls>();
     groundGenerator = FindObjectOfType <GroundGenerator>();
 }
コード例 #29
0
 void Awake()
 {
     generator = FindObjectOfType <GroundGenerator>();
 }
コード例 #30
0
ファイル: MapGenerator.cs プロジェクト: AkpoFlash/Bomberman
    public void AddGround(GameObject gameObject)
    {
        GroundGenerator ground = new GroundGenerator();

        ground.Generate(gameObject);
    }
コード例 #31
0
 void Start()
 {
     groundGen = GameObject.FindGameObjectWithTag("GroundGenerator").GetComponent <GroundGenerator>();
 }
コード例 #32
0
    public void Regenerate()
    {
        if (generatorInstance)
        {
            generatorInstance.Clear();
            DestroyImmediate(generatorInstance);
        }
        generatorInstance = Instantiate(generator);

        Vector2Int worldSize = generatorInstance.GetWorldSize();

        generatorSpec = new HoleGroundGenerator(stoneTile, new List <Rect> {
            new Rect(16, worldSize.y - 32, 32, 32),
            new Rect(15, worldSize.y - 31, 34, 32),
            new Rect(14, worldSize.y - 30, 36, 32),
            new Rect(14, worldSize.y - 30, 36, 32),
            InvertRectY(new Rect(42, 32, 5, 6)),
            InvertRectY(new Rect(26, 36, 18, 2)),
            InvertRectY(new Rect(12, 38, 18, 4)),
            InvertRectY(new Rect(12, 38, 2, 10)),
            InvertRectY(new Rect(12, 48, 30, 10)),
            InvertRectY(new Rect(42, 48, 10, 2)),
            InvertRectY(new Rect(52, 48, 2, 14)),
            InvertRectY(new Rect(42, 60, 10, 2)),
            InvertRectY(new Rect(26, 60, 16, 2)),
            InvertRectY(new Rect(12, 60, 16, 8)),
            InvertRectY(new Rect(10, 60, 2, 20)),
            InvertRectY(new Rect(12, 79, 2, 1)),
            InvertRectY(new Rect(14, 79, 20, 10)),
            InvertRectY(new Rect(34, 79, 4, 2)),
            InvertRectY(new Rect(36, 81, 2, 30)),
            InvertRectY(new Rect(10, 93, worldSize.x - 20, 29)),
        }, new Vector2Int(18, worldSize.y - 29), new List <HoleGroundGenerator.CustomGenerator>
        {
            (seed, position) =>
            {
                Rect[] boulders = new Rect[]
                {
                    new Rect(14, 40, 2, 2),
                    new Rect(20, 40, 2, 2),
                    new Rect(26, 40, 2, 2),
                    new Rect(12, 50, 2, 8),
                    new Rect(14, 52, 2, 6),
                    new Rect(16, 54, 2, 4),
                    new Rect(18, 56, 2, 2),
                    new Rect(22, 52, 2, 2),
                    new Rect(26, 52, 2, 2),
                    new Rect(30, 52, 2, 2),
                    new Rect(34, 52, 2, 2),
                    new Rect(38, 52, 2, 2),
                    new Rect(42, 52, 2, 2),
                    new Rect(26, 64, 2, 4),
                    new Rect(24, 66, 2, 2),
                    new Rect(20, 67, 2, 1),
                    new Rect(16, 67, 2, 1),
                    new Rect(12, 67, 2, 1),
                    new Rect(14, 82, 2, 7),
                    new Rect(24, 85, 2, 2),

                    new Rect(28, 83, 2, 2),
                };

                foreach (Rect boulder in boulders)
                {
                    if (InvertRectY(boulder).Contains(position))
                    {
                        return(stoneTile);
                    }
                }

                Rect[] lavaSpots = new Rect[]
                {
                    new Rect(31, 32, 10, 3),
                    new Rect(50, 62, 2, 2),
                    new Rect(46, 62, 2, 2),
                    new Rect(42, 62, 2, 2),
                    new Rect(38, 62, 2, 2),
                    new Rect(34, 62, 2, 2),
                    new Rect(30, 62, 2, 2),
                    new Rect(22, 68, 2, 2),
                    new Rect(18, 68, 2, 2),
                    new Rect(14, 68, 2, 2),
                    new Rect(16, 89, 18, 2)
                };

                foreach (Rect lava in lavaSpots)
                {
                    if (InvertRectY(lava).Contains(position))
                    {
                        return(lavaTile);
                    }
                }


                if ((position.x == 17 || position.x == 18) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(moveInstructionTile);
                }
                if ((position.x == 21 || position.x == 22) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(jumpInstructionTile);
                }
                if ((position.x == 25 || position.x == 26) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(shootInstructionTile);
                }
                if ((position.x >= 29 && position.x <= 30) && (position.y >= (worldSize.y - 32) && position.y <= (worldSize.y - 31)))
                {
                    return(stoneTile);
                }

                return(null);
            }
        });

        generatorInstance.Generate(0, generatorSpec);
    }
コード例 #33
0
ファイル: NbackGenerator.cs プロジェクト: SamClose/NC-Popz
    public void GenerateNbackInGrid(Grid grid, TerrainChunk tc, GroundGenerator ggen)
    {
        //Called from Terrainen
        int difficulty = navigationDifficulty;
        int scale = 10;

        // Generate beginning so character doesnt fall
        if (generateCount == 0) {
            for (int i = 0; i < 5; ++i) {
                //ggen.GenerateGround (i, 0, grid, tc);
                //ggen.GenerateGround (i, 7, grid, tc);
            }
        }
        ++generateCount;

        //Entry for prototype platforms generation
        /*if (platforms) {
            GenerateNbackInGridPlatforms(grid, tc, ggen);
            return;
        }*/

        // Generate Nback collectibles on floor,ceiling, and random
        int x = lastGridOffset;
        int y = 3;
        for ( ; x < grid.numCellsX; x += rate) {
            int rand = Random.Range(0, 2);
            //int y = rand == 0 ? 1 : 6;
            if(timer >= 0f && timer < 40f){
                y = 3;
            } else if (timer >= 40f && timer < 80f) {
                y = 5;
            } else if (timer >= 80f && timer < 120f) {
                y = 6;
            } else if (timer >= 120f && timer < 240f) {
                y = 1;
            } else if (timer >= 240f && timer < 280) {
                y = rand == 0 ? 1 : 5;
            } else if ((timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) {
                y = rand == 0 ? 1 : 6;
            } else if ((timer >= 320f && timer < 360f) || timer >= 480f) {
                y = rand == 0 ? 1 : 4;
            }

            // Used to create empty space between levels and updates current level
            int emptyspace = 0;
            if(timer >= 120 && timer < 125){
                currentLevel = 2;
                emptyspace = 1;
            }else if(timer >= 240 && timer < 245){
                currentLevel = 3;
                emptyspace = 1;
            }else if(timer >= 360 && timer < 365){
                currentLevel = 4;
                emptyspace = 1;
            }else if(timer >= 480 && timer < 485){
                currentLevel = 5;
                emptyspace = 1;
            }else if(timer >= 0 && timer < 120){
                currentLevel = 1;
                emptyspace = 0;
            }else{
                emptyspace = 0;
            }

            if(emptyspace == 0){
            Transform h = GenerateNbackObjectInGrid(x, y, grid, tc);
            }
        }

        //GenerateGround
        ggen.GenerateGrounds (grid, tc, 0, false);

        //Generate Ceilings depending on timer

        if ((timer >= 0 && timer < 40) || (timer >= 200f && timer < 240f) || (timer >= 320f && timer < 360f) || timer >= 480f) {
            ggen.GenerateGrounds (grid, tc, 5, true);
        } else if ((timer >= 40f && timer < 80f) || (timer >= 160f && timer < 200f) || (timer >= 240f && timer < 280f)) {
            ggen.GenerateGrounds (grid, tc, 6, true);
        } else if ((timer >= 80f && timer < 160f) || (timer >= 280f && timer < 320f) || (timer >= 360f && timer < 480f)) {
            ggen.GenerateGrounds (grid, tc, 7, true);
        }
        lastGridOffset = x - grid.numCellsX;
    }
コード例 #34
0
ファイル: TerrainGenerator.cs プロジェクト: nchou001/NC-Popz
    // Use this for initialization
    void Start()
    {
        gameMngr = FindObjectOfType (typeof(PopzGameManager)) as PopzGameManager;

        // Set up references to object generators and grid
        grid = GameObject.FindGameObjectWithTag ("Grid").GetComponent<Grid> ();
        platformGen = GameObject.FindGameObjectWithTag ("PlatformGen").GetComponent<PlatformGenerator> ();
        collectibleGen = GameObject.FindGameObjectWithTag ("CollectibleGen").GetComponent<CollectibleGenerator> ();
        groundGen = GameObject.FindGameObjectWithTag ("GroundGen").GetComponent<GroundGenerator> ();
        nbackGen = FindObjectOfType (typeof(NbackGenerator)) as NbackGenerator;
        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();

        // Position generator and box collider
        Vector3 bottomLeft = Camera.main.ScreenToWorldPoint (new Vector3 (0f, 0f, 0f));
        Vector3 topRight = Camera.main.ScreenToWorldPoint (new Vector3 (Camera.main.pixelWidth, Camera.main.pixelHeight, 0f));
        bottomLeft.y = Camera.main.GetComponent<FixedHeight> ().height - (topRight.y - bottomLeft.y)/2f;
        BoxCollider2D boxCol = gameObject.GetComponent<BoxCollider2D> ();
        float boxHeight = topRight.y - bottomLeft.y;
        float boxWidth = 1f;
        boxCol.size = new Vector2 (boxWidth, boxHeight);
        boxCol.offset = new Vector2 (-boxWidth, boxHeight / 2f);
        transform.position = new Vector3(bottomLeft.x, bottomLeft.y, 0f);

        BoxCollider2D chunkBoxCol = terrainChunk.GetComponent<BoxCollider2D> ();
        float chunkBoxWidth = 2f * ((float) grid.numCellsX) * grid.cellSizeX;
        float chunkBoxHeight = topRight.y - bottomLeft.y;
        chunkBoxCol.size = new Vector2 (chunkBoxWidth, chunkBoxHeight);
        chunkBoxCol.offset = new Vector2 (chunkBoxWidth/2f, chunkBoxHeight/2f);
        chunkBoxCol.isTrigger = true;

        genPlants = false;
        genPlatforms = false;

        GenerateTerrain (transform.position);
    }
コード例 #35
0
 public void Awake()
 {
     instance = this;
 }
コード例 #36
0
ファイル: EventsManager.cs プロジェクト: gbersac/zappy_42
 void Start()
 {
     em = this.GetComponent<EventsManager> ();
     msgBox = Instantiate<MessagesBox>(msgBox);
     map = ground.GetComponent<GroundGenerator> ();
     eggs = new List<Egg> ();
     teams = new List<Team> ();
     functions = new Dictionary<string, System.Action<string>> ();
     functions.Add ("BIENVENUE", ft_bienvenue);
     functions.Add("msz", ft_mapsize);
     functions.Add("bct", ft_content_map);
     functions.Add("tna", ft_team_name);
     functions.Add("pnw", ft_new_player);
     functions.Add("ppo", ft_player_position);
     functions.Add("plv", ft_player_level);
     functions.Add("pin", ft_player_inventory);
     functions.Add("pex", ft_player_expulse);
     functions.Add("pbc", ft_player_broadcast);
     functions.Add("pic", ft_player_incantation);
     functions.Add("pie", ft_player_end_incantation);
     functions.Add("pfk", ft_player_lays);
     functions.Add("pdr", ft_player_vomit);
     functions.Add("pgt", ft_player_picks);
     functions.Add("pdi", ft_player_died);
     functions.Add("enw", ft_new_egg_pos);
     functions.Add("eht", ft_egg_born);
     functions.Add("edi", ft_egg_died);
     functions.Add("ebo", ft_player_replaces_egg);
     functions.Add("sgt", timeUnit);
     functions.Add("seg", ft_end);
     functions.Add("smg", recMessage);
     functions.Add("suc", unknownCommand);
     functions.Add("sbp", badArgs);
 }