Exemple #1
0
 // Add food to stores, save the game, and leave the area
 void GoToScene()
 {
     StateSaver.gameState.AddFood(player.GetFoodFound());
     StateSaver.Save();
     StateSaver.gameState.curArea = StateSaver.gameState.areas [(int)togo];
     SceneManager.LoadSceneAsync(StateSaver.areas[(int)togo].name);
 }
Exemple #2
0
 public void NewGameClicked()
 {
     StateSaver.Reset();
     StartCoroutine(bout.FadeInBlack());
     StateSaver.Save();
     SceneManager.LoadSceneAsync(StateSaver.areaNames[(int)StateSaver.Area.Base]);
 }
Exemple #3
0
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         StateSaver          s  = new StateSaver();
         StateSaver.GameData gd = new StateSaver.GameData(jewels, jewelsPerSecond, buildings, upgrades,
                                                          events, jewelsPerClick, multiplier, clickMultiplier, lifetimejewels);
         s.Save(gd);
     }
 }
    // Update is called once per frame
    new void Update()
    {
        base.Update();
        if (!paused)
        {
            checkOutOfBounds();
        }
        if (!mySound.isPlaying)
        {
            mySound.clip = this.pantSound;
            mySound.loop = true;
            mySound.Play();
        }
        LayerMask    ignore = ~(1 << LayerMask.NameToLayer("Detection"));
        RaycastHit2D left   = Physics2D.Raycast(new Vector3(transform.position.x - this.GetComponent <BoxCollider2D> ().bounds.extents.x - 0.01f, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);
        RaycastHit2D middle = Physics2D.Raycast(new Vector3(transform.position.x, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);
        RaycastHit2D right  = Physics2D.Raycast(new Vector3(transform.position.x + this.GetComponent <BoxCollider2D> ().bounds.extents.x + 0.01f, transform.position.y - this.GetComponent <BoxCollider2D> ().bounds.extents.y - 0.01f, transform.position.z), Vector2.down, 0.1f, ignore);

        Vector2 velToAdd = Vector2.zero;

        if (left.rigidbody != null && left.rigidbody.isKinematic && !left.collider.isTrigger)
        {
            velToAdd = left.rigidbody.velocity;
        }
        else if (middle.rigidbody != null && middle.rigidbody.isKinematic && !middle.collider.isTrigger)
        {
            velToAdd = middle.rigidbody.velocity;
        }
        else if (right.rigidbody != null && right.rigidbody.isKinematic && !right.collider.isTrigger)
        {
            velToAdd = right.rigidbody.velocity;
        }


        bool grounded = (left && left.collider && !left.collider.isTrigger) || (middle && middle.collider && !middle.collider.isTrigger) || (right && right.collider && !right.collider.isTrigger);

        if (paused || !hasControl)
        {
            rb.velocity = Vector2.zero + velToAdd;
        }
        else
        {
            float jump_speed = 0f;
            rb.velocity = new Vector2(0.0f, rb.velocity.y) + velToAdd;
            if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKey(KeyCode.UpArrow)) && grounded)
            {
                jump_speed  = jump + (0.1f * rb.velocity.x);
                rb.velocity = velToAdd + new Vector2(rb.velocity.x, jump_speed);
            }
            else if ((Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) && rb.velocity.x < speed)
            {
                rb.velocity = velToAdd + new Vector2(speed, rb.velocity.y);
            }
            else if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) && rb.velocity.x > -speed)
            {
                rb.velocity = velToAdd + new Vector2(-speed, rb.velocity.y);
            }

            if (dialogueAvail && Input.GetKey(KeyCode.F))
            {
                dialogueAvail = false;
                activeDialogue.BeginDialogue();
            }
            else if (Input.GetKeyUp(KeyCode.E) && abilityCont.SniffAvailable())
            {
                hasControl = false;
                roomManager.RevealSniffablesInCurRoom();
            }
            else if (Input.GetKeyUp(KeyCode.Q) && abilityCont.BarkAvailable())
            {
                if (!mySound.isPlaying || mySound.clip.Equals(pantSound))
                {
                    mySound.clip = barkSound;
                    mySound.loop = false;
                    mySound.Play();
                }
                Bark();
            }
            else if (Input.GetKeyUp(KeyCode.R) && abilityCont.SaveAvailable())
            {
                StateSaver.Save();
            }
            else if (Input.GetKeyUp(KeyCode.T))
            {
                RaycastHit2D botInFront = Physics2D.Raycast(new Vector3(transform.position.x + (this.transform.localScale.x * (this.GetComponent <BoxCollider2D>().bounds.extents.x + 0.01f)), transform.position.y, transform.position.z), new Vector2(this.transform.localScale.x, 0), 1.0f);
                if (botInFront.collider != null && botInFront.transform.GetComponent <Drone> () != null && abilityCont.TakedownAvailable())
                {
                    StartCoroutine("PreformTakedown", botInFront.transform.GetComponent <Drone>());
                }
            }
            else if (Input.GetKeyUp(KeyCode.I))
            {
                abilityCont.ToggleInfo();
            }
        }


        if (rb.velocity.x < 0)
        {
            this.transform.localScale = new Vector3(-1, this.transform.localScale.y, this.transform.localScale.z);
        }
        else if (rb.velocity.x > 0)
        {
            this.transform.localScale = new Vector3(1, this.transform.localScale.y, this.transform.localScale.z);
        }
    }
Exemple #5
0
 public void LoadGameClicked()
 {
     StartCoroutine(bout.FadeInBlack());
     StateSaver.Save();
     SceneManager.LoadSceneAsync(StateSaver.areaNames[(int)StateSaver.Area.Overworld]);
 }