Beispiel #1
0
 void Start()
 {
     respawnSound        = GetComponent <AudioSource>();
     playerNameTextMover = GameObject.FindObjectOfType <PlayerNameTextMover>();
     musicManager        = GameObject.FindObjectOfType <MusicManager>();
     resetManager        = GameObject.FindObjectOfType <ResetManager>();
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        PS = PlayerState.Idle;
        //Ani = GetComponent<Animator>();
        Speed     = MinSpeed;
        render    = GetComponent <SpriteRenderer>();
        rigidbody = GetComponent <Rigidbody2D>();

        wallHopeDirection.Normalize();
        wallJumpDirection.Normalize();

        SpawnPoint = transform.position;
        camera     = FindObjectOfType <CameraMove>();

        CutManager = FindObjectOfType <CutSceneManager>();

        reset = FindObjectOfType <ResetManager>();
        for (int i = 0; i < PrismCount; i++)
        {
            GameObject PrismDummy = Instantiate(prism, new Vector2(0, 0), Quaternion.identity);
            Prisms.Add(PrismDummy);
            Prisms[i].SetActive(false);
            reset.prism.Add(PrismDummy.GetComponent <Prism>());
        }
    }
Beispiel #3
0
    void OnGUI()
    {
        if (!Enabled)
        {
            return;
        }

        // Set the skin.
        GUI.skin = Skin;

        // ScaleTask the GUI stuff so that it stretches across the screen.
        float xRatio = Screen.width / 800.0f;
        float yRatio = Screen.height / 600.0f;

        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(xRatio, yRatio, 1));

        // Draw the play button
        GUIStyle centered = GUI.skin.GetStyle("Label");

        centered.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(0, 350, 800, 300), "Tap to start!", centered);

        // Detect tap
        if (Input.GetMouseButtonDown(0))
        {
            ResetManager.Reset();
        }
    }
Beispiel #4
0
    // Draw the GUI
    void OnGUI()
    {
        // Load the skin
        GUI.skin = Skin;

        // Scale the GUI stuff so that it stretches across the screen.
        float xRatio = Screen.width / 800.0f;
        float yRatio = Screen.height / 600.0f;

        GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(xRatio, yRatio, 1));

        // If the retry screen is enabled
        if (RetryScreenEnabled)
        {
            // Draw the stuff.
            if (GUI.Button(new Rect(300, 350, 200, 200), "Retry"))
            {
                ResetManager.Reset();
            }

            // Draw the wave we got to at the top.
            GUIStyle centered = GUI.skin.GetStyle("Label");
            centered.alignment = TextAnchor.MiddleCenter;
            GUI.Label(new Rect(0, 50, 800, 100), "You made it to Wave " + WaveManager.WaveNum.ToString(), centered);

            // Tell them what the furthest they ever got was
//			string tense = "";
//			if (WaveManager.WaveNum > WaveManager.GetPreviousFurthestWave()) // Make sure the tenses make sense.
//				tense = "was";
//			else
//				tense = "is";
            GUI.Label(new Rect(0, 150, 800, 200), "Your best wave: " + WaveManager.GetFurthestWave().ToString(), centered);
        }
    }
Beispiel #5
0
 void Update()
 {
     if (kb != null)
     {
         int code = kb.text.GetHashCode();
         if (code == godmodeCode)
         {
             Util.godmode       = true;
             Util.wm.hasCheated = true;
             Util.wm.saveSettings();
         }
         if (code == godmodeOffCode)
         {
             Util.godmode = false;
         }
         if (code == resetCode)
         {
             ResetManager.completeReset();
             Util.wm.hasCheated = true;
             Util.wm.saveSettings();
         }
         if (code == fpsCode)
         {
             if (fps == null)
             {
                 fps      = Instantiate(fpsPrefab);
                 fps.name = "FPS";
             }
         }
     }
 }
Beispiel #6
0
        // Start is called before the first frame update
        public override void Awake()
        {
            base.Awake();
            player          = FindObjectOfType <PlayerCharacter>();
            transitions     = TransitionManager.Instance;
            resets          = ResetManager.Instance;
            sounds          = AudioManager.Instance;
            inGameDialogs   = InGameDialogManager.Instance;
            cutsceneDialogs = CutsceneDialogManager.Instance;

            Physics2D.gravity = new Vector2(0, -gravity);


            if (initialSpawn == null)
            {
                if (player != null)
                {
                    transitions.RegisterSpawn("SCENE_START", GameObject.FindGameObjectWithTag("Player").transform.position, true);
                    transitions.setCurrentSpawn("SCENE_START");
                }
            }
            else
            {
                transitions.setCurrentSpawn(initialSpawn.name);
            }
            transitions.setCurrentScene(SceneManager.GetActiveScene().name);
        }
Beispiel #7
0
    void Start()
    {
        if (!Menu)
        {
            if (SceneManager.GetActiveScene().name == "Level01")
            {
                FindObjectOfType <TileMap> ().BuildMesh(1);
                FindObjectOfType <TileMap> ().BuildMesh(1);
            }
            else if (SceneManager.GetActiveScene().name == "Level02")
            {
                FindObjectOfType <TileMap> ().BuildMesh(2);
                FindObjectOfType <TileMap> ().BuildMesh(2);
            }
            resetMngr = FindObjectOfType(typeof(ResetManager)) as ResetManager;

            score  = GameObject.Find("ScoreText");
            scoreT = score.GetComponent <ScoreText> ();
            rstpp  = player.GetComponent <ResetPlayerParameters> () as ResetPlayerParameters;


            GameOver = gmOver.GetComponent <Image> () as Image;
            newbst   = newBest.GetComponent <Image> () as Image;

            LevelComplete = lvlcomplete.GetComponent <Text> () as Text;
            lvlcmpOverlay = lvlcompoverlay.GetComponent <Text> () as Text;

            cmpRe = compRe.GetComponent <Button> () as Button;
            cpRe  = cpRestart.GetComponent <Button> () as Button;

            _comp   = compRe.GetComponent <Image> () as Image;
            _checkp = cpRestart.GetComponent <Image> () as Image;
        }
    }
Beispiel #8
0
 // Update is called once per frame
 void Update()
 {
     if (Util.even)
     {
         transform.localScale = new Vector3((float)(1f - (ResetManager.moneyRemainingNextElixir() / ResetManager.nextElixirCost())), 1f, 1f);
         nextElixirText.GetComponent <Text>().text = "Next elixir in: $" + Util.encodeNumber(ResetManager.moneyRemainingNextElixir());
     }
 }
Beispiel #9
0
            public static void SendRecoveryEmail(string emailAddress)
            {
                long   id    = -1;
                string token = "";
                string body;

                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["Development"].ConnectionString))
                {
                    con.Open();
                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        cmd.Connection  = con;
                        cmd.CommandText = "SELECT users.UserID FROM users WHERE users.UserEmail = @email;";
                        cmd.Parameters.AddWithValue("@email", emailAddress);
                        cmd.Prepare();
                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                // Get data:
                                id    = Convert.ToInt64(reader["UserID"]);
                                token = GenerateToken();
                                body  = ResetManager.GenerateEmail(token);
                            }
                            else
                            {
                                // User doesn't exist. Send an email saying so!
                                body = ResetManager.GenerateEmail();
                            }
                        }
                    }
                    if (id != -1)
                    {
                        using (MySqlCommand cmd = new MySqlCommand())
                        {
                            cmd.Connection  = con;
                            cmd.CommandText = "INSERT INTO passwordResets (UserID, ResetHash) VALUES (@uid, @hash);";
                            cmd.Parameters.AddWithValue("@uid", id);
                            cmd.Parameters.AddWithValue("@hash", PasswordReset.ComputeHash(token));
                            cmd.Prepare();
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
                MailMessage email = new MailMessage(new MailAddress("The Gift Hub<*****@*****.**>"), new MailAddress(emailAddress));

                email.Body       = body;
                email.Subject    = "Password Reset";
                email.IsBodyHtml = true;
                using (SmtpClient sender = new SmtpClient("smtp.gmail.com", 587))
                {
                    sender.EnableSsl             = true;
                    sender.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    sender.UseDefaultCredentials = false;
                    sender.Credentials           = new NetworkCredential("*****@*****.**", Resources.emailPassword);
                    sender.Send(email);
                }
            }
Beispiel #10
0
        private void Update()
        {
            // pause.Update(Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.Escape) || Gamepad.GetButton(Gamepad.Button.Start));
            reset.Update(Input.GetKeyDown(KeyCode.R) || Gamepad.GetButton(Gamepad.Button.Y));

            if (reset.onPressed)
            {
                ResetManager.ResetAll();
            }

            if (pause.onPressed)
            {
                SuspensionManager.SetSuspendedAll(PauseManager.Toggle());
            }

            for (int i = 0; i < Inputs.players.Length; i++)
            {
                if (Inputs.players[i].join.onPressed)
                {
                    SpawnPlayer(i);
                }
            }
        }
Beispiel #11
0
    //public List<GameObject> ls = new List<GameObject> ();

    void Awake()
    {
        instance = this;
    }
 public void ResetToDebugMenu()
 {
     ResetManager reset = Instantiate <ResetManager>(resetbomb);
 }
Beispiel #13
0
    void level3()
    {
        oldwichBG.transform.FindChild("Oldwich").GetComponent <Image>().sprite      = oldwich2;
        oldwichBG.transform.FindChild("OldwichNameText").GetComponent <Text>().text = "Sandalf the Old";
        Transform lockBG = oldwichBG.transform.FindChild("LockBG");

        lockBG.gameObject.SetActive(true);
        lockBG.FindChild("LockIcon").gameObject.SetActive(false);
        lockBG.FindChild("InfoText").gameObject.SetActive(true);
        lockBG.FindChild("ResetGainText").gameObject.SetActive(true);
        lockBG.FindChild("NextElixirBar").gameObject.SetActive(true);
        lockBG.FindChild("ResetGainText").GetComponent <Text>().text = Util.encodeNumberInteger((int)ResetManager.elixirsOnReset());
    }
Beispiel #14
0
 void updateElixirCounter()
 {
     elixirCounter.GetComponent <Text>().text = Util.encodeNumberInteger((int)ResetManager.elixirsOnReset());
 }
Beispiel #15
0
 void callReset()
 {
     ResetManager.reset();
 }
Beispiel #16
0
        /// <summary>
        /// Dispatch will, given a request, return the webpage that will be shown to the user.
        /// </summary>
        /// <param name="request">The incoming HTML request, in it's entirety</param>
        /// <returns>The html to be sent back to the user. Additionally, it will also alter the response, if necessary</returns>
        public static string Dispatch(HttpListenerContext rtx)
        {
            // Check if user is logged in (via cookies?)
            HttpListenerRequest  request  = rtx.Request;
            HttpListenerResponse response = rtx.Response;
            Cookie reqLogger = request.Cookies["UserID"];
            // Get URI:
            string path = request.RawUrl;

            if (path.Contains("?") || path.Length < 2)
            {
                // there will be no img
                path = "";
            }
            User user = null;

            if (reqLogger != null)
            {
                user = new User(Convert.ToInt64(reqLogger.Value));
            }
            if (request.ContentType != null && request.ContentType.Contains("multipart/form-data"))
            {
                MultipartParser parser = new MultipartParser(request.InputStream, "image");
                if (parser.Success)
                {
                    // Image file will be saved in resources/images/users/User[UID].jpg
                    // Figure out which page user was on, engage.
                    if (request.QueryString["dest"] != null)
                    {
                        switch (request.QueryString["dest"])
                        {
                        case "dashboard":
                            return(DashboardManager.Dashboard(user));

                        case "profile":
                            // Save user image:
                            user.SaveImage(parser);
                            return(ProfileManager.ProfilePage(user));

                        default:
                            return(DashboardManager.Dashboard(user));
                        }
                    }
                    else
                    {
                        // Just return dashboard
                        return(DashboardManager.Dashboard(user));
                    }
                }
                // We have image; read! (how????)
                // We will return the same page, with new image!
            }
            if (request.HasEntityBody)
            {
                string input;
                // Read input, then dispatch accordingly
                using (StreamReader reader = new StreamReader(request.InputStream))
                {
                    input = reader.ReadToEnd();
                    NameValueCollection dict = HttpUtility.ParseQueryString(input);
                    if (dict["submit"] != null)
                    {
                        // Dispatch to correct logic:
                        switch (dict["submit"])
                        {
                        case "Logout":
                            if (request.Cookies["UserID"] != null)
                            {
                                // Logout user by removing UserID token:
                                Cookie cookie = new Cookie("UserID", "-1");
                                cookie.Expires = DateTime.Now.AddDays(-1d);
                                response.Cookies.Add(cookie);
                            }
                            return(LoginManager.Login());

                        case "Signup":
                            user = new User(dict["firstName"], dict["lastName"], dict["email"], dict["password"]);
                            user.Create();
                            return(LoginManager.SuccessSignup());

                        case "Login":
                            try
                            {
                                user = new User(dict["email"], dict["password"]);
                                Cookie logger = new Cookie("UserID", Convert.ToString(user.id));
                                response.Cookies.Add(logger);
                                response.AppendHeader("dest", "dashboard");
                                return(DashboardManager.Dashboard(user));
                            } catch (InvalidPasswordException)
                            {
                                return(LoginManager.FailLogin());
                            } catch (UserNotFoundException)
                            {
                                return(LoginManager.FailLogin());
                            }

                        case "PasswordResetRequest":
                            // POST data will have user email. Send recovery email.
                            PasswordReset.SendRecoveryEmail(dict["email"]);
                            return(ResetManager.ResetPasswordSent());

                        case "PasswordReset":
                            // Reset password and direct to login page
                            // POST data will have userID in userID input. Reset the password and let the user know.
                            long   id       = Convert.ToInt64(dict["userID"]);
                            string password = dict["password"];
                            PasswordReset.ResetPassword(id, password);
                            return(ResetManager.SuccessResetPassword());

                        default:
                            return(LoginManager.Login());
                        }
                    }
                    else
                    {
                        // If string is not empty, perhaps it is a
                        return(LoginManager.Login());
                    }
                }
            }
            else if (user == null)
            {
                // Send login page EXCEPT if requesting password reset:
                if (request.QueryString["ResetToken"] != null)
                {
                    // Get token; search DB for hash. If it exists, show reset form
                    string token = request.QueryString["ResetToken"];
                    long   id    = PasswordReset.GetUser(token);
                    // Show reset form. Form will have a hidden input with UserID?
                    return(ResetManager.CreateReset(id));
                }
                else
                {
                    return(LoginManager.Login());
                }
            }
            else if (request.QueryString["dest"] != null)
            {
                switch (request.QueryString["dest"])
                {
                case "dashboard":
                    return(DashboardManager.Dashboard(user));

                case "profile":
                    return(ProfileManager.ProfilePage(user));

                default:
                    return(DashboardManager.Dashboard(user));
                }
            }
            else if (path.Length != 0)
            {
                // Check if user is allowed to access
                // Serve back whatever's at the path (will be image):

                byte[] buffer = File.ReadAllBytes(WebServer.GeneratePath(path));
                response.ContentLength64 = buffer.Length;
                using (Stream resp = response.OutputStream)
                {
                    resp.Write(buffer, 0, buffer.Length);
                }
                return("");
            }
            else
            {
                // If logged in (but no request), just send back home page:
                return(DashboardManager.Dashboard(user));
            }
        }