This script allows players to switch between cameras in the cams variable. NOTE: this is mainly a debugging script used to see the whole field of play.
Inheritance: MonoBehaviour
    void SetCameraInfo(CameraValues values)
    {
        Camera cam;

        if (values.stationary)
        {
            cam = lockCamera;
            followCamera.enabled   = false;
            lockCamera.enabled     = true;
            cam.orthographicSize   = values.size;
            cam.transform.position = new Vector3(values.position.x, values.position.y, -10);
            Debug.Log("SET THE LOCK CAMERA");
        }
        else
        {
            cam = followCamera;
            followCamera.enabled = true;
            lockCamera.enabled   = false;
            cam.orthographicSize = constants.defaultCamSize;
            CameraBox box = cam.GetComponent <CameraBox>();
            box.top    = values.cameraBox.yMin;
            box.bottom = values.cameraBox.yMax;
            box.left   = values.cameraBox.xMin;
            box.right  = values.cameraBox.xMax;
            Debug.Log("SET THE FOLLOW CAMERA");
        }

        playerController.cam = cam;
    }
Example #2
0
    public LayerCoord(CameraBox box, Vector3 inBoxPoint)
    {
        this.box = box;
        this.offset = inBoxPoint;

        gameObject = new GameObject("Layer " + (int)inBoxPoint.z);
        gameObject.layer = box.transform.gameObject.layer;
        gameObject.transform.parent = box.transform;
        gameObject.transform.localPosition = ZeroInBoxPoint;
    }
Example #3
0
        void Start()
        {
            pageSound     = GetComponent <AudioSource>();
            rend          = GetComponent <Image>();
            introControls = GameObject.FindObjectOfType <IntroControls>();
            checkpoint    = GameObject.FindObjectOfType <Checkpoint>();
            cameraBox     = GameObject.FindObjectOfType <CameraBox>();
            musicManager  = GameObject.FindObjectOfType <MusicManager>();
            DisplayControls(false);
            musicManager.StopAllMusic();

            InitTexts();
        }
Example #4
0
    public PuzzlePanel(Rect rect, int subClassCode, PuzzleRecord record, TimeClient timeClient)
    {
        this.timeClient = timeClient;
        this.record = record;

        if (box == null)
        {
            Rect captureRect = new Rect(1000, 1000, PuzzleOption.BlockCountX, PuzzleOption.BlockCountY);
            box = new CameraBox("PuzzleCamera", captureRect, rect, -1, 2, 2, null, CullingLayer, timeClient);
            box.GetLayer(1).coord.SetScale(new Vector3(1, -1, 1));
            box.GetLayer(1).coord.Move(new Vector2(-(PuzzleOption.BlockCountX - 1) / 2f, (PuzzleOption.BlockCountY - 1) / 2f));
        }

        board = new Board(rect, this, BlockSpawn.GetDart(subClassCode), false, OnMatching, OnMatchStart, OnMatchFinish, timeClient);
    }
Example #5
0
    public TileLayer(CameraBox cameraBox, float depth, float y, LayerInfo layerInfo)
        : base(cameraBox, depth)
    {
        if (layerInfo == null)
        {
            Debug.LogError("must not be null");
        }

        // ddong
        float cameraWidth = 16;

        float playerLayerOffsetX = cameraBox.GetLayer(0).coord.ZeroInBoxPoint.x;
        this.initX = -playerLayerOffsetX * layerInfo.speed - cameraWidth;
        this.initY = y;
        this.layerInfo = layerInfo;

        do
        {
            AddNewTile();
        } while (lastGenRect.BottomRight.InBoxPoint.x < cameraWidth);
    }
Example #6
0
        /// <summary>
        /// Initializes a main window handler.
        /// </summary>
        /// <param name="mainCore">Application's main core.</param>
        public MainWindow(Core mainCore)
        {
            InitializeComponent();

            // Copyright Ali Deym (c) 2017-2018
            Console.WriteLine("COPYRIGH Ali Deym (c) 2017-2018");
            Text = "تدبیرگر راه - مهندسین مشاور تدبیر فرودراه";

            hasPendingProject = hasCheckedCameras = hasCheckedPorts = false;

            cameraStatusBars = new [] {
                camera1Label,
                camera2Label,
                camera3Label,
                camera4Label,
                camera5Label,
                camera6Label
            };


            appCore = mainCore;


            appCore.Trigger.OnPendingProjectReceived += ReceivedPendingProjectPacket;


            deviceList = new List <Camera> ();


            appCore.BaslerManager.RefreshDevices();

            var devices = appCore.BaslerManager.GetDeviceList();


            /* Set Camera count and change main window alignment for that. */
            CameraCount = devices.Length;

            var config = appCore.MainConfigManager.GetConfig("CameraCount");

            if (config != null)
            {
                if (int.TryParse(config, out int count))
                {
                    CameraCount = count;
                }
            }

            if (CameraCount <= 1)
            {
                SetColumnSize(1);
                SetRowSize(1);
            }
            else
            {
                SetColumnSize(2);
            }


            // Get correct row for the main panel.
            float f = CameraCount;

            SetRowSize((int)Math.Ceiling(f / 2));



            /* Detect creation of Cameras. */
            bool cam1Made, cam2Made, cam3Made, cam4Made, cam5Made, cam6Made;

            cam1Made = cam2Made = cam3Made = cam4Made = cam5Made = cam6Made = false;



            if (devices.Length > 0)
            {
                foreach (var pylonCam in devices)
                {
                    /* If there's no more slot left in main window, do not create more camera devices. */
                    if (true.AllEqual(cam1Made, cam2Made, cam3Made, cam4Made, cam5Made, cam6Made))
                    {
                        break;
                    }



                    var cam = appCore.BaslerManager.AddCamera((int)pylonCam.Index);

                    var conf = appCore.MainConfigManager.GetConfig(cam.Name);


                    if (conf == null)
                    {
                        MessageBox.Show(Language.ErrorExposure, Language.Error);
                        Environment.Exit(0);


                        return;
                    }

                    if (!int.TryParse(conf, out int exposureNumber))
                    {
                        MessageBox.Show(Language.ErrorExposure, Language.Error);
                        Environment.Exit(0);

                        return;
                    }


                    deviceList.Add(cam);

                    CameraBox cameraBox = null;

                    /* Get an available slot in camera boxes. */
                    if (!cam1Made)
                    {
                        cameraBox = cameraBox1;
                        cam1Made  = true;
                    }
                    else if (!cam2Made)
                    {
                        cameraBox = cameraBox2;
                        cam2Made  = true;
                    }
                    else if (!cam3Made)
                    {
                        cameraBox = cameraBox3;
                        cam3Made  = true;
                    }
                    else if (!cam4Made)
                    {
                        cameraBox = cameraBox4;
                        cam4Made  = true;
                    }
                    else if (!cam5Made)
                    {
                        cameraBox = cameraBox5;
                        cam5Made  = true;
                    }
                    else if (!cam6Made)
                    {
                        cameraBox = cameraBox6;
                        cam6Made  = true;
                    }


                    // In case of failure.
                    if (cameraBox == null)
                    {
                        continue;
                    }


                    // Set the picturebox's managed camera to this new created instance.
                    cameraBox.SetCamera(cam);


                    /* Handle new camera box slot and prepare it for the managed camera. */
                    cam.OnErrorReceived += OnErrorReceived;


                    cam.OnDeviceRemoved += OnDeviceRemoved;


                    cam.pictureBox = cameraBox;


                    cam.Initialize(exposureNumber);


                    // Because we moved picture box into JobWorkers, we need to initialize the camera first, and then change it's camerabox object.
                    // NO Nevermind, used master / slave format.
                    // Nevermind this.
                    // It's back top of initialize.


                    cam.ImageProvider.GrabErrorEvent += ImageProviderError;
                }
            }
        }
Example #7
0
 public Layer(CameraBox cameraBox, float depth)
 {
     coord = new LayerCoord(cameraBox, new Vector3(0, 0, depth));
     guide = new LayerGuide(this);
 }
Example #8
0
    public PuzzlePanel(Rect rect, E_HeroType heroType, E_GameModeType gameModeType, PuzzleRecord record, TimeClient timeClient)
    {
        this.timeClient = timeClient;
        this.record = record;

        if (box == null)
        {
            Rect captureRect = new Rect(1000, 1000, PuzzleOption.BlockCountX, PuzzleOption.BlockCountY);
            box = new CameraBox("PuzzleCamera", captureRect, rect, -1, 2, 2, null, CullingLayer, timeClient);
            box.GetLayer(1).coord.SetScale(new Vector3(1, -1, 1));
            box.GetLayer(1).coord.Move(new Vector2(-(PuzzleOption.BlockCountX - 1) / 2f, (PuzzleOption.BlockCountY - 1) / 2f));

            //feverGuageBack
            {
                int layer = LayerMask.NameToLayer("Field");
                camera2 = new CameraBox("PuzzleCamera2", captureRect, rect, -1, 2, 1, null, layer, timeClient);
                feverGuageBack = GameObject.Instantiate(Resources.Load("vfx50021_GUI_Summongauge01")) as GameObject;
                feverGuageBack.transform.parent = camera2.transform;
                GameObjectTool.SetLayerRecursively(feverGuageBack.transform, layer);
                SetFeverGuageRatio(0f);
            }
        }

        board = new Board(rect, this, heroType, OnMatching, OnMatchStart, OnMatchFinish, timeClient);

        AddAction(Action.E_Type.Transform_Attack1,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.ChangeBlock(ArrayTool.Create(E_BlockType.Item, E_BlockType.Gather), E_BlockType.Attack1, OnChangeBlock);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Transform_Attack2,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.ChangeBlock(ArrayTool.Create(E_BlockType.Item, E_BlockType.Gather), E_BlockType.Attack2, OnChangeBlock);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Remove_Ability,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.RemoveAll(E_BlockType.Ability, OnRemoveBlock);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Remove_Defend,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.RemoveAll(E_BlockType.Defend, OnRemoveBlock);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Remove_Item,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.RemoveAll(E_BlockType.Item, OnRemoveBlock);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Remove_Gather,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.RemoveAll(E_BlockType.Gather, OnRemoveBlock);
                return new ActionHandler.Result(null, value);
            }
        );

        /*
        Stat<BlockSpawn> stat = StatLoader.Instance.GetStatTable<E_GameModeType, BlockSpawn>("GameModeType").Get(gameModeType);
        status = new Status(null, stat, null);
        AddAction(Action.E_Type.Buff,
            delegate(float value, GameInstance firer, string[] param)
            {
                Buff.Handle onBuff = null;
                Buff.Handle onDebuff = null;
                int? buffID = Cast.To<int>(value);
                status.AddBuff(buffID.Value, firer.Stat, onBuff, onDebuff);
                return new ActionHandler.Result(null, value);
            }
        );
        AddAction(Action.E_Type.Shuffle,
            delegate(float value, GameInstance firer, string[] param)
            {
                board.Shuffle();
                return new ActionHandler.Result(null, value);
            }
        );
         * */
    }
Example #9
0
 public void Destroy()
 {
     camera2.Destroy();
     box.Destroy();
     box = null;
 }
Example #10
0
 public Field(Rect fieldArea, TimeClient timeClient)
 {
     Rect viewPortRect = fieldArea;
     Rect captureRect = new Rect(1000, 0, CaptureWidth, CaptureWidth * viewPortRect.height / viewPortRect.width);
     box = new CameraBox("FieldCamera", captureRect, viewPortRect, MinDepth, MaxDepth, -1, Color.black, LayerMask.NameToLayer("Field"), timeClient);
 }
Example #11
0
 public void Destroy()
 {
     box.Destroy();
     box = null;
 }