Inheritance: MonoBehaviour
    public List <GameObject> CreatBaseCube(BlockSpawner block, Transform transform)
    {
        List <GameObject> Cubes = new List <GameObject>();

        for (int x = 0; x < block.blockCount; x++)
        {
            a = Random.Range(-3f, 3f);

            z       = Random.Range(-1f, -4f);
            cubePos = new Vector3(
                a,
                .3f * .5f,
                z);

            GameObject cubeObje = Instantiate(cube, transform);
            cubeObje.transform.localPosition = cubePos;

            cubeObje.GetComponent <Renderer>().material.color = Color.black;
            cubeObje.transform.localScale = Vector3.one * .3f;

            Cubes.Add(cubeObje);
        }
        Debug.Log("küp sayısı " + Cubes.Count);
        return(Cubes);
    }
Example #2
0
    public Tetris(BlockSpawner spawner)
    {
        Grid      = new Transform[Width, Height + ExtraHeight];
        m_spawner = spawner;

        m_spawner.InitNextChainSlot();
    }
Example #3
0
    // Start is called before the first frame update
    private void Start()
    {
        dataSavingManager = GameObject.FindGameObjectWithTag("DataSavingManager").GetComponent<DataSavingManager>();
        uiManager = GameObject.FindGameObjectWithTag("UIManager").GetComponent<UIManager>();
        blockSpawner = GameObject.FindGameObjectWithTag("BlockSpawner").GetComponent<BlockSpawner>();

        offlineProgress = new UnityAction<object>(HandleOfflineProgress);
        EventManager.StartListening("OfflineProgress", offlineProgress);
        blockKilled = new UnityAction<object>(BlockKilled);
        EventManager.StartListening("BlockKilled", blockKilled);

        prestige = new UnityAction<object>(Prestige);
        EventManager.StartListening("Prestige", prestige);

        tryUpgrade = new UnityAction<object>(UpgradeSkill);
        EventManager.StartListening("TryUpgrade", tryUpgrade);

        UpdatePlayerMoneyAndUI((double)dataSavingManager.GetOtherValue("Money"));
        UpdatePlayerPrestigeMoneyAndUI((double)dataSavingManager.GetOtherValue("PrestigeMoney"));
        UpdatePendingPrestigeMoneyAndUI((double)dataSavingManager.GetOtherValue("PendingPrestigeMoney"));

        playerMoneyMult = (double)dataSavingManager.GetOtherValue("MoneyMultiplier");

        // Load skill dictionary into shop and ui
        uiManager.LoadSkillDescriptions(dataSavingManager.GetSkillDictionary());
        uiManager.SetSkillPanelsVisibility(dataSavingManager.GetSkillDictionary());
        uiManager.SetDamagePanelsVisibilty(dataSavingManager.GetSkillDictionary());
        LoadHelpers();
    }
Example #4
0
    void Start()
    {
        instancesTest++;
        main = this;
        Materials.init();
        random = new System.Random();

        camhandler        = new CameraHandler(transform.gameObject);
        mouseclickhandler = new MouseClickSceneHandler();

        cursorcone = GameObject.Find("cone");
        cursorcone.transform.renderer.enabled = false;

        for (int i = 0; i < 10; i++)
        {
            EntityUtil.spawnEntityAtSpawn(0, 0, random.Next(20, 30), random.Next(20, 30));
        }

        for (int i = 0; i < 10; i++)
        {
            EntityUtil.spawnEntityAtSpawn(0, 1, random.Next(10, 20), random.Next(10, 20));
        }

        EntityUtil.spawnEntityAtSpawn(1, 0, 20, 20);
        EntityUtil.spawnEntityAtSpawn(1, 1, 18, 18);

        BlockSpawner spawner  = new BlockSpawner(10, 0, 14, 1);
        BlockSpawner spawner2 = new BlockSpawner(28, 0, 24, 0);

        blocks.Add(spawner);
        blocks.Add(spawner2);
    }
    private void Awake()
    {
        // singleton design pattern
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            if (serverThread == null)
            {
                serverThread = new Thread(() => RunServer());
                serverThread.Start();
                Debug.Log("Starting server");
            }
        }

        spawner = GameObject.Find("BlockSpawner").GetComponent <BlockSpawner>();

        if (spawner == null)
        {
            serverThread.Join();
            serverThread = null;
            Debug.Log("Spawner is required.");
        }

        deathCounter = GetComponent <DeathCounter>();
    }
Example #6
0
    // Use this for initialization
    void Start()
    {
        //Start spawner
        spawnPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z) + new Vector3(0, 18, 0);
        bounds [1]    = spawnPosition.x + 3.5;
        bounds [0]    = spawnPosition.x - 3.5;

        blockSpawner   = FindObjectOfType <BlockSpawner> ();
        powerUpSpawner = FindObjectOfType <PowerUpSpawner> ();

        //Instantiate all variables to false.
        moveLeft  = false;
        moveRight = false;
        rotate    = false;

        //If the script runs on a client, spawn for that client
        if (isLocalPlayer)
        {
            FortuneWheel = Instantiate(FortuneWheel);
            FortuneWheel.transform.position = new Vector3(spawnPosition.x + 3, spawnPosition.y - 2, 0);
            fortuneWheelController          = FortuneWheel.GetComponentInChildren <FortuneWheelController> ();
            SpawnBlock();
            InvokeRepeating("SpawnPowerUp", 10f, 20f);
        }
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        if (isMovingRight)
        {
            MoveBlockRight();
        }
        else
        {
            MoveBlockLeft();
        }


        if (Input.GetKeyDown(KeyCode.Space))
        {
            blockRB.useGravity = true;
            moveSpeed          = 0;

            // Find spawner, call spawn function
            GameObject   spawner       = GameObject.Find("Block Spawner");
            BlockSpawner spawnerScript = spawner.GetComponent <BlockSpawner>();
            spawnerScript.SpawnBlock();

            Destroy(this);
        }
    }
Example #8
0
    // Start is called before the first frame update
    private void Start()
    {
        soundManager      = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>();
        dataSavingManager = GameObject.FindGameObjectWithTag("DataSavingManager").GetComponent <DataSavingManager>();
        blockSpawner      = GameObject.FindGameObjectWithTag("BlockSpawner").GetComponent <BlockSpawner>();

        playerData = dataSavingManager.GetPlayerData();
        var purchasedAbilities = dataSavingManager.GetAbilityDictionary().Values.Where(s => s.level > 0).ToList();

        purchasedPassives = purchasedAbilities.Where(a => a.abilityType == AbilityType.PASSIVE).ToList();
        purchasedActives  = purchasedAbilities.Where(a => a.abilityType == AbilityType.ACTIVE).ToList();

        transform.position = clickPos;

        finalMoveSpeed = playerData.baseMoveSpeed;

        //anim = character.GetComponent<Animator>();
        anim = gameObject.transform.GetChild(0).GetComponent <Animator>();
        //sprite = character.GetComponent<SpriteRenderer>();
        sprite = gameObject.transform.GetChild(0).GetComponent <SpriteRenderer>();

        abilityEffectsDict = new Dictionary <int, ParticleSystem>();
        appliedAbilities   = new Dictionary <string, double>();

        purchasedAbility = new UnityAction <object>(PurchasedAbility);
        EventManager.StartListening("PurchasedAbility", purchasedAbility);

        toggleAutoMove = new UnityAction <object>(ToggleAutoMove);
        EventManager.StartListening("ToggleAutoMove", toggleAutoMove);
    }
Example #9
0
    void Start()
    {
        bs             = GameObject.FindGameObjectWithTag("BlockSpawner").GetComponent <BlockSpawner>();
        cameraScript   = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <MoveCameraMobileTest>();
        playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
        blockButtons   = GameObject.FindGameObjectWithTag("BlockButtons");
        currentTime    = 0f;
        alphaTime      = 1f;

        var buttons = blockButtons.GetComponentsInChildren <Image>();

        foreach (var button in buttons)
        {
            if (!uiImages.Contains(button))
            {
                uiImages.Add(button);
            }
        }

        var gos = GameObject.FindGameObjectsWithTag("UI");

        foreach (var go in gos)
        {
            if (!uiImages.Contains(go.GetComponent <Image>()))
            {
                uiImages.Add(go.GetComponent <Image>());
            }
        }
    }
Example #10
0
 private void Awake()
 {
     blockSpawner   = FindObjectOfType <BlockSpawner>();
     _launchPreview = GetComponent <LaunchPreview>();
     _uImanager     = GetComponent <UImanager>();
     ballsReady     = PlayerPrefs.BallsReady;
     CreateBall();
 }
Example #11
0
    private void Start()
    {
        _blockManager = FindObjectOfType <BlockSpawner>();
        _inputManager = FindObjectOfType <InputManager>();
        _inputManager.BlockReleased += OnBlockReleased;

        SpawnNewBlock(0f);
    }
 public void Init(Block blockPrefab, BlockSpawner blockSpawner)
 {
     this.blockPrefab  = blockPrefab;
     this.blockSpawner = blockSpawner;
     blockSpawner.BlockPrefabChanged += OnBlockPrefabChanged;
     blockName.text    = blockPrefab.name;
     blockImage.sprite = LoadBlockPreview();
 }
Example #13
0
    // Use this for initialization
    void Start()
    {
        GameObject pool = GameObject.Find("Pool");

        blockSpawnerScript = pool.GetComponent <BlockSpawner> ();
        pools       = pool.GetComponents <Pool> ();
        elapsedTime = delayBetweenDestroy;
    }
Example #14
0
    // Start is called before the first frame update
    void Start()
    {
        //speed = 7.5f;
        rb = GetComponent <Rigidbody2D>();
        rb.freezeRotation = true;

        blocksHolder = GameObject.Find("BlockSpawner").GetComponent <BlockSpawner>();
    }
Example #15
0
    private void Awake()
    {
        launchPreview = GetComponent <LaunchPreview>();

        blockSpawner = FindObjectOfType <BlockSpawner>();

        CreateBall();
    }
Example #16
0
    private void Awake()
    {
        blockSpawner = FindObjectOfType <BlockSpawner>();
        launhPreview = GetComponent <LaunhPreview>();
        launhPreview.SetStartPoint(transform.position);
        launhPreview.SetEndPoint(transform.position);

        CreateBall();
    }
Example #17
0
 // Use this for initialization
 void Start()
 {
     currentCharacter = CharacterSwitcher.Instance.currentCharacter;
     UIController.Instance.UpdateBlocks(currentCharacter.GetComponent <CharacterBehaviour>().boxesAvailable);
     if (Instance == null)
     {
         Instance = this;
     }
 }
Example #18
0
        public TileSpawner(string Name = "", Structure Structure = null, int X = 0, int Y = 0)
        {
            this.Name            = Name;
            this.X               = X;
            this.Y               = Y;
            this.Structure       = Structure;
            this.WallSpawnerDict = new Dictionary <Vector2Int, WallSpawner>(WallSpawner.EmptyWallSpawnerDict);


            if (Structure != null)
            {
                TileSpawner OldTileSpawner = Structure.TileSpawnerArray[X, Y];
                if (OldTileSpawner != null)
                {
                    //Moves the walls that where at OldTileSpaner to this tile
                    WallSpawner UpWallSpawner    = OldTileSpawner.WallSpawnerDict[Vector2Int.up];
                    WallSpawner RightWallSpawner = OldTileSpawner.WallSpawnerDict[Vector2Int.right];
                    WallSpawner DownWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.down];
                    WallSpawner LeftWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.left];

                    if (UpWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(UpWallSpawner, this, Vector2Int.up, UpWallSpawner.Rotation);
                    }
                    if (RightWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(RightWallSpawner, this, Vector2Int.right, RightWallSpawner.Rotation);
                    }
                    if (DownWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(DownWallSpawner, this, Vector2Int.down, DownWallSpawner.Rotation);
                    }
                    if (LeftWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(LeftWallSpawner, this, Vector2Int.left, LeftWallSpawner.Rotation);
                    }

                    //If there already was a TileSpawner at (X,Y) with an ActorSpawner move the ActorSpawner to this
                    if (OldTileSpawner.ActorSpawner != null)
                    {
                        this.ActorSpawner = OldTileSpawner.ActorSpawner;
                        OldTileSpawner.ActorSpawner.TileSpawner = this;
                        OldTileSpawner.ActorSpawner             = null;
                    }
                    //If there already was a TileSpawner at (X,Y) with a |BlockSpawner move the BlockSpawner to this
                    if (OldTileSpawner.BlockSpawner != null && (this.ActorSpawner == null || OldTileSpawner.BlockSpawner.Solid == false))
                    {
                        this.BlockSpawner = Structure.TileSpawnerArray[X, Y].BlockSpawner;
                        OldTileSpawner.BlockSpawner.TileSpawner = this;
                        OldTileSpawner.BlockSpawner             = null;
                    }
                    OldTileSpawner.Structure = null;
                }

                Structure.TileSpawnerArray[X, Y] = this;
            }
        }
Example #19
0
    private void Awake() {
        if (instance == null) {
            instance = this;
        } else if (instance != this) {
            Destroy(gameObject);
        }

        blocks = new List<GameObject>();
        blockSpawner = GetComponent<BlockSpawner>();
    }
Example #20
0
    //private ObjectPool _objectPool;

    void Start()
    {
        _blockSpawner = new BlockSpawner();
        // Main Walls
        _blockSpawner.SpawnWorldWalls();
        for (int y = 0; y >= -5000; y -= 5)
        {
            _blockSpawner.SpawnLevel(y, y - 1);
        }
    }
Example #21
0
    public Quaternion ComputeRotationForPlacement( GenerateWorld World, BlockSpawner spawner, Vector3 normalOfPlacementSurface, Vector3 curDir, BlockIndex futureIndex)
    {
        Quaternion output = Quaternion.identity;

        //Gets the block prefab so we can check its properties:
        var block = spawner.SpawnType;

        //We only care about the direction, not the inclination:
        curDir.y = 0;
        curDir.Normalize();

        //Due to gimbal lock that can happen along a wall, we use a different axis and then rotate into the axis we want!
        //Thus the 270 rotation.

        Quaternion wallDirectionAxis = Quaternion.FromToRotation( Vector3.up, normalOfPlacementSurface);
        Quaternion upDirectionAxis = Quaternion.FromToRotation( Vector3.right, normalOfPlacementSurface) * Quaternion.Euler(0,270,0);
        Quaternion rotationTowardDown = wallDirectionAxis * upDirectionAxis ;

        //Is it going on the floor/ceiling: 0.2f episilon
        if ( normalOfPlacementSurface.y < -0.2f || normalOfPlacementSurface.y > 0.2f)
        {
            float angle = Vector3.Angle(Vector3.forward, curDir);
            var side = Vector3.Cross( Vector3.up, curDir);
            angle *= (side.z < 0) ? 1 : -1;

            upDirectionAxis = Quaternion.AngleAxis( angle, normalOfPlacementSurface);
            var upDirEuler = upDirectionAxis.eulerAngles;

            rotationTowardDown = wallDirectionAxis * upDirectionAxis ;

            //This adds the special rotation that the object gets when its on the floor or ceiling.
            //This exists because different objects act differently when placed.  This covers most cases!
            if ( block.SpecialRotateX90) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(90,0,0); }
            if ( block.SpecialRotateY90) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(0,90,0); }
            if ( block.SpecialRotateZ90) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(0,0,0); }

            if ( block.SpecialRotateX270) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(270,0,0); }
            if ( block.SpecialRotateY270) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(0,270,0); }
            if ( block.SpecialRotateZ270) { rotationTowardDown = rotationTowardDown  * Quaternion.Euler(0,0,270); }

        }

        Vector3 rot = rotationTowardDown.eulerAngles;

        //If the object is designed to sit only on the floor remove the x and z rotations:
        if( block.RotatesTowardWalls == false )
        {
            //Take only the y rotation.
            rot.x = 0;
            rot.z = 0;
        }

        output = Quaternion.Euler(rot);
        return output;
    }
Example #22
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Example #23
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(this);
     }
 }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != null)
     {
         Destroy(gameObject);
     }
 }
Example #25
0
 public PlayState(GraphicsDevice _graphicsDevice)
 {
     _hud = new HUD();
     _spawner = new BlockSpawner(_graphicsDevice);
     _preloader.PlayMusic(Menu._song);
     _scenery = _preloader.Load("scene");
     _pauseButton = new Button(new Vector2(150, 730), SceneManager.Scenes.PAUSED, "Pause", true);
     _unPauseButton = new Button(new Vector2(150, 200), SceneManager.Scenes.UNPAUSED, "Continue?", true);
     _quitButton = new Button(new Vector2(150, 300), SceneManager.Scenes.MENU, "Quit?", true);
     _sceneManager = SceneManager.GetInstance();
 }
Example #26
0
    // Start is called before the first frame update
    void Start()
    {
        blocksHolder = GameObject.Find("BlockSpawner").GetComponent <BlockSpawner>();
        player       = GameObject.Find("Player");
        timer        = GameObject.Find("Timer");
        highScore    = GameObject.Find("HighScore");
        deathSound   = GetComponent <AudioSource>();
        camera1      = GameObject.Find("Main Camera");
        colorChange  = GameObject.Find("Background");

        playerKilled = false;
    }
Example #27
0
    // Use this for initialization
    void Start()
    {
        spawner = GameObject.FindObjectOfType(typeof(BlockSpawner)) as BlockSpawner;

        var renderer = GetComponent <Renderer>();

        if (renderer != null)
        {
            int colorIndex = Random.Range(0, colorMaterials.Length);
            myMaterial        = colorMaterials[colorIndex];
            renderer.material = myMaterial;
        }
    }
Example #28
0
    private void SpawnBlock(bool isHeld)
    {
        if (isHeld && !m_SpawnBlockPressed)
        {
            m_SpawnBlockPressed = true;

            m_CurrentlyControlledBlock = BlockSpawner.SpawnBlock().gameObject.GetComponent <BlockMover>();
        }
        else if (!isHeld)
        {
            m_SpawnBlockPressed = false;
        }
    }
Example #29
0
    private void OnDestroy()
    {
        BlockSpawner blockSpawner      = null;
        var          spawnerGameObject = GameObject.Find("spawner");

        if (null != spawnerGameObject)
        {
            blockSpawner = spawnerGameObject.GetComponent <BlockSpawner>();
        }
        if (null != blockSpawner)
        {
            blockSpawner.DeleteFromGrid(x, y);
        }
    }
Example #30
0
    public void Init(string name)
    {
        soundManager      = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>();
        dataSavingManager = GameObject.FindGameObjectWithTag("DataSavingManager").GetComponent <DataSavingManager>();
        blockSpawner      = GameObject.FindGameObjectWithTag("BlockSpawner").GetComponent <BlockSpawner>();
        shop       = GameObject.FindGameObjectWithTag("Shop").GetComponent <Shop>();
        helperData = dataSavingManager.GetSkill(name).helperData;

        anim = character.GetComponent <Animator>();

        anim.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(helperData.helperAnimatorName);

        StartCoroutine(StartCountdown(helperData.idleTime));
    }
Example #31
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            Destroy(gameObject);
        }

        blockSpawner = GetComponent <BlockSpawner>();
    }
Example #32
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
        }

        blockSpawner  = GetComponent <BlockSpawner>();
        cubeSpawner   = GetComponent <CubeSpawner>();
        groundSpawner = GetComponent <GroundSpawner>();
    }
Example #33
0
 public virtual void SpawnABlock()
 {
     if (_spawnStuff)
     {
         int          randomIndex = Random.Range(0, _spawners.Length);
         BlockSpawner other       = (BlockSpawner)_spawners [randomIndex].GetComponent(typeof(BlockSpawner));
         if (_objectQueue.Count > 0)
         {
             other.LaunchBlock(_objectQueue.Dequeue());
         }
         else
         {
             other.LaunchBlock();
         }
     }
 }