Example #1
0
        private void FixedUpdate()
        {
            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                CurrentGameObject.SetOpacity(0);
            }

            var shiftVector = new Vector3(OffSetAmount, OffSetAmount);

            shiftVector.Scale(transform.up);
            Vector2 screenPosition = UnityEngine.Camera.main.WorldToScreenPoint(transform.position + shiftVector);

            CurrentGameObject.transform.position = screenPosition;
            CurrentGameObject.transform.rotation = transform.rotation;

            if (_availableForKeyPress && Input.GetButtonDown("Selective Button"))
            {
                CurrentGameObject.SetOpacity(0);
                Destroy(this.gameObject);
                var player     = GameObject.FindGameObjectWithTag("Player");
                var playerItem = player.GetComponent <SimpleItem>();
                playerItem.AddItem(this.gameObject);
            }
        }
Example #2
0
        void FixedUpdate()
        {
            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                CurrentGameObject.SetOpacity(0);
            }

            var shiftVector = new Vector3(TextOffSetAmount, TextOffSetAmount);

            shiftVector.Scale(transform.up);
            Vector2 screenPosition = UnityEngine.Camera.main.WorldToScreenPoint(transform.position + shiftVector);

            CurrentGameObject.transform.position = screenPosition;
            CurrentGameObject.transform.rotation = transform.rotation;

            if (_canGoThrough && Input.GetButtonDown("Selective Button") && AvailableForKeyPress)
            {
                CurrentGameObject.SetOpacity(0);
                DontDestroyOnLoad(GameHandler.Game.Player);
                GameHandler.Game.NewLevel = true;
                GameHandler.Game.IncreaseLevel();
                GameHandler.Game.GotoNextLevel();
            }
        }
Example #3
0
 private void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         CurrentGameObject.SetOpacity(255);
         _availableForKeyPress = true;
     }
 }
Example #4
0
        private void Awake()
        {
            _availableForKeyPress = false;
            FloatingTextController.Initialize();

            // TO DO: Get Key Combination
            EnterString       = "Press E to Take";
            CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
            CurrentGameObject.SetOpacity(0);
            _availableForKeyPress = false;
        }
Example #5
0
        void Start()
        {
            FloatingTextController.Initialize();
            _numberOfEnemies = GameObject.FindGameObjectsWithTag("Enemy").Length;
            _requiredEnemy   = _numberOfEnemies / 2;

            _canGoThrough        = _requiredEnemy == 0;
            AvailableForKeyPress = false;

            EnterString       = _requiredEnemy > 0 ? "Press E [" + _requiredEnemy + " Enemy to Progress]" : "Press E";
            CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
            CurrentGameObject.SetOpacity(0);
        }
Example #6
0
        void Start()
        {
            // TO DO: Initialize At Game Handler
            FloatingTextController.Initialize();

            // TO DO: Get Key Combination
            EnterString = "Press E";
            if (RequireKey && KeyAmount > 0)
            {
                EnterString += " [Require " + (KeyAmount == 1 ? "a key" : (KeyAmount.ToString() + " keys")) + "]";
            }

            CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
            CurrentGameObject.SetOpacity(0);

            ItemRoomController    = new ItemRoomController();
            _availableForKeyPress = false;
            _itemSpawned          = GameObject.Find("ItemSpawned") != null;
        }
Example #7
0
        public void KilledEnemy()
        {
            if (_requiredEnemy > 0)
            {
                _requiredEnemy -= 1;
            }
            EnterString = _requiredEnemy > 0 ? "Press E [" + _requiredEnemy + " Enemy to Progress]" : "Press E";

            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                if (CurrentGameObject)
                {
                    CurrentGameObject.SetOpacity(0);
                }
            }
            if (CurrentGameObject)
            {
                CurrentGameObject.SetText(EnterString);
            }
            _canGoThrough = _requiredEnemy == 0;
        }
Example #8
0
        void FixedUpdate()
        {
            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                CurrentGameObject.SetOpacity(0);
            }

            var shiftVector = new Vector3(OffsetAmount, OffsetAmount);

            shiftVector.Scale(transform.up);
            Vector2 screenPosition = UnityEngine.Camera.main.WorldToScreenPoint(transform.position + shiftVector);

            CurrentGameObject.transform.position = screenPosition;
            CurrentGameObject.transform.rotation = transform.rotation;

            if (_availableForKeyPress && Input.GetButtonDown("Selective Button"))
            {
                var score = GameHandler.Game.Player.GetComponent <SimpleScore>();
                if (!_itemSpawned)
                {
                    var itemSpawned = new GameObject("ItemSpawned");
                    DontDestroyOnLoad(itemSpawned);
                    var spawnedItem = GameHandler.Game.Item.SpawnItem();
                    var copyItem    = Instantiate(spawnedItem);
                    _itemSpawned = true;
                    copyItem.SetActive(false);
                    DontDestroyOnLoad(copyItem);
                }
                if (!ReturnLevel)
                {
                    if (!RequireKey)
                    {
                        GameHandler.Game.ToItemRoom();
                        SceneManager.LoadScene("ItemRoom", LoadSceneMode.Single);
                    }
                    else
                    {
                        if (score.GetCurrentKey() >= KeyAmount)
                        {
                            score.RemoveKey(KeyAmount);
                            RequireKey  = false;
                            EnterString = "Press E";
                            CurrentGameObject.SetText(EnterString);
                            GameHandler.Game.ToItemRoom();
                            SceneManager.LoadScene("ItemRoom", LoadSceneMode.Single);
                        }
                    }
                }
                else
                {
                    GameHandler.Game.ActivatePrevWorld = true;
                    var item = GameObject.FindGameObjectWithTag("Item");
                    if (item)
                    {
                        item.SetActive(false);
                    }
                    SceneManager.LoadScene("Minimum Scene", LoadSceneMode.Single);
                }
                //Debug.Log("Button pressed");
            }
        }