Exemple #1
0
    public void OnTriggerEnter2D(Collider2D some)
    {
        if (some.gameObject.tag == "Player")
        {
            CharacterPos.setTent();

            SceneManager.LoadScene("Scenes/DarkWorld", LoadSceneMode.Single);
        }
    }
Exemple #2
0
 public void back()
 {
     Debug.Log("backed");
     CharacterPos.setTent();
     SceneManager.LoadScene("Scenes/DarkWorld", LoadSceneMode.Single);
     Bag_Fighter.b_fighter = 0;
     Bag_Wizard.b_wizard   = 0;
     Bag_Archer.b_archer   = 0;
 }
    // Update is called once per frame
    void Update()
    {
        breadtext.text = "Bread: " + Mathf.Ceil(Bag_Bread.bagbread) + "       Keys: " + keys;

        if (needBread() == true)
        {
            CharacterPos.setTent();
            SceneManager.LoadScene("Scenes/DarkWorld", LoadSceneMode.Single);
            Bag_Archer.b_archer   = 0;
            Bag_Wizard.b_wizard   = 0;
            Bag_Fighter.b_fighter = 0;
        }

        if ((Input.GetAxisRaw("Horizontal") > -0.5f) && (Input.GetAxisRaw("Horizontal") < 0.5f))
        {
            myrigidbody.velocity = new Vector2(0f, myrigidbody.velocity.y);
            ani.SetBool("Idle", true);
            ani.SetBool("Walk", false);
        }
        if ((Input.GetAxisRaw("Vertical") < 0.5f) && (Input.GetAxisRaw("Vertical") > -0.5f))
        {
            myrigidbody.velocity = new Vector2(myrigidbody.velocity.x, 0f);
            ani.SetBool("Idle", true);
            ani.SetBool("Walk", false);
        }

        if ((Input.GetAxisRaw("Horizontal") > 0.5f))
        {
            ani.SetBool("Walk", true);
            //transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") *playerSpeed *Time.deltaTime,0f,0f));
            myrigidbody.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * playerSpeed, myrigidbody.velocity.y);

            Bag_Bread.bagbread   = Bag_Bread.bagbread - 0.02f;
            transform.localScale = new Vector3(-1, 1, -1);
        }

        if ((Input.GetAxisRaw("Horizontal") < -0.5f))
        {
            ani.SetBool("Walk", true);
            //transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") *playerSpeed *Time.deltaTime,0f,0f));
            myrigidbody.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * playerSpeed, myrigidbody.velocity.y);
            Bag_Bread.bagbread   = Bag_Bread.bagbread - 0.02f;
            transform.localScale = new Vector3(1, 1, -1);
        }


        if ((Input.GetAxisRaw("Vertical") > 0.5f) || (Input.GetAxisRaw("Vertical") < -0.5f))
        {
            ani.SetBool("Walk", true);
            //transform.Translate(new Vector3(0f,Input.GetAxisRaw("Vertical") * playerSpeed * Time.deltaTime, 0f));
            myrigidbody.velocity = new Vector2(myrigidbody.velocity.x, Input.GetAxisRaw("Vertical") * playerSpeed);
            Bag_Bread.bagbread   = Bag_Bread.bagbread - 0.02f;
        }
        // anim1.SetFloat("Movex", Input.GetAxisRaw("Horizontal"));
        // anim1.SetFloat("Movey", Input.GetAxisRaw("Vertical"));
    }
Exemple #4
0
        public void ShowDialog(DialogType type, CharacterPos cPos, CharacterType chType, string text, bool isDisplayContinue, Rect rectPanel, int hatIndex, bool hideTipball = false)
        {
            if (_dialog == null)
            {
                var go = Instantiate(ResourceLoadUtils.Load <GameObject>("Framework/Core/Tutorial/Dialog/Dialog")) as GameObject;
                _dialog = go.transform as RectTransform;
                _dialog.SetParent(SwitchTransform, false);
                _dialog.localScale = Vector3.one;
            }
            _dialog.gameObject.SetActive(false);

            RectTransform root        = _dialog.Find(type.ToString()) as RectTransform;
            Text          contentText = null;

            for (int i = 0; i < _dialog.childCount; ++i)
            {
                var go = _dialog.GetChild(i).gameObject;
                go.SetActive(type.ToString() == go.name);
                if (type.ToString() == go.name)
                {
                    contentText = go.transform.Find("Background/Text").GetComponent <Text>();
                }
            }
            if (contentText)
            {
                contentText.text = text;
            }
            Transform rtrans = null;

            switch (type)
            {
            case DialogType.Anywhere:
                root.anchorMin = new Vector2(rectPanel.xMin, rectPanel.yMin);
                root.anchorMax = new Vector2(rectPanel.xMax, rectPanel.yMax);

                for (CharacterPos i = 0; i < CharacterPos.Count; ++i)
                {
                    var parentTrans = root.Find("Background/" + i.ToString() + "/Tipball");
                    parentTrans.parent.gameObject.SetActive(i == cPos);
                    if (i == cPos)
                    {
                        rtrans = parentTrans;
                        var  anchorPos = (rtrans.parent as RectTransform).anchoredPosition;
                        Rect rootRect  = UIUtils.GetRectInCanvas(GetCanvas(), root.Find("Background") as RectTransform);
                        switch (cPos)
                        {
                        case CharacterPos.BottomLeft:
                            (rtrans.parent as RectTransform).anchoredPosition = new Vector2(rootRect.width * -.3f, anchorPos.y);
                            break;

                        case CharacterPos.BottomRight:
                            (rtrans.parent as RectTransform).anchoredPosition = new Vector2(rootRect.width * .3f, anchorPos.y);
                            break;
                        }
                    }
                }
                root.Find("Background/ClickContinuePic").gameObject.SetActive(isDisplayContinue);
                break;

            case DialogType.Bottom:
                rtrans = root.Find("Background/Tipball");
                root.Find("Background/ClickContinuePic").gameObject.SetActive(isDisplayContinue);
                break;
            }
            for (int i = 0; i < _tipBalls.Length; ++i)
            {
                if ((int)chType == i && !hideTipball)
                {
                    if (_tipBalls[i] == null)
                    {
                        _tipBalls[i] = Instantiate(ResourceLoadUtils.Load <GameObject>("Framework/Core/Tutorial/Dialog/" + chType.ToString()), rtrans, false);
                    }
                    else
                    {
                        _tipBalls[i].transform.SetParent(rtrans, false);
                        _tipBalls[i].SetActive(true);
                    }
                    for (int j = 0; j < _tipBalls[i].transform.childCount; j++)
                    {
                        _tipBalls[i].transform.GetChild(j).gameObject.SetActive(hatIndex == j);
                    }
                }
                else
                {
                    if (_tipBalls[i])
                    {
                        _tipBalls[i].SetActive(false);
                    }
                }
            }

            _dialog.gameObject.SetActive(true);
            EnableParentCanvasRaycaster(_dialog);
        }
Exemple #5
0
    public void goHome()
    {
        CharacterPos.setTent();

        SceneManager.LoadScene("Scenes/DarkWorld", LoadSceneMode.Single);
    }