示例#1
0
    void Start()
    {
        _scCamera = MainCamera.GetComponent<RtsCamera>();
        _scKeys = MainCamera.GetComponent<RtsCameraKeys>();
        _scMouse = MainCamera.GetComponent<RtsCameraMouse>();

        _scDemoMain = GetComponent<DemoMain>();
    }
示例#2
0
    void Start()
    {
        _scCamera = MainCamera.GetComponent <RtsCamera>();
        _scKeys   = MainCamera.GetComponent <RtsCameraKeys>();
        _scMouse  = MainCamera.GetComponent <RtsCameraMouse>();

        _scDemoMain = GetComponent <DemoMain>();
    }
    protected override void Init()
    {
        base.Init();

        if (base.gameObject == null)
        {
            return;
        }

        proxyTrans = transform.FindChild("TransformProxy");
        if (null == proxyTrans)
        {
            Debug.LogError("you must have TransformProxy Object in CameraManager.");
            return;
        }

        RtsCamera = proxyTrans.GetComponent <RtsCamera>();
        if (null == RtsCamera)
        {
            RtsCamera      = proxyTrans.gameObject.AddComponent <RtsCamera>();
            rtsCameraMouse = proxyTrans.gameObject.AddComponent <RtsCameraMouse>();
            rtsCameraKeys  = proxyTrans.gameObject.AddComponent <RtsCameraKeys>();
        }
        else
        {
            rtsCameraMouse = proxyTrans.GetComponent <RtsCameraMouse>();
            rtsCameraKeys  = proxyTrans.GetComponent <RtsCameraKeys>();
        }

        mainCamera = proxyTrans.GetComponentInChildren <Camera>();
        Shaker     = mainCamera.GetComponent <Thinksquirrel.Utilities.CameraShake>();
        if (null == Shaker)
        {
            Shaker = mainCamera.gameObject.AddComponent <Thinksquirrel.Utilities.CameraShake>();
        }

        if (transform.FindChild("ClickEffect") != null)
        {
            Destroy(transform.FindChild("ClickEffect"));
        }

        GameObject effParent = new GameObject("ClickEffect");

        effParent.transform.parent        = transform;
        effParent.transform.localPosition = Vector3.zero;
        effParent.transform.localScale    = Vector3.one;
        effParent.layer = LayerMask.NameToLayer("UILayer");

        TouchEff = UIHelper.CreateEffectInGame(effParent.transform, "Fx_UI_click_01", true);

        //ActiveCamEff(false);

        InitData();
    }
    //This method is used in the turn system to turn on and off all
    //of the components that the player will need now that it is his turn
    //First disables all of the other player's components
    public void EnablePlayer1()
    {
        #region Disable Player 2
        if (gmScript.turnNumber > 1)
        {
            childCam = player2Inst.transform.FindChild("Camera").gameObject;
            playerCam = childCam.gameObject.GetComponent<Camera>();
            unitCam = player2Inst.transform.FindChild("UnitCam").gameObject.GetComponent<Camera>();
            playerAudio = player2Inst.gameObject.GetComponent<AudioListener>();
            playerScript = player2Inst.gameObject.GetComponent<script_2PPlayer>();
            cam = player2Inst.gameObject.GetComponent<RtsCamera>();
            camKeys = player2Inst.gameObject.GetComponent<RtsCameraKeys>();
            camMouse = player2Inst.gameObject.GetComponent<RtsCameraMouse>();
            effectsUpdater = player2Inst.gameObject.GetComponent<RtsEffectsUpdater>();
            targetScript = player2Inst.gameObject.GetComponent<TargetMover>();
            playerView = player2Inst.gameObject.GetComponent<Camera>();

            playerScript.isMyTurn = false;
            camKeys.enabled = false;
            camMouse.enabled = false;
            cam.enabled = false;
            effectsUpdater.enabled = false;
            targetScript.enabled = false;
            playerCam.enabled = false;
            unitCam.enabled = false;
            playerAudio.enabled = false;
            playerView.enabled = false;

            playerScript.enabled = false;
        }
        #endregion

        #region Enabled Player 1
        if (mainCam != null)
        {
            mainCam = Camera.main;
            GameObject.Destroy(mainCam.gameObject);
        }
        childCam = player1Inst.transform.FindChild("Camera").gameObject;
        playerCam = childCam.gameObject.GetComponent<Camera>();
        unitCam = player1Inst.transform.FindChild("UnitCam").gameObject.GetComponent<Camera>();
        camKeys = player1Inst.gameObject.GetComponent<RtsCameraKeys>();
        camMouse = player1Inst.gameObject.GetComponent<RtsCameraMouse>();
        cam = player1Inst.gameObject.GetComponent<RtsCamera>();
        playerScript = player1Inst.gameObject.GetComponent<script_2PPlayer>();
        effectsUpdater = player1Inst.gameObject.GetComponent<RtsEffectsUpdater>();
        targetScript = player1Inst.gameObject.GetComponent<TargetMover>();
        playerAudio = player1Inst.gameObject.GetComponent<AudioListener>();
        playerView = player1Inst.gameObject.GetComponent<Camera>();

        playerAudio.enabled = true;
        camKeys.enabled = true;
        camMouse.enabled = true;
        cam.enabled = true;
        playerScript.enabled = true;
        effectsUpdater.enabled = true;
        targetScript.enabled = true;
        playerView.enabled = true;

        if (gmScript.turnNumber <= 2)
        {
            cam.MinBounds = playerMinCoords;
            cam.MaxBounds = playerMaxCoords;
            cam.LookAt = player1SpawnCoords;
        }

        playerCam.enabled = true;
        unitCam.enabled = true;
        playerScript.isMyTurn = true;
        playerScript.movesRemaining = 5;
        #endregion
    }