示例#1
0
 void Start()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
示例#2
0
 void Start()
 {
     if (player == null)
     {
         player        = GameObject.Find("Player");
         playerWasNull = true;
     }
     this.transform.position = new Vector3(
         x: followX?player.transform.position.x + currentOffset.x: transform.position.x,
         y: followY ? player.transform.position.y + currentOffset.y : transform.position.y,
         z: this.transform.position.z
         );
     pc           = player.GetComponent <PlayerController>();
     this.target  = player;
     cameraOffset = GetComponentInChildren <CameraOffset>();
 }
示例#3
0
 void Start()
 {
     if (player == null)
     {
         player        = Resources.FindObjectsOfTypeAll <PlayerController>()[0].gameObject;
         playerWasNull = true;
     }
     this.transform.position = new Vector3(
         x: followX?player.transform.position.x + currentOffset.x: transform.position.x,
         y: followY ? player.transform.position.y + currentOffset.y : transform.position.y,
         z: this.transform.position.z
         );
     pc           = player.GetComponent <PlayerController>();
     this.target  = player;
     cameraOffset = GetComponentInChildren <CameraOffset>();
     UpdateOffset(initialOffset);
 }
示例#4
0
        // when this gets too big spin off a new controller
        public void LoadContent(Game game)
        {
            var screenCentre = new Point(game.Window.ClientBounds.Width / 2, game.Window.ClientBounds.Height / 2);
            _cameraOffset = new CameraOffset(screenCentre);

            _worldPlayer = new WorldPlayer();
            _worldPlayer.Postion = new Vector2(850, 550);
            _worldPlayerView = new WorldPlayerView(_worldPlayer);
            _worldPlayerView.LoadContent(game);
            _worldPlayerController = new WorldPlayerController(_worldPlayer);

            _worldMonsterController = new WorldMonsterController(_cameraOffset);
            _worldMonsterController.LoadContent(game);

            _map = new Map(game, @"C:\Users\Jake\Documents\Games\RPG Content\Maps\map2.xml");
            _mapView = new MapView(game, _map);

            // add views to ComponentDrawer
            _componentDrawer.MapView = _mapView;
            _componentDrawer.PlayerView = _worldPlayerView;
        }
示例#5
0
    void Start()
    {
        DisabledTime = 0;

        /*     CriticalHitEffect =  GetComponentInChildren<Vignetting>();
         *   CriticalHitEffect.blurVignette = 0;
         *   CriticalHitEffect.enabled = false;*/
        //      BlurOk = true;


        Offset = Target.GetComponent("CameraOffset") as CameraOffset;

        CameraTransform = transform;

        TargetTransform = Target.transform;

        //  CameraTransform.position = Offset.GetCameraPosition();

        /*   Vector3 dir = CameraTransform.forward;
         * dir.y = 0;
         * dir.Normalize();
         * Vector3 t = TargetTransform.position;
         * t += dir * 1.5f;
         *
         * CameraTransform.LookAt(t);*/


        CurrentFovTime   = 0;
        FovTime          = 0;
        FovStart         = 0;
        FovCameraEnd     = 0;
        BaseFov          = CurrentCameraFov = Camera.main.fieldOfView;
        FovCameraOk      = true;
        TimeScaleCurrent = 1;
        ShiftOk          = true;
    }
示例#6
0
        public Editor(GameState editing)
        {
            this.Editing = editing;
            this.Editing.HandleMessage(Messages.MapReset, null);
            if (Editing.Camera != null)
            {
                this.Editing.Camera.HandleMessage(Messages.CameraStopFollowing, null);
                while (true)
                {
                    CameraOffset offset = this.Editing.Camera.GetComponentByType <CameraOffset>();
                    if (offset != null)
                    {
                        this.Editing.Camera.RemoveComponent(offset);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            layers = new List <EditorLayer>();
            foreach (Component c in editing.Components)
            {
                if (c.Properties != null && c.Properties.GetString("editable", null) != null)
                {
                    string name = c.Properties.GetString("editable", null);
                    layers.Add(new EditorLayer(c, name + " (Properties)", LayerType.Properties, null, 0));
                    if (c is EntityLayer)
                    {
                        if (MapLoader.EntityLists.ContainsKey(c.Properties.GetString("tileList", "")))
                        {
                            layers.Add(new EditorLayer(c, name + " (Tiles)", LayerType.Tiles, MapLoader.EntityLists[c.Properties.GetString("tileList", "")], c.Properties.GetInt("tileSize", 0)));
                        }
                        if (MapLoader.EntityLists.ContainsKey(c.Properties.GetString("entityList", "")))
                        {
                            layers.Add(new EditorLayer(c, name + " (Entities)", LayerType.Entities, MapLoader.EntityLists[c.Properties.GetString("entityList", "")], 0));
                        }
                    }
                }
            }

            /*for (int i = editing.Components.Count - 1; i >= 0; i--)
             * {
             *  Component c = editing.Components[i];
             *  if (c != editing.Camera && (c.Properties == null || c.Properties.GetString("editable", null) == null))
             *      editing.RemoveComponent(c);
             * }*/

            if (layers.Count > 0)
            {
                currentLayer = 0;
                for (int i = 0; i < layers.Count; i++)
                {
                    if (layers[i].Type != LayerType.Properties)
                    {
                        currentLayer = i;
                        break;
                    }
                }
            }
            ChangeLayer();

            CreateWindows();
        }
示例#7
0
 // Use this for initialization
 void Start()
 {
     Offset          = Target.GetComponent <CameraOffset>();
     TargetTransform = Offset.transform;
 }
示例#8
0
    void Update()
    {
        if (MainMenuMenu == null)
        {
            button1      = GameObject.Find("PlayButton");
            button2      = GameObject.Find("HighScoreButton");
            button3      = GameObject.Find("OptionsButton");
            button4      = GameObject.Find("QuitButton");
            MainMenuMenu = GameObject.Find("MainMenu");
            optionsMenu  = GameObject.Find("OptionsMenu");

            animator1 = button1.GetComponent <Animator>();
            animator2 = button2.GetComponent <Animator>();
            animator3 = button3.GetComponent <Animator>();
            animator4 = button4.GetComponent <Animator>();

            optionsButton1 = GameObject.Find("CameraPos1");
            optionsButton2 = GameObject.Find("CameraPos2");
            optionsButton3 = GameObject.Find("CameraPos3");

            optionsAnimator1 = optionsButton1.GetComponent <Animator>();
            optionsAnimator2 = optionsButton2.GetComponent <Animator>();
            optionsAnimator3 = optionsButton3.GetComponent <Animator>();

            optionsMenu.SetActive(false);
        }

        if (SceneManager.GetActiveScene().name == "Menu" && MainMenuMenu.activeSelf == true)
        {
            if (im.vasen == 0 && im.oikea == 1)
            {
                if (aika > 0.5f)
                {
                    selectedOption -= 1;
                    if (selectedOption < 1)
                    {
                        selectedOption = numberOfOptions;
                    }
                    Debug.Log(selectedOption);

                    switch (selectedOption)
                    {
                    case 1:
                        aika = 0f;
                        if (!animator1.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator1.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 2:
                        aika = 0f;
                        if (!animator2.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator2.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 3:
                        aika = 0f;
                        if (!animator3.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator3.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 4:
                        aika = 0f;
                        if (!animator4.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator4.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;
                    }
                }
            }

            else if (im.vasen == 1 && im.oikea == 0)
            {
                if (aika > 0.5f)
                {
                    selectedOption += 1;
                    if (selectedOption > numberOfOptions)
                    {
                        selectedOption = 1;
                    }
                    Debug.Log(selectedOption);

                    switch (selectedOption)
                    {
                    case 1:
                        aika = 0f;
                        if (!animator1.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator1.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 2:
                        aika = 0f;
                        if (!animator2.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator2.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 3:
                        aika = 0f;
                        if (!animator3.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator3.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 4:
                        aika = 0f;
                        if (!animator4.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            animator4.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;
                    }
                }
            }
            else if (im.vasen == 1 && im.oikea == 1)
            {
                Debug.Log("Picked: " + selectedOption);

                switch (selectedOption)
                {
                case 1:
                    MainMenu.PlayGame();
                    break;

                case 2:
                    MainMenu.OpenHighScore();
                    break;

                case 3:
                    optionsMenu.SetActive(true);
                    MainMenuMenu.SetActive(false);


                    break;

                case 4:
                    MainMenu.QuitGame();
                    break;
                }
            }
        }
        if (SceneManager.GetActiveScene().name == "HighScore")
        {
            hiInput = FindObjectOfType <HiScoreInput>();
            if (im.vasen == 0 && im.oikea == 1)
            {
                if (aika > 0.5f)
                {
                    hiInput.NextAlphaBet();
                    aika = 0f;
                }
            }

            else if (im.vasen == 1 && im.oikea == 0)
            {
                if (aika > 0.5f)
                {
                    hiInput.PrevAlphaBet();
                    aika = 0f;
                }
            }
            else if (im.vasen == 1 && im.oikea == 1)
            {
                if (aika > 0.5f)
                {
                    hiInput.NextLetter();
                    aika = 0f;
                    if (hiInput.end == true)
                    {
                        SceneManager.LoadScene(0);
                        aika = 0f;
                    }
                }
            }
        }
        if (SceneManager.GetActiveScene().name == "Menu" && MainMenuMenu.activeSelf == false)
        {
            Debug.Log("123");
            if (im.vasen == 0 && im.oikea == 1)
            {
                if (aika > 0.5f)
                {
                    selectedOption -= 1;
                    if (selectedOption < 1)
                    {
                        selectedOption = numberOfOptions;
                    }
                    Debug.Log(selectedOption);

                    switch (selectedOption)
                    {
                    case 1:
                        aika = 0f;
                        if (!optionsAnimator1.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator1.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 2:
                        aika = 0f;
                        if (!optionsAnimator2.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator2.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 3:
                        aika = 0f;
                        if (!optionsAnimator3.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator3.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 4:
                        aika = 0f;
                        if (!optionsAnimator4.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator4.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;
                    }
                }
            }

            else if (im.vasen == 1 && im.oikea == 0)
            {
                if (aika > 0.5f)
                {
                    selectedOption += 1;
                    if (selectedOption > numberOfOptions)
                    {
                        selectedOption = 1;
                    }
                    Debug.Log(selectedOption);

                    switch (selectedOption)
                    {
                    case 1:
                        aika = 0f;
                        if (!optionsAnimator1.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator1.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 2:
                        aika = 0f;
                        if (!optionsAnimator2.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator2.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 3:
                        aika = 0f;
                        if (!optionsAnimator3.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator3.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;

                    case 4:
                        aika = 0f;
                        if (!optionsAnimator4.GetCurrentAnimatorStateInfo(0).IsName("MenuButtonAnimation"))
                        {
                            optionsAnimator4.Play("MenuButtonAnimation");
                            FindObjectOfType <AudioManager>().Play("Click");
                        }
                        break;
                    }
                }
            }
            else if (im.vasen == 1 && im.oikea == 1)
            {
                Debug.Log("Picked: " + selectedOption);

                switch (selectedOption)
                {
                case 1:
                    CameraOffset.UpdateCameraOffset(0);
                    break;

                case 2:
                    CameraOffset.UpdateCameraOffset(1);
                    break;

                case 3:
                    CameraOffset.UpdateCameraOffset(2);

                    break;

                case 4:
                    MainMenuMenu.SetActive(true);
                    optionsMenu.SetActive(false);
                    break;
                }
            }
        }
    }
示例#9
0
 private void Start()
 {
     _sceneCameraOffset   = sceneCamera.GetComponent <CameraOffset>();
     baseOrthographicSize = sceneCamera.orthographicSize;
 }