void Update()
        {
            if (MoonzInput.GetKeyDown(MoonzInput.RB, InputSuffix))
            {
                if (OnActionClicked != null)
                {
                    OnActionClicked.Invoke();
                }
            }

            Vector2 angle = new Vector2(MoonzInput.GetAxis("H", InputSuffix), MoonzInput.GetAxis("V", InputSuffix));

            if (Mathf.Abs(angle.x) + Mathf.Abs(angle.y) > 0.5f)
            {
                if (OnMoveAngleChanged != null)
                {
                    OnMoveAngleChanged.Invoke(angle);
                }
            }

            Vector2 angle2 = new Vector2(MoonzInput.GetAxis("FH", InputSuffix), MoonzInput.GetAxis("FV", InputSuffix));

            if (Mathf.Abs(angle2.x) + Mathf.Abs(angle2.y) > 0.5f)
            {
                if (OnRotateAngleChanged != null)
                {
                    OnRotateAngleChanged.Invoke(angle2);
                }
            }
        }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        lastChangeTime += Time.deltaTime;
        bool use = MoonzInput.GetKeyDown(MoonzInput.USE, player);

        GetComponent <Minigame> ().PlayerIsDoingAction(use);

        //if (state != 5 || lastChangeTime < 0.1) //nie chcemy za czesto zmieniac, bo get axis bedzie przychodzic co kazdego update
        //	return;

        lastChangeTime = 0;

        bool up    = false;
        bool down  = false;
        bool left  = false;
        bool right = false;

        left  = (int)MoonzInput.GetAxis("H", player) == -1;
        right = (int)MoonzInput.GetAxis("H", player) == 1;
        if (!left && !right)
        {
            up   = (int)MoonzInput.GetAxis("V", player) == 1;
            down = (int)MoonzInput.GetAxis("V", player) == -1;
        }

        if (GetComponent <Health> ().health <= 0)
        {
            return;
        }

        if (MoonzInput.GetKeyDown(MoonzInput.ARROW_UP, player))
        {
            up = true;
        }
        if (MoonzInput.GetKeyDown(MoonzInput.ARROW_DOWN, player))
        {
            down = true;
        }
        if (MoonzInput.GetKeyDown(MoonzInput.ARROW_LEFT, player))
        {
            left = true;
        }
        if (MoonzInput.GetKeyDown(MoonzInput.ARROW_RIGHT, player))
        {
            right = true;
        }

        InGamePosition pos = gameObject.GetComponent <InGamePosition> ();

        if (checkIfCanMove(pos, up, down, left, right))
        {
            pos.row    += left?1:0;
            pos.row    += right?-1:0;
            pos.column += up?1:0;
            pos.column += down?-1:0;
            if (left)
            {
                state = 2;
            }
            if (right)
            {
                state = 6;
            }
            if (up)
            {
                state = 8;
            }
            if (down)
            {
                state = 4;
            }
            Tweener.Handler handler = MakeIdle;
            if (pos != null)
            {
                Debug.Log(pos.row.ToString() + " " + pos.column.ToString());
                tweener.AddNewTween(gameObject, new Vector3(pos.column, 1, pos.row), 0.2f, handler);
            }
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (sc && critter)
        {
            //change backpack
            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_UP, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_UP);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_DOWN, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_DOWN);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_LEFT, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_LEFT);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.ARROW_RIGHT, inputSuffix))
            {
                GetComponent <Eq>().ChangeSlot(Item.SLOT_RIGHT);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.B, inputSuffix) && eq.GetShield() != null)
            {
                critter.shieldActive = !critter.shieldActive;
            }
            bubble.SetActive(critter.shieldActive && eq.GetShield() != null);

            if (MoonzInput.GetKeyDown(MoonzInput.A, inputSuffix))
            {
                if (eq.downSlot != null)
                {
                    critter.UseBuff(eq.downSlot);
                    eq.RemoveItem(eq.downSlot.GetComponent <Item>());
                }
            }

            float h = MoonzInput.GetAxis("H", inputSuffix);
            float v = MoonzInput.GetAxis("V", inputSuffix);

            float angle;
            if (Mathf.Abs(h) + Mathf.Abs(v) > 0.5f)
            {
                GetComponent <Animator>().SetInteger("animId", 0);
                angle       = Mathf.Atan2(h, v);
                sp.rotation = Quaternion.Euler(0, angle * 180 / Mathf.PI, 0);
            }
            else
            {
                GetComponent <Animator>().SetInteger("animId", 1);
            }

            sc.MoveForward(v * critter.getSpeed() * Time.deltaTime);
            sc.MoveSide(h * critter.getSpeed() * Time.deltaTime);

            float fh = MoonzInput.GetAxis("FH", inputSuffix);
            float fv = MoonzInput.GetAxis("FV", inputSuffix);
            angle = Mathf.Atan2(fh, fv);

            if (Mathf.Abs(fh) + Mathf.Abs(fv) > 0.5)
            {
                Vector3 shootDirection = Camera.main.transform.up * fv + Camera.main.transform.right * fh;
                critter.Attack(sc.position + shootDirection);
                sp.rotation = Quaternion.Euler(0, angle * 180 / Mathf.PI, 0);
            }

            if (MoonzInput.GetKeyDown(MoonzInput.RB, inputSuffix) || MoonzInput.GetKeyDown(MoonzInput.X, inputSuffix))
            {
                PickDropIfAny();
            }
        }
    }