Inheritance: MonoBehaviour
Beispiel #1
0
    public void resetGame()
    {
        isLive   = false;
        gameOver = false;
        if (cam.transform.position != pos4)
        {
            cam.transform.position = Vector3.Lerp(cam.transform.position, pos4, 3.0f * Time.deltaTime);
        }

        GameObject demoPlayer = GameObject.Find("ShipIcon");

        demoPlayer.tag = "shipIcon";
        LevelLogic LL = (LevelLogic)levelScreen.GetComponent(typeof(LevelLogic));

        LL.gameOver = false;

        gameOver = false;
        gameOverPrefab.SetActive(false);


        // enable the renderer
        levelScreen.SetActive(false);
        levelScreen.SetActive(true);

        highestWave = LL.currentWave;

        LL.reset();
        LL.enableTimer();
        LL.currentWave = highestWave;

        //LL.c

        isLive = true;
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        levelLogicScript = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();

        rb = GetComponent <Rigidbody2D>();

        //finds closest player
        float          distanceToClosestPlayer = Mathf.Infinity;
        PlayerMovement closestPlayer           = null;

        PlayerMovement[] allPlayers = GameObject.FindObjectsOfType <PlayerMovement>();

        foreach (PlayerMovement currentPlayer in allPlayers)
        {
            float distanceToPlayer = (currentPlayer.transform.position - transform.position).sqrMagnitude;
            if (distanceToPlayer < distanceToClosestPlayer)
            {
                distanceToClosestPlayer = distanceToPlayer;
                closestPlayer           = currentPlayer;
            }
        }

        //moves pellet towards closest player and destroys pellet after 2 seconds
        moveDirection = (closestPlayer.transform.position - transform.position).normalized * speed;
        rb.velocity   = new Vector2(moveDirection.x, moveDirection.y);
        Destroy(gameObject, 2f);
    }
 public void Start()
 {
     levelLogic = GameObject.FindGameObjectWithTag("LevelMnanager").GetComponent <LevelLogic>();
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMOD>();
     clic       = GetComponent <AudioSource>();
     //options.SetActive(false);
 }
	// Use this for initialization    
	void Start ()
	{
		if (null == levelController)
		{
			levelController = new LevelLogic();
			levelController.createEmptyLevel(16, 16);
		}
		playerController = GetComponent<PlayerMan>();

        if(LevelManager.isActive()){
            levelDescription = LevelManager.getCurrentLevel();
        }

		/* Windows-proofing the text. We assume no OS9 or earlier. *crosses fingers* */
		string csvText = levelDescription.text.Replace("\r", "");

		var lineNumber = 0;
		var columnNumber = 0;
		foreach (string line in csvText.Split('\n'))
		{
		columnNumber = 0;
		foreach (string column in line.Split(','))
		{
		addTile(columnNumber, lineNumber, column);
		++columnNumber;
		}
		++lineNumber;
		}
		GameObject.FindGameObjectWithTag("MainCamera").transform.position = new Vector3(columnNumber / 2 * gridSize, -lineNumber / 2 * gridSize, -3);
		GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().orthographicSize = Math.Max((float)columnNumber / 2 * gridSize / 16 * 9, (float)lineNumber / 2 * gridSize);
	}
Beispiel #5
0
    [SerializeField] int timesHit;     //TODO: serialized for debug purposes

    private void Start()
    {
        level       = FindObjectOfType <LevelLogic>();
        gameSession = FindObjectOfType <GameSession>();

        CountBreakableBlocks();
    }
    void Start()
    {
        operationObjectsNOT_TO_USE_JUST_TO_SEE_IN_INSPECTOR = operationObjects;

        LevelLogic.InitLevelLogic();

        initUnlocks();

        instantiatableObjects = instantiatableObjectsToSet;
        for (int i = 0; i < instantiatableObjects.Length; i++)
        {
            // Sets the actual "objectID" of each instantiatable object on the prefabs for easy access:

            // This is no longer used, syncGameState will handle the type:

            if (instantiatableObjects [i])
            {
                if (instantiatableObjects [i].GetComponent <SyncGameState> ())
                {
                    instantiatableObjects [i].GetComponent <SyncGameState> ().objectType = (byte)i;
                }
            }
        }

        // The following are only used by server:
        operationGameObjectSpawnTimes.Add(0);       // Spawn time is not used for this..
        operationGameObjectBufferedRPCs.Add(new List <object[]>());
        operationGameObjectsData.Add(null);         // Not instantiatable..
    }
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(this.gameObject);
        }

        settings = Resources.Load <PlayerSettings>("PlayerSettings");
        settings.LoadSettings();
        if (loadScene)
        {
            SceneManager.LoadScene(niveles[index].nombre, LoadSceneMode.Additive);
            currentScene = niveles[index];
        }
        else
        {
            mode = LoadSceneMode.Single;
            foreach (LevelLogic lv in niveles)
            {
                lastLv = SceneManager.GetActiveScene().name;
                if (lv.nombre == lastLv)
                {
                    currentScene = lv;
                }
            }
        }
    }
    public void GenerateDefaultLevelGrid()
    {
        CreateLevelScript();

        Grid2D grid = new Grid2D(worldSize, gridSpace);

        levelLogic = new LevelLogic(grid, gameGraphics);

        for (int x = 0; x < grid.gridSizeX; x++)
        {
            for (int y = 0; y < grid.gridSizeY; y++)
            {
                Node2D    currentNode = grid.Grid[x, y];
                BaseBrick brick       = GenerateRandomBaseBrick(currentNode.ID);
                if (brick != null)
                {
                    brick.transform.SetParent(brickGridParent);
                    brick.SwitchPositions(currentNode.worldPosition);

                    AddBrickToLevelController(brick);
                }
            }
        }
        Debug.Log("Bricks added to level controller");
        AddPathToLevelController();
    }
    public void DestroyLevel()
    {
        if (levelController != null)
        {
            if (levelController.levelBricks != null)
            {
                foreach (BaseBrick brick in levelController.levelBricks)
                {
                    DestroyImmediate(brick.gameObject);
                }
                levelController.levelBricks.Clear();

                if (levelController.safePathIDs != null)
                {
                    levelController.safePathIDs.Clear();
                }
            }
            else
            {
                Debug.LogError("Level bricks are null");
            }
        }
        else
        {
            Debug.LogError("levelController is null, cannot destroy level");
        }
        if (levelLogic != null)
        {
            levelLogic = null;
        }
        else
        {
            Debug.LogError("Level Logic is null, have you generated a level?");
        }
    }
Beispiel #10
0
    void UpdateProgress(float deltaTime)
    {
        if (m_AttemptTimer)
        {
            m_CurrentAtemptTimer -= deltaTime;

            m_Progress.SetProgress(m_CurrentAtemptTimer / LevelLogic.GetUnlockAttempTime());

            if (m_CurrentAtemptTimer < 0)
            {
                m_AttemptTimer = false;
            }
        }

        if (m_MoveNextTimer)
        {
            m_CurrMoveNextTime -= deltaTime;

            if (m_CurrMoveNextTime < 0)
            {
                m_MoveNextTimer = false;

                AskForNext();
            }
        }

        m_CurrBag.UpdateMe(deltaTime);
    }
Beispiel #11
0
    // Start is called before the first frame update
    void Start()
    {
        levelLogicScript = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
        SFX_hit.volume   = levelLogicScript.sfxVolumeSlider.value;

        existTimer = 0;
        damage     = 4;

        //GetComponent<BoxCollider2D>().enabled = false;
        //finds closest player
        float          distanceToClosestPlayer = Mathf.Infinity;
        PlayerMovement closestPlayer           = null;

        PlayerMovement[] allPlayers = GameObject.FindObjectsOfType <PlayerMovement>();

        foreach (PlayerMovement currentPlayer in allPlayers)
        {
            float distanceToPlayer = (currentPlayer.transform.position - transform.position).sqrMagnitude;
            if (distanceToPlayer < distanceToClosestPlayer)
            {
                distanceToClosestPlayer = distanceToPlayer;
                closestPlayer           = currentPlayer;
            }
        }
        weaponManagerScript = closestPlayer.GetComponent <WeaponManager>();
    }
    void Start()
    {
        levelLogic = GameObject.FindGameObjectWithTag("LevelMnanager").GetComponent <LevelLogic>();
        State      = levelLogic.mainMenuState;

        if (State == 0)
        {
            warningObj.SetActive(true);
            titleScreen.SetActive(false);
            menu1.SetActive(false);
            menu2.SetActive(false);
            menu3.SetActive(false);
            menuTesting.SetActive(false);
        }
        else if (State == 1)
        {
            warningObj.SetActive(false);
            titleScreen.SetActive(true);
            menu1.SetActive(false);
            menu2.SetActive(false);
            menu3.SetActive(false);
            menuTesting.SetActive(false);
        }
        else if (State == 2)
        {
            warningObj.SetActive(false);
            titleScreen.SetActive(false);
            menu1.SetActive(false);
            menu2.SetActive(false);
            menu3.SetActive(true);
            menuTesting.SetActive(false);
        }

        Cursor.visible = true;
    }
Beispiel #13
0
 // Start is called before the first frame update
 void Start()
 {
     levelLogicScript    = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
     attackCooldownTimer = 0;
     isMoving            = true;
     HP = 10.0f;
     breadSpriteRenderer_RedHit.enabled = false;
 }
Beispiel #14
0
 void Start()
 {
     video = GetComponent <VideoPlayer>();
     if (GameObject.Find("LevelManager") != null)
     {
         level = GameObject.Find("LevelManager").GetComponent <LevelLogic>();
     }
 }
Beispiel #15
0
 private void CountBreakableBlocks()
 {
     level = FindObjectOfType <LevelLogic>();
     if (IsBreakable())
     {
         level.AddBlock();
     }
 }
Beispiel #16
0
 void SetAttemptTimer(bool start)
 {
     m_AttemptTimer = start;
     if (start)
     {
         m_CurrentAtemptTimer = LevelLogic.GetUnlockAttempTime();
     }
 }
Beispiel #17
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "playerLaser" && collision.gameObject.name != "LaserFire")
        {
            Debug.Log("collision!");

            int damage = PlayerPrefs.GetInt("W1Damage") + 1;

            if (isVenting)
            {
                damage *= 3;
            }

            steamBotHP -= damage;

            AudioSource.PlayClipAtPoint(hitSound, transform.position);

            tk2dTextMesh dT = damageNumber.GetComponent <tk2dTextMesh>();
            dT.text = damage.ToString();


            GameObject.Instantiate(damageNumber, new Vector3(collision.transform.position.x,
                                                             collision.transform.position.y,
                                                             collision.transform.position.z), Quaternion.identity);
            if (!isVenting)
            {
                fire = true;
            }
            Destroy(collision.gameObject);

            if (steamBotHP <= 0)
            {
                if (!hasExploded)
                {
                    Transform clone = (Transform)Instantiate(explosionMesh, transform.position, Quaternion.Euler(90, 0, 0));
                    SplitMeshIntoTriangles explodeScript = (SplitMeshIntoTriangles)clone.GetComponent(typeof(SplitMeshIntoTriangles));
                    explodeScript.blowUp();
                    hasExploded = true;
                    AudioSource.PlayClipAtPoint(deathSound, transform.position);
                    GameObject  cam = GameObject.Find("tk2dCamera");
                    CameraShake cS  = (CameraShake)cam.GetComponent(typeof(CameraShake));
                    cS.shakeCam();
                }



                steamBotHP = 20;

                // give the player credit
                GameObject level = GameObject.Find("Level");
                LevelLogic LL    = level.GetComponent <LevelLogic>();
                LL.destroyCount += 1;

                Destroy(gameObject);
            }
        }
    }
Beispiel #18
0
 void Start()
 {
     levelLogic = FindObjectOfType <LevelLogic>();
     if (CompareTag("Breakable"))
     {
         levelLogic.AddBreakableBlock();
     }
     gameStatus = FindObjectOfType <GameSession>();
 }
Beispiel #19
0
    // Server side:
    void SpawnPlayer()
    {
        // Picks a spawn point here:
        GameObject sP = LevelLogic.getSpawnPoint(team);
        // Picks a spawn point here:
        GameObject playerObject = (GameObject)MonoBehaviour.Instantiate(playerObjects[team * (playerObjects.Length / 2) + classNum], sP.transform.position, sP.transform.rotation);

        playerObject.GetComponent <SyncGameState> ().playerOwner = playerOwner;
        OperationNetwork.OperationAddSyncState(playerObject);
    }
Beispiel #20
0
    // Use this for initialization
    void Start()
    {
        levelLogic = GameObject.FindGameObjectWithTag("LevelLogic").GetComponent <LevelLogic>();

        levelCompletePlay = false;

        levelComplete = Camera.main.transform.FindChild("LevelComplete").gameObject;

        levelComplete.SetActive(false);
    }
Beispiel #21
0
	void Awake()
	{
		if (_instance == null)
		{
			_instance = this;
		}
		else
		{
			Debug.LogWarning("Multiple LevelLogic objects in scene!");
		}
	}
Beispiel #22
0
 // Start is called before the first frame update
 void Start()
 {
     onCookingStation = false;
     recipeBookImage.SetActive(false);
     ESP1                 = GameObject.Find("EnemySpawnerP1").GetComponent <EnemySpawnerP1>();
     ESP2                 = GameObject.Find("EnemySpawnerP2").GetComponent <EnemySpawnerP2>();
     ESP3                 = GameObject.Find("EnemySpawnerP3").GetComponent <EnemySpawnerP3>();
     ESP4                 = GameObject.Find("EnemySpawnerP4").GetComponent <EnemySpawnerP4>();
     levelLogicScript     = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
     sceneSwitchingScript = GameObject.Find("SceneSwitchingScript").GetComponent <SceneSwitchingScript>();
 }
Beispiel #23
0
    void Start()
    {
        m_DataLoader = new DataLoader(this);
        m_LevelLogic = new LevelLogic(this);
        m_Profile    = new PlayerProfile(this);

        // m_InputManager.Init(this);
        // m_EntityManager.Init(this);

        m_GUILogic.Init(this);
    }
Beispiel #24
0
 // Start is called before the first frame update
 void Start()
 {
     levelLogicScript                      = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
     tomatoSpriteRenderer.enabled          = true;
     tomatoExplosionSpriteRenderer.enabled = false;
     isMoving    = true;
     HP          = 16.0f;
     theAnimator = GetComponent <Animator>();
     theAnimator.SetBool("tomatoIsMoving", true);
     tomatoSpriteRendererRedHit.enabled = false;
 }
Beispiel #25
0
 // Start is called before the first frame update
 void Start()
 {
     levelLogicScript = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
     timerRed         = 1;
     timerBlue        = 1;
     timerGreen       = 1;
     timerOrange      = 1;
     p1InZone         = false;
     p2InZone         = false;
     p3InZone         = false;
     p4InZone         = false;
 }
    // Use this for initialization
    void Start()
    {
        levelLogic   = GameObject.FindGameObjectWithTag("LevelMnanager").GetComponent <LevelLogic>();
        levelOptions = GameObject.FindGameObjectWithTag("LevelOptions").GetComponent <LevelOptions>();

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMOD>();
        textObj.SetActive(true);
        allChristals.SetActive(false);

        player.isLifeDecreasing = false;

        videoNumber = levelOptions.videoNumber;
    }
Beispiel #27
0
    // public PlayerProfile GetPlayerProfile(){
    //     return m_Profile;
    // }

    void Start()
    {
        m_DataLoader = new DataLoader(this);
        m_LevelLogic = new LevelLogic(this);
        // m_Profile = new PlayerProfile(this);

        m_InputManager.Init(this);
        m_Level.Init(this);
        m_EntityManager.Init(this);
        m_GUILogic.Init(this);

        // InitBackend();
        OnAuthComplete();
    }
Beispiel #28
0
 void Start()
 {
     if (!dontChangeMenu)
     {
         SetGeneralMenu();
     }
     if (GameObject.Find("LevelManager").GetComponent <LevelLogic>() != null)
     {
         level = GameObject.Find("LevelManager").GetComponent <LevelLogic>();
     }
     //if (sounds != null) sounds = GameObject.Find("LevelManager").GetComponent<PlaySound>();
     //gammaLevel = RenderSettings.ambientLight.gamma;
     AddListNames();
     SetSavedOptionsValue();
 }
Beispiel #29
0
    void Start()
    {
        m_Logic = this;

        m_LevelLogic  = new LevelLogic();
        m_PhysManager = new PhysicsManager();

        m_InputManager.Init();
        m_Level.Init();
        m_EntityManager.Init();
        m_GUILogic.Init();

        m_LevelLogic.AddGameStartListener(GameStarted);
        m_LevelLogic.AddLevelStartListener(LevelStarted);
        m_LevelLogic.AddLevelEndListener(LevelEnded);
    }
Beispiel #30
0
 // Start is called before the first frame update
 void Start()
 {
     enemySpawnerActive = false;
     inMyZone           = false;
     enemyReadyToSpawn  = false;
     //sets default enemy type to bread
     theEnemyType         = EnemyType.Enemy_enum_Bread;
     playerMovementScript = GameObject.Find("Player3").GetComponent <PlayerMovement>();
     enemySpawnTimer      = 0;
     enemySpawnLength     = 3f;
     DestroyAllEnemies();
     NotInRecipeBook();
     enemySpawner_UI.SetActive(true);
     resources_UI.SetActive(true);
     levelLogicScript = GameObject.Find("LevelLogic").GetComponent <LevelLogic>();
 }
    // Use this for initialization
    void Start()
    {
        state             = State.FADEOUT;
        temp              = tempInit;
        loadCurrentScreen = false;
        loadNextScreen    = false;
        loadNextScreen3P  = false;
        loadNextScreen4P  = false;
        color             = renderer.material.color;
        levelLogic        = GameObject.FindGameObjectWithTag("LevelLogic").
                            GetComponent <LevelLogic>();
        dataLogic = GameObject.FindGameObjectWithTag("DataLogic").
                    GetComponent <DataLogic>();

        DontDestroyOnLoad(transform.gameObject);
    }
Beispiel #32
0
    void Start()
    {
        m_Logic = this;

        dataController = new DataController();

        m_LevelLogic = new LevelLogic();
        // m_PhysManager = new PhysicsManager();

        // m_InputManager.Init();
        // m_Level.Init();
        m_GUILogic.Init();

        m_LevelLogic.AddGameStartListener(GameStarted);
        m_LevelLogic.AddLevelStartListener(LevelStarted);
        m_LevelLogic.AddLevelEndListener(LevelEnded);
    }
    // Use this for initialization
    void Start () {
        currentSeq = "";
        beat = 60.0f / bpm;
        offset = Time.time % (beat);

        // Translation of directions to move vectors
        moveList = new Dictionary<string, string>();
        moveVectors = new Dictionary<char, Vector3>();
        moveVectors['u'] = new Vector3(0, 1, 0);
        moveVectors['d'] = new Vector3(0, -1, 0);
        moveVectors['l'] = new Vector3(-1, 0, 0);
        moveVectors['r'] = new Vector3(1, 0, 0);

        string moves = moveText.text.Replace("\r","");
        foreach(string line in moves.Split('\n'))
        {
            string[] mt = line.Split(':');
            moveList[mt[1]] = mt[0];
        }
        levelLoader = GetComponent<LoadLevel>();
		levelLogic = levelLoader.GetLevelController ();
    }
Beispiel #34
0
    private void Awake()
    {
        DontDestroyOnLoad (this);

                id = PlayerPrefs.GetString ("id");
                //Debug.Log ("Level Stats Awake: Axiom " + Axiom.ToString ());
                name = PlayerPrefs.GetString ("name");
                difficulty = PlayerPrefs.GetInt ("difficulty");

                switch (difficulty) {
                case 2:
                        difficulty_scale = 3.0f;
                        break;
                case 0:
                        difficulty_scale = 1.0f;
                        break;
                default:
                        difficulty_scale = 2.0f;
                        break;
                }

                level_logic = GetComponent<LevelLogic> ();
    }
 void Start()
 {
     level_logic = GameObject.Find ("LevelLogic").GetComponent<LevelLogic> ();
 }