Пример #1
0
    // Use this for initialization
	void Start () {
        srs = new List<SpriteRenderer>();
        foreach(Transform t in transform)
        {
            SpriteRenderer sr = t.GetComponent<SpriteRenderer>();
            if (sr != null)
            {
                srs.Add(sr);
            }
        }

        cFollow = Camera.main.GetComponent<CamFollow>();
        width = (cFollow.rightBounds - cFollow.leftBounds) / 2;
        zero = cFollow.leftBounds + width;

        Vector3 selfPosition = transform.position;
        selfPosition.y = (cFollow.upperBounds + cFollow.lowerBounds) / 2;
        selfPosition.x = zero;
        transform.position = selfPosition;

        for (int i = 0; i < srs.Count; i++)
        {
            Vector3 pos = srs[i].transform.position;
            pos.x = zero;
            srs[i].transform.position = pos;
        }


	}
Пример #2
0
    // public LightScript lightScript;

    //Start
    private void Start()
    {
        //zone1.SetActive(true);
        //zone2.SetActive(false);

        inUpDraft = false;
        audio     = FindObjectOfType <AudioManager>();

        creditsMenu = GameObject.Find("Credits Menu");
        creditsMenu.SetActive(false);

        //Calling Scripts
        debugLines         = GetComponent <DebugLines>();
        flyingStates       = GetComponent <FlyingStates>();
        playerCollider     = GetComponent <BoxCollider>();
        camFollow          = GetComponent <CamFollow>();
        input              = GetComponent <InputManager>();
        rotationController = GetComponent <RotationController>();
        animationScript    = GetComponent <AnimationScript>();
        loadLevel          = GetComponent <LoadLevel>();
        // lightScript.light.color = lightScript.Cavecolor;

        //boostLight.SetActive(false);
        //windStream.SetActive(false);
        flyingStates.WingStreamsOff();
        FindObjectOfType <AudioManager>().StopPlayingAudio("Boost");


        EndGameUI.SetActive(false);
    }
Пример #3
0
	void Start()
	{
		// find the server so that we can interact with it
		_server = Utility.FindComponent<Server>(Server.NAME);
		_server.ConnectionLostEvent += OnConnectionLost;
		_server.ExtensionEvent += OnResponse;

		_chat = Utility.FindComponent<ChatController>(ChatController.NAME);
	
		_cam = Camera.main.GetComponent<CamFollow>();

		LoadMap();

		// pull player image from prefs and randomly place them on the top of the map
		int type = PlayerPrefs.GetInt(Constants.PLAYER_TYPE, 0);;
		int x = Random.Range(5, 20);
		int y = Random.Range(0, -10);

		_player = CreateCharacter(type, new Vector2(x, y));

		_cam.Target = _player.gameObject;

		_otherPlayers = new Dictionary<string, Player>();

		// let the server (and other players) this player has just joined the game
		PsObject psobj = new PsObject();
		psobj.SetInt(ServerConstants.PLAYER_TYPE, type);
		psobj.SetIntArray(ServerConstants.PLAYER_POSITION, new List<int>() { x, y });

		_server.SendRequest(new ExtensionRequest(PlayerCommand.GetCommand(PlayerCommand.PlayerEnum.Start), psobj));

		_running = true;
	}
Пример #4
0
 //Use for initiation
 void Start()
 {
     cFollow = Camera.main.GetComponent<CamFollow>();
     if (Manager.instance.gameMode == Manager.GameModes.BLITZKRIEG)
         fireDelay *= 0.5f;
     playerID = GetComponent<PlayerController>().GetPlayerID();
 }
Пример #5
0
    //awake is always called, even when the attached object is set unactive. start starts as soon as it's set active
    void Awake()
    {
        s       = this;
        CamZ    = transform.position.z;
        minCamY = transform.position.y;
        leftCam = transform.position.x;



        slingshot = GameObject.FindWithTag("Slingshot");
        empty     = GameObject.FindWithTag("Empty");
        goal      = GameObject.FindWithTag("Goal");

        Debug.Log(slingshot);

        if (GO_left == null)
        {
            setEmptyToMiddle();
        }
        else
        {
            setEmptyToMiddle(GO_left, GO_right);
        }
        lastPoi = poi;
    }
 private void Start()
 {
     inside = false;
     cm     = Camera.main.gameObject.GetComponent <CameraZoomOut>();
     cf     = Camera.main.gameObject.GetComponent <CamFollow>();
     Sp1.SetActive(false);
     Sp2.SetActive(false);
     Sp3.SetActive(false);
     cm.enabled = false;
 }
Пример #7
0
    private void Awake()
    {
        // Setting up references.
        m_GroundCheck  = transform.Find("GroundCheck");
        m_CeilingCheck = transform.Find("CeilingCheck");
        m_Anim         = GetComponent <Animator>();
        m_Rigidbody2D  = GetComponent <Rigidbody2D>();

        cam_ = Camera.main.GetComponent <CamFollow>();
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        active = true;

        character  = GetComponent <ThirdPersonCharacter>();
        audio      = GetComponent <AudioSource>();
        cam        = FindObjectOfType <CamFollow>();
        cam.target = transform;
        guards     = FindObjectsOfType <GuardAI>();
        AddPrimaryTarget(transform);
    }
Пример #9
0
    private void Start()
    {
        Application.targetFrameRate = 60;
        cam               = Camera.main;
        camParent         = cam.transform.parent;
        camFollow         = camParent.GetComponent <CamFollow>();
        camFollow.enabled = false;
        player            = GameObject.FindWithTag("Player");

        mainThemeMusic.SetActive(true); //!!! PIG FARMA GİRDİĞİMİZDE BUNU KAPATIP YERİNE SAD VIOLIN'I ÇALACAĞIZ. !!!
        happyPigStartSound.SetActive(false);
        deathSound.SetActive(false);
        sadViolinEndingMusic.SetActive(false);
        coinCollectSound.SetActive(false);
    }
Пример #10
0
    // Start is called before the first frame update
    void Start()
    {
        prefabManager    = GameObject.Find("PrefabManager").GetComponent <PrefabManager> ();
        spawnManager     = GameObject.Find("SpawnManager").GetComponent <SpawnManager> ();
        inventoryManager = GameObject.Find("InventoryManager").GetComponent <InventoryManager> ();

        follow    = GameObject.Find("MainCamera").GetComponent <CamFollow> ();
        mapFollow = GameObject.Find("MapCamera").GetComponent <CamFollow> ();
        //playerStats = GameObject.Find("GameManager").GetComponent<PlayerStats>();

        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        if (!selectionUI.Equals(null))
        {
            selectionUI.FindSelectionObjects();
        }
    }
Пример #11
0
    void Awake()
    {
        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        //Variables.App.Set("name", "David Crispin");
        spawnManager     = GameObject.Find("SpawnManager").GetComponent <SpawnManager>();
        prefabManager    = GameObject.Find("PrefabManager").GetComponent <PrefabManager>();
        characterManager = GameObject.Find("CharacterManager").GetComponent <CharacterManager>();
        selectionUI.FindSelectionObjects();
        //GameObject.Find("UIManager").GetComponent<SelectionUI>().FindSelectionObjects();
        //Debug.Log("Awake");
        //if (spawnManager.findPlayer() == null)  _SpawnPlayer();
        // spawnName = "none";
        follow    = GameObject.Find("MainCamera").GetComponent <CamFollow> ();
        mapFollow = GameObject.Find("MapCamera").GetComponent <CamFollow> ();

        follow.target    = prefabManager.currentPrefab.transform;
        mapFollow.target = prefabManager.currentPrefab.transform;
        //DontDestroyOnLoad(this.gameObject);
    }
Пример #12
0
    //awake is always called, even when the attached object is set unactive. start starts as soon as it's set active
    void Awake()
    {
        s = this;
        CamZ = transform.position.z;
        minCamY = transform.position.y;
        leftCam = transform.position.x;

        slingshot = GameObject.FindWithTag ("Slingshot");
        empty = GameObject.FindWithTag ("Empty");
        goal = GameObject.FindWithTag ("Goal");

        Debug.Log (slingshot);

        if (GO_left == null) {
            setEmptyToMiddle ();
        } else {
            setEmptyToMiddle(GO_left, GO_right);
        }
        lastPoi = poi;
    }
Пример #13
0
    public void AddPlayer(int index)
    {
        Debug.Log("ADDED PLAYER");
        GameObject tempPlayer = Instantiate(playerPrefab);

        tempPlayer.transform.position    = trackPositions[index].transform.position;
        tempPlayer.transform.eulerAngles = trackPositions[index].transform.forward;
        Player p = tempPlayer.GetComponent <Player>();

        p.SetPlayerIndex(index);
        GameObject tempCam = Instantiate(cameraPrefab);

        tempCam.transform.parent = cameraList.transform;
        Destroy(tempCam.GetComponent <AudioListener>());
        CamFollow cf = tempCam.GetComponent <CamFollow>();

        cf.target        = p.camLookAt.transform;
        cf.carController = p.carController;
        players.Add(p);
        screenManager.UpdateScreenRects();
    }
Пример #14
0
    void Start()
    {
        // find the server so that we can interact with it
        _server = Utility.FindComponent <Server>(Server.NAME);
        _server.ConnectionLostEvent += OnConnectionLost;
        _server.ExtensionEvent      += OnResponse;

        _chat = Utility.FindComponent <ChatController>(ChatController.NAME);

        _cam = Camera.main.GetComponent <CamFollow>();

        LoadMap();

        // pull player image from prefs and randomly place them on the top of the map
        int type = PlayerPrefs.GetInt(Constants.PLAYER_TYPE, 0);;
        int x    = Random.Range(5, 20);
        int y    = Random.Range(0, -10);

        _player = CreateCharacter(type, new Vector2(x, y));

        _cam.Target = _player.gameObject;

        _otherPlayers = new Dictionary <string, Player>();

        // let the server (and other players) this player has just joined the game
        PsObject psobj = new PsObject();

        psobj.SetInt(ServerConstants.PLAYER_TYPE, type);
        psobj.SetIntArray(ServerConstants.PLAYER_POSITION, new List <int>()
        {
            x, y
        });

        _server.SendRequest(new ExtensionRequest(PlayerCommand.GetCommand(PlayerCommand.PlayerEnum.Start), psobj));

        _running = true;
    }
Пример #15
0
    // Use this for initialization
    IEnumerator Start()
    {
        // initialize cameras
        setupCam        = GameObject.Find("Main Camera").GetComponent <Camera>();
        playCam         = GameObject.Find("PlayCam").GetComponent <Camera>();
        playCam.enabled = false;
        playCam.GetComponent <AudioListener>().enabled = false;

        // find the spawnpoint. if it exists create a player and put it there.
        GameObject spawnPoint = GameObject.Find("SpawnPoint");

        if (null != spawnPoint)
        {
            Transform spawnPointTransform = GameObject.Find("SpawnPoint").GetComponent <Transform> ();
            this.player = (GameObject)Instantiate(Resources.Load("BubbleBoy"));
            Rigidbody playerBody = player.GetComponent <Rigidbody> ();
            playerBody.position = spawnPointTransform.position;
            playerBody.velocity = Vector3.zero;

            CamFollow follow = playCam.GetComponentInParent <CamFollow> ();
            follow.target = this.player.transform;
            follow.body   = playerBody;
        }
        else
        {
            Debug.LogWarning("Failed to get spawnpoint");
        }

        GameManager.Active = false;

        AsyncOperation async = Application.LoadLevelAdditiveAsync("UI_Scene");

        yield return(async);

        Debug.Log("Loading complete");
    }
Пример #16
0
    void Awake()         //Acontece quando o prefab é "acordado"
    {
        podeExecutar = true;
        vidas        = 5;
        almas        = 0;

        aguiaScript     = (Aguia)GetComponent(typeof(Aguia));
        oncaScript      = (Onca)GetComponent(typeof(Onca));
        tartarugaScript = (Tartaruga)GetComponent(typeof(Tartaruga));

        rb        = GetComponent <Rigidbody2D>(); //Encontra o componente Rigidbody do jogador.
        an        = GetComponentInChildren <Animator>();
        cam       = Camera.main.GetComponent <CamFollow>();
        canMove   = true;
        moveBlock = false;
        canShoot  = true;

        facingRight = true;

        force = 1500;

        groundCheckSize = new Vector2(0.4f, 0.3f);

        passosEv = FMODUnity.RuntimeManager.CreateInstance(somPassos);
        passosEv.getParameter("Andando", out andandoParam);
        passosEv.getParameter("Terreno", out terrenoParam);
        passosEv.start();

        Instantiate(gm);
        StartCoroutine(gm.habilidadesIniciais());

        Time.timeScale = 1;

        hitPlayed  = true;
        vulneravel = true;
    }
 void OnEnable()
 {
     c = (CamFollow)target;
 }
Пример #18
0
 void Start()
 {
     game = FindObjectOfType <GamePlay>();
     cam  = Camera.main.GetComponent <CamFollow>();
     map  = GetComponent <MapEdit>();
 }
Пример #19
0
 // Use this for initialization
 void Start()
 {
     Cursor.visible = false;
     death          = false;
     cam            = GameObject.Find("ThirdPersonCamera").GetComponent <CamFollow>();
 }
Пример #20
0
 private void Awake()
 {
     me = this;
     au = GetComponents <AudioSource>();
 }
Пример #21
0
    void Awake()
    {
        if (!Application.isEditor)
        {
            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.Locked;
        }

        _loadingScreen = GameObject.Instantiate(loadingScreenPrefab, new Vector3(8000, 8000, 8000), Quaternion.identity);
        _loadingScreen.gameObject.SetActive(false);

        _winPopup = GameObject.Instantiate(winPopupPrefab, Vector3.zero, Quaternion.identity);
        _winPopup.gameObject.SetActive(false);

        spawns = StageManager.instance.transform.Find("SpawnPoints").GetComponentsInChildren <Transform>().Where(x => x.name != "SpawnPoints").ToArray();

        playerInfo             = Serializacion.LoadJsonFromDisk <RegisteredPlayers>("Registered Players");
        playerInfo.playerStats = new PlayerStats[playerInfo.playerControllers.Length];
        playerCameras[playerInfo.playerControllers.Length - 2].SetActive(true);
        if (playerInfo.playerControllers.Length == 2)
        {
            for (int i = 0; i < 2; i++)
            {
                Camera c = GameObject.Find("Camera_P" + (i + 1)).GetComponent <Camera>();
                cameraTexturesForTwoPlayers[i].width = 1280;
                c.rect = new Rect(0, 0, 2, 1);
            }
        }
        else
        {
            for (int i = 0; i < 2; i++)
            {
                Camera c = GameObject.Find("Camera_P" + (i + 1)).GetComponent <Camera>();
                cameraTexturesForTwoPlayers[i].width = 640;
                c.rect = new Rect(0, 0, 1, 1);
            }
        }

        //Setting the mode!
        gameRules = Resources.Load("Scriptable Objects/GameMode_" + playerInfo.gameMode) as SO_GameRules;

        //get all the cameras
        var allCams = GameObject.FindObjectsOfType <CamFollow>().ToList();

        Utility.KnuthShuffle(spawns);

        for (int i = 0; i < playerInfo.playerControllers.Length; i++)
        {
            var URLs = Serializacion.LoadJsonFromDisk <CharacterURLs>("Player " + (playerInfo.playerControllers[i] + 1));

            //Dejo los objetos ccomo children del body por cuestiones de carga de los scripts. Assembler no debería generar problemas, ya que su parent objetivo sería el mismo.
            var player = Instantiate(Resources.Load <GameObject>("Prefabs/Bodies/" + URLs.bodyURL), spawns[i].transform.position, Quaternion.identity).GetComponent <Player>();
            var weapon = Instantiate(Resources.Load <GameObject>("Prefabs/Weapons/" + URLs.weaponURL), player.transform.position, Quaternion.identity, player.transform);
            var comp1  = Instantiate(Resources.Load <GameObject>("Prefabs/Skills/Complementary/" + URLs.complementaryURL[0]), player.transform.position, Quaternion.identity, player.transform);
            var comp2  = Instantiate(Resources.Load <GameObject>("Prefabs/Skills/Complementary/" + URLs.complementaryURL[1]), player.transform.position, Quaternion.identity, player.transform);
            var def    = Instantiate(Resources.Load <GameObject>("Prefabs/Skills/Defensive/" + URLs.defensiveURL), player.transform.position, Quaternion.identity, player.transform);

            CharacterAssembler.Assemble(player.gameObject, def, comp1, comp2, weapon);
            player.transform.forward = spawns[i].forward;

            comp1.GetComponent <ComplementarySkillBase>().RegisterInput(0);
            comp2.GetComponent <ComplementarySkillBase>().RegisterInput(1);

            player.gameObject.layer = LayerMask.NameToLayer("Player" + (playerInfo.playerControllers[i] + 1));
            player.gameObject.tag   = "Player " + (playerInfo.playerControllers[i] + 1);
            foreach (Transform t in player.transform)
            {
                t.gameObject.layer = LayerMask.NameToLayer("Player" + (playerInfo.playerControllers[i] + 1));
                t.gameObject.tag   = "Player " + (playerInfo.playerControllers[i] + 1);
            }

            player.Stats.Score  = 0;
            player.lockedByGame = true;

            player.LightsModule.SetPlayerColor(playerColors[playerInfo.playerControllers[i]]);

            CamFollow cam = allCams.Where(x => x.name == "Camera_P" + (i + 1)).First();
            allCams.Remove(cam);

            if (player.ControlModule.playerType == PlayerControlModule.PlayerType.DRONE)
            {
                cam.AssignTarget(player, player.GetCameraOffset());
            }
            else
            {
                var castedControlModule = player.ControlModule as QuadrupedControlModule;
                cam.AssignTarget(player, player.GetCameraOffset(), castedControlModule.HardcodeForCameraForward);
            }
        }

        //disable cams that are not being used
        foreach (var item in allCams)
        {
            item.gameObject.SetActive(false);
        }

        AddEvents();
        UIManager.Instance.Initialize(Players, StartFirstRound, gameRules.pointsToWin[playerInfo.playerControllers.Length - 2]);
    }
Пример #22
0
 void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     cam       = GameObject.Find("Main Camera");
     camScript = cam.GetComponent <CamFollow>();
 }
Пример #23
0
 private void Start()
 {
     camFollow = FindObjectOfType <CamFollow>();
 }
Пример #24
0
 void Start()
 {
     game   = FindObjectOfType <GamePlay>();
     player = GetComponent <Player>();
     cam    = Camera.main.GetComponent <CamFollow>();
 }
Пример #25
0
 public void Initiate()
 {
     camBG     = Instantiate(camBGPrefab, Vector3.zero, camBGPrefab.transform.rotation);
     camFollow = camBG.GetComponent <CamFollow>();
 }
Пример #26
0
 public void AssignCamera(CamFollow cam)
 {
     Cam       = cam;
     _camShake = cam.GetComponent <CameraShake>();
     GetComponent <PlayerSightingHandler>().Init();
 }
Пример #27
0
    //add timer, camera only does zoom thing after x time

    void Awake()
    {
        instance = this;
    }