Пример #1
0
 public void NextLevel()
 {
     if (ScoreManager.canContinue == true)           // Have enough stars been earned?
     {
         BasicUtilities.NextLevel();
     }
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!cannotPlacePositive)
        {
            //Left click places positive ion
            if (Input.GetMouseButtonUp(0))
            {
                if (!levelEditor.CheckForObject("Button"))
                {
                    if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                    {
                        //==============If you are holding down delete, delete the nearest one============
                        if (activePositiveIons.Count > 0)
                        {
                            Vector3 mousePosition = Input.mousePosition;
                            mousePosition.z = 100.0f;
                            mousePosition   = Camera.main.ScreenToWorldPoint(mousePosition);
                            GameObject closest = BasicUtilities.findNearest(mousePosition, activePositiveIons);
                            GameObject clone   = Instantiate(deletedPosIon, closest.transform.position, closest.transform.rotation, cloneFolder.transform) as GameObject;
                            deletedIons.Add(clone);
                            if (deletedIons.Count > maxMarkers)
                            {
                                Destroy(deletedIons[0]);
                                deletedIons.RemoveAt(0);
                            }
                            DeletePositiveIon(closest);
                        }
                    }

                    if (availablePositiveIons > 0)
                    {
                        //==============If you are not holding delete, place one=============
                        if (!Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                        {
                            activePositiveIons.Add(levelEditor.CreateNewObjectAtCursor(positiveIonPrefab, "Positive"));
                            lastWasPositive = true;
                            availablePositiveIons--;
                            gameManager.GetComponent <IonTrackerScript>().ScoreTracker(); //Refrescante la puntuación en el IonTrackerScript
                        }
                    }
                }
            }
        }

        if (!cannotPlaceNegative)
        {
            //Right click places negative ion
            if (Input.GetMouseButtonUp(1))
            {
                print(IonPlacement.activePositiveIons.Count);
                if (!levelEditor.CheckForObject("Button"))
                {
                    if (activeNegativeIons.Count > 0)
                    {
                        //==============If you are holding down delete, delete the nearest one============
                        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                        {
                            Vector3 mousePosition = Input.mousePosition;
                            mousePosition.z = 100.0f;
                            mousePosition   = Camera.main.ScreenToWorldPoint(mousePosition);

                            GameObject closest = BasicUtilities.findNearest(mousePosition, activeNegativeIons);
                            GameObject clone   = Instantiate(deletedNegIon, closest.transform.position, closest.transform.rotation, cloneFolder.transform) as GameObject;
                            deletedIons.Add(clone);
                            if (deletedIons.Count > maxMarkers)
                            {
                                Destroy(deletedIons[0]);
                                deletedIons.RemoveAt(0);
                            }
                            DeleteNegativeIon(closest);
                        }
                    }


                    if (availableNegativeIons > 0)
                    {
                        //==============If you are not holding delete, place one=============
                        if (!Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
                        {
                            activeNegativeIons.Add(levelEditor.CreateNewObjectAtCursor(negativeIonPrefab, "Negative"));
                            lastWasPositive = false;
                            availableNegativeIons--;

                            gameManager.GetComponent <IonTrackerScript>().ScoreTracker(); //Refrescante la puntuación en el IonTrackerScript
                        }
                    }
                }
            }
        }

        //Escape checks to see if there are any ions active. If so, check the tag of the last one created, increment respective available ions, and destroy that ion
        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            if (activeNegativeIons.Count <= 0)
            {
                lastWasPositive = true;
            }

            if (lastWasPositive && activePositiveIons.Count > 0)
            {
                GameObject closest = activePositiveIons[(activePositiveIons.Count - 1)];
                GameObject clone   = Instantiate(deletedPosIon, closest.transform.position, closest.transform.rotation, cloneFolder.transform) as GameObject;
                deletedIons.Add(clone);
                if (deletedIons.Count > maxMarkers)
                {
                    Destroy(deletedIons[0]);
                    deletedIons.RemoveAt(0);
                }
                DeletePositiveIon(closest);
            }
            else
            {
                if (activeNegativeIons.Count > 0)
                {
                    GameObject closest = activeNegativeIons[(activeNegativeIons.Count - 1)];
                    GameObject clone   = Instantiate(deletedNegIon, closest.transform.position, closest.transform.rotation, cloneFolder.transform) as GameObject;
                    deletedIons.Add(clone);
                    if (deletedIons.Count > maxMarkers)
                    {
                        Destroy(deletedIons[0]);
                        deletedIons.RemoveAt(0);
                    }
                    DeleteNegativeIon(closest);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.LeftAlt))
        {
            DeleteAll();
        }
    }
Пример #3
0
 public void RestartLevel()
 {
     BasicUtilities.RestartLevel();
 }