Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (timeLeft.timeLeft == 0 && !launch)
        {
            launch = true;
            GameManager.current.Die();
        }

        if (!launch && buttonMash.force > 10)
        {
            buttonMash.done = true;
            launch          = true;
            newDisc         = Instantiate(disc, disc.transform.position, Quaternion.Euler(0, 0, 0));
            disc.SetActive(false);
            discMover = newDisc.AddComponent <HorizontalMove>();
            discMover.movementSpeed = buttonMash.force;
            Rigidbody rb = newDisc.AddComponent <Rigidbody>();
            rb.useGravity = false;
            newDisc.GetComponent <Collider>().enabled = false;
            newDisc.AddComponent <AutoMove>();
            GameManager.current.AddPoints(100);
            return;
        }
        if (launch && currentTime < 5)
        {
            currentTime += Time.deltaTime;
        }
        else if (launch && currentTime >= 5)
        {
            GameManager.current.GetNextGame();
        }

        transform.RotateAround(transform.position, Vector3.up, buttonMash.force);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        verticalMove   = GetComponent <VerticalMove>();
        horizontalMove = GetComponent <HorizontalMove>();

        if (random)
        {
            Random.InitState((int)Time.time);
        }
    }
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            InstantPlace.Invoke();
        }

        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            HorizontalMove.Invoke(-1);
        }

        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            HorizontalMove.Invoke(1);
        }

        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            TouchClick.Invoke();
        }
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     hm  = gameObject.GetComponent <HorizontalMove>();
     ani = gameObject.GetComponent <Animator>();
 }
Ejemplo n.º 5
0
        void Update()
        {
            // mobile touch ?
            if (Input.touchCount > 0)
            {
                var touch = Input.GetTouch(0);

                switch (touch.phase)
                {
                case TouchPhase.Began:
                    Debug.Log(touch.position);

                    touched     = true;
                    forceCancel = false;
                    forceTime   = Time.time;
                    forceVector = Vector2.zero;
                    break;

                case TouchPhase.Moved:
                    if (touched)
                    {
                        if (Mathf.Abs(touch.deltaPosition.x) > Mathf.Abs(touch.deltaPosition.y) * 2f)
                        {
                            dragHorizontal += touch.deltaPosition.x * Time.deltaTime;
                            if (Math.Abs(dragHorizontal) > GameSettings.Instance.BlockSize)
                            {
                                dragHorizontal = 0;
                                forceCancel    = true;
                                HorizontalMove.Invoke(dragHorizontal > 0 ? 1 : -1);
                            }
                        }
                        else
                        {
                            if (Mathf.Abs(touch.deltaPosition.y) > Mathf.Abs(touch.deltaPosition.x) * 2)
                            {
                                forceVector += touch.deltaPosition;
                            }
                        }
                    }
                    break;

                case TouchPhase.Ended:
                    if (touched)
                    {
                        touched = false;
                        float delta = Time.time - forceTime;
                        if (delta < 0.184f)
                        {
                            TouchClick.Invoke();
                        }
                        else if (delta < 0.44f)
                        {
                            if (!forceCancel)
                            {
                                if (Mathf.Abs(forceVector.y) > Mathf.Abs(forceVector.x) * 6)
                                {
                                    InstantPlace.Invoke();
                                }
                            }
                        }
                    }

                    break;
                }
            }
        }
Ejemplo n.º 6
0
    private void Start()
    {
        PosiIni = transform.position;
        lifeIni = life;
        //if(Flying) intecSprint = 5 ;
        if (gameObject.GetComponents <AI> ().Length != 0)
        {
            minion = GetComponent <AI> ().minion;
        }
        else
        {
            minion  = true;
            itsItem = true;
        }

        m_Anim        = GetComponent <Animator>();
        m_Rigidbody2D = GetComponent <Rigidbody2D>();

        if (!(itsItem && !Flying))
        {
            Point_Atack   = transform.Find("Point_Atack");
            atack_Point_0 = Point_Atack.Find("0");
            atack_Point_1 = atack_Point_0.Find("1");

            gravityScale = m_Rigidbody2D.gravityScale;

            if (LayerMask.LayerToName(gameObject.layer) == "Character")
            {
                myEnemy_layer = LayerMask.GetMask("Enemy") | LayerMask.GetMask("InteractiveItens");
                if (transform.gameObject.name == "Char2")
                {
                    gravityScale = GameObject.Find("GM").GetComponent <Global>().gravityScale [1];
                }
                else
                {
                    gravityScale = GameObject.Find("GM").GetComponent <Global>().gravityScale [0];
                }
                m_Rigidbody2D.gravityScale = gravityScale;
            }
            else
            {
                myEnemy_layer = LayerMask.GetMask("Character");
            }

            if (Flying)
            {
                m_Rigidbody2D.gravityScale = 0f;
            }
            else
            {
                m_GroundCheck    = transform.Find("GroundCheck");
                m_WhatIsGround   = Global.WhatIsGround | LayerMask.GetMask("InteractiveItens");
                m_WhatIsPlat     = Global.WhatIsPlat;
                GroundCols       = GetComponent <CircleCollider2D> ();
                BoxCols          = GetComponent <BoxCollider2D> ();
                k_GroundedRadius = GroundCols.radius;
                m_JumpForce      = (float)Mathf.Sqrt(Mathf.Abs(2.075f * m_JumpHeight * Physics2D.gravity.y * m_Rigidbody2D.gravityScale)) * m_Rigidbody2D.mass;
            }
        }

        if (Flying)
        {
            Vertical = new VerticalFlyAction(this.gameObject);
        }
        else if (!itsItem)
        {
            Vertical = new JumpAction(this.gameObject);
        }
        if (!itsItem)
        {
            Horizontal = new HorizontalMove(this.gameObject);
        }
    }
Ejemplo n.º 7
0
    IEnumerator StartFalling(KeyData kd)
    {
        yield return(new WaitForSeconds(kd.startTime - GeneralSettings.musicStartTime + GeneralSettings.delay - GeneralSettings.fallingTime));

        //print(kd.prop["Type"] + " is falling from Exit " + kd.prop["Exit"] + " in " + kd.prop["FallingTime"]);
        int       exit = 0;
        PanelType panel = PanelType.Left;
        string    str; string[] seg;

        if (kd.prop.TryGetValue("Exit", out str))
        {
            exit = int.Parse(str);
        }
        if (kd.prop.TryGetValue("Panel", out str))
        {
            if (str == "Right")
            {
                panel = PanelType.Right;
            }
        }

        string blockType = "None";

        if (kd.prop.TryGetValue("Type", out str))
        {
            blockType = str;
        }
        if (GeneralSettings.specialMode == 1)
        {
            blockType = "FallingBlock";
        }

        // General Properties
        // if game layout needs to change
        bool generateNewExit = false;

        if (kd.prop.TryGetValue("NewExitCount", out str))
        {
            int newExitCount = int.Parse(str);
            if (newExitCount != GeneralSettings.exitCount)
            {
                GeneralSettings.exitCount = newExitCount;
                print("Change number of Exits to " + GeneralSettings.exitCount);
                generateNewExit = true;
            }
        }
        if (kd.prop.TryGetValue("NewGameMode", out str))
        {
            int newMode = int.Parse(str);
            if (newMode != GeneralSettings.mode)
            {
                GeneralSettings.mode = newMode;
                print("New game mode: " + GeneralSettings.mode);
                generateNewExit = true;
            }
        }
        if (generateNewExit)
        {
            RhythmGameManager.GenerateExits();
        }

        if (kd.prop.TryGetValue("HideBottom", out str))
        {
            if (str == "true")
            {
                RhythmGameManager.HideBottomBar();
            }
            else if (str == "false")
            {
                RhythmGameManager.HideBottomBar(false);
            }
        }
        if (kd.prop.TryGetValue("HideExits", out str))
        {
            if (str == "true")
            {
                RhythmGameManager.HideExit();
            }
            else if (str == "false")
            {
                RhythmGameManager.HideExit(false);
            }
            else
            {
                seg = str.Split(',');
                HashSet <int> set = new HashSet <int>();
                foreach (var s in seg)
                {
                    set.Add(int.Parse(s));
                }
                RhythmGameManager.HideExit(set);
            }
        }
        if (kd.prop.TryGetValue("SpecialMode", out str))
        {
            GeneralSettings.specialMode = int.Parse(str);
        }
        if (kd.prop.TryGetValue("Enable3D", out str))
        {
            if (str == "yes")
            {
                Road.ins.EnableDisplay(true);
            }
            else if (str == "no")
            {
                Road.ins.EnableDisplay(false);
            }
        }
        if (kd.prop.TryGetValue("SetParam", out str))
        {
            seg = str.Split(',');
            vEventIns.setParameterByName(seg[0], float.Parse(seg[1]));
        }
        if (kd.prop.TryGetValue("SFX", out str))
        {
            FMODUnity.RuntimeManager.PlayOneShot("event:/" + str);
        }
        if (kd.prop.TryGetValue("Image", out str))
        {
            Instantiate(Resources.Load <GameObject>(str), RhythmGameManager.ins.imageNode);
        }
        if (kd.prop.TryGetValue("VideoVolumeFadeOut", out str))
        {
            ins.StartCoroutine(FadeVideoVolume(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("MusicFadeIn", out str))
        {
            ins.StartCoroutine(MusicFadeIn(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("MusicFadeOut", out str))
        {
            ins.StartCoroutine(MusicFadeOut(float.Parse(str)));
        }
        if (kd.prop.TryGetValue("PreloadVideoClip", out str))
        {
            int    clipNum = int.Parse(str);
            int    mode    = kd.prop["Ratio"] == "16:9" ? 1 : 0;
            double time    = 0;
            if (kd.prop.TryGetValue("VideoStartTime", out str))
            {
                time = double.Parse(str);
            }
            PreloadVideo(clipNum, mode, time);
        }
        if (kd.prop.TryGetValue("ShowPreloadVideo", out str))
        {
            StartCoroutine(SetPreloadVideoActive());
        }
        if (kd.prop.TryGetValue("PlayVideoClip", out str))
        {
            int    clipNum = int.Parse(str);
            int    mode    = kd.prop["Ratio"] == "16:9" ? 1 : 0;
            double time    = 0;
            if (kd.prop.TryGetValue("VideoStartTime", out str))
            {
                time = double.Parse(str);
            }
            PlayVideo(clipNum, mode, time);
        }
        if (kd.prop.TryGetValue("PanelAlpha", out str))
        {
            Panel.alpha = float.Parse(str);
            foreach (var e in RhythmGameManager.exits)
            {
                foreach (Graphic g in e.obj.GetComponentsInChildren <Graphic>())
                {
                    Color c = g.color;
                    c.a     = Panel.alpha;
                    g.color = c;
                }
                foreach (Graphic g in e.idctor.GetComponentsInChildren <Graphic>())
                {
                    Color c = g.color;
                    c.a     = Panel.alpha;
                    g.color = c;
                }
            }
        }

        if (blockType == "GameOver")
        {
            RhythmGameManager.HideContent();
            // DebugMode.DestroyAllDebugObjects();
            Instantiate(Resources.Load <GameObject>("结算画面"), GameObject.Find("Canvas").transform);
        }
        else if (blockType == "ShowLeftPanel")
        {
            Panel.ShowLeft();
        }
        else if (blockType == "HideLeftPanel")
        {
            Panel.HideLeft();
        }
        else if (blockType == "ShowRightPanel")
        {
            Panel.ShowRight();
        }
        else if (blockType == "HideRightPanel")
        {
            Panel.HideRight();
        }
        else if (blockType == "HideBothPanels")
        {
            Panel.HideBoth();
        }

        // Generates block
        else if (blockType != "None" && (GeneralSettings.specialMode != 2 || IgnoresSpecialMode2(blockType)))
        {
            if (Harp.Contains(kd))
            {
                if (Harp.ins.rouxian)
                {
                    if (blockType == "Lyrics")
                    {
                        Harp.CreateLyrics(kd.prop["Lyrics"], float.Parse(kd.prop["TimeLast"]));
                    }
                }
            }
            else
            {
                Color c = Utils.GetRandomColor();
                if (kd.prop.TryGetValue("Color", out str))
                {
                    seg = str.Split(',');
                    c   = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255);
                }
                var block = RhythmGameManager.CreateBlock(exit, panel, blockType, c);
                block.fallingTime = GeneralSettings.fallingTime;

                if (kd.prop.TryGetValue("Note", out str))
                {
                    seg         = str.Split(',');
                    block.sound = new SoundStruct[seg.Length];
                    for (int i = 0; i < seg.Length; ++i)
                    {
                        block.sound[i].id = "MidiNotes/" + seg[i];
                    }
                }
                if (kd.prop.TryGetValue("Delays", out str))
                {
                    seg = str.Split(',');
                    if (seg.Length > 1 && seg.Length == block.sound.Length - 1)
                    {
                        float val = 0;
                        for (int i = 0; i < seg.Length; ++i)
                        {
                            float cur = float.Parse(seg[i]);
                            val += cur;
                            block.sound[i + 1].delay = val;
                        }
                    }
                    else
                    {
                        float val = float.Parse(seg[0]);
                        for (int i = 1; i < block.sound.Length; ++i)
                        {
                            block.sound[i].delay = val * i;
                        }
                    }
                }

                switch (blockType)
                {
                case "FallingBlock":
                    break;

                case "Beat":
                    Beat beat = (Beat)block;
                    if (kd.prop.TryGetValue("Position", out str))
                    {
                        seg = str.Split(',');
                        beat.rt.anchoredPosition = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    }
                    else
                    {
                        var pos = beat.rt.anchoredPosition;
                        pos.y = 0;
                        beat.rt.anchoredPosition = pos;
                    }
                    if (kd.prop.TryGetValue("Lifetime", out str))
                    {
                        beat.lifetime = int.Parse(str);
                    }
                    else
                    {
                        beat.lifetime = 2;
                    }
                    break;

                case "LongFallingBlock":
                    LongFallingBlock lfb = (LongFallingBlock)block;
                    lfb.length = int.Parse(kd.prop["Length"]);
                    break;

                case "HorizontalMove":
                    HorizontalMove hrm = (HorizontalMove)block;
                    hrm.width     = int.Parse(kd.prop["Width"]);
                    hrm.direction = kd.prop["Direction"] == "Up" ? Direction.Up : Direction.Down;
                    break;

                case "Harp":
                    Harp h = (Harp)block;
                    h.width    = int.Parse(kd.prop["Width"]);
                    h.timeLast = float.Parse(kd.prop["TimeLast"]);
                    if (kd.prop.TryGetValue("Rouxian", out str))
                    {
                        h.rouxian = str == "yes";
                    }
                    if (h.rouxian)
                    {
                        str = kd.prop["Roufa"];
                        if (str == "deep")
                        {
                            h.roufa = 0;
                        }
                        else if (str == "shallow")
                        {
                            h.roufa = 1;
                        }
                        str = kd.prop["Rousu"];
                        if (str == "quick")
                        {
                            h.rousu = 0;
                        }
                        else if (str == "slow")
                        {
                            h.rousu = 1;
                        }
                        if (kd.prop.TryGetValue("LimitTime", out str))
                        {
                            h.limitTime = float.Parse(str);
                        }
                        else
                        {
                            h.limitTime = 0.5f;
                        }
                        if (kd.prop.TryGetValue("Cooldown", out str))
                        {
                            h.cooldown = float.Parse(str);
                        }
                        else
                        {
                            h.cooldown = 0.6f;
                        }
                    }
                    break;

                case "VocalText":
                    VocalText vt = (VocalText)block;
                    if (kd.prop.TryGetValue("Text", out str))
                    {
                        vt.text = str;
                    }
                    seg             = kd.prop["StartPosition"].Split(',');
                    vt.startPos     = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    seg             = kd.prop["EndPosition"].Split(',');
                    vt.endPos       = new Vector2(float.Parse(seg[0]) * DefRes.x, float.Parse(seg[1]) * DefRes.y);
                    vt.rotation     = int.Parse(kd.prop["Rotation"]);
                    vt.beatInterval = float.Parse(kd.prop["BeatInterval"]);
                    vt.voEvent      = kd.prop["Voice"];
                    vt.length       = int.Parse(kd.prop["Length"]);
                    vt.num          = int.Parse(kd.prop["Num"]);
                    if (kd.prop.TryGetValue("AnimColor", out str))
                    {
                        seg          = str.Split(',');
                        vt.animColor = new Color32(byte.Parse(seg[0]), byte.Parse(seg[1]), byte.Parse(seg[2]), 255);
                    }
                    if (kd.prop.TryGetValue("MaxMiss", out str))
                    {
                        vt.maxMiss = int.Parse(str);
                    }
                    else
                    {
                        vt.maxMiss = 1;
                    }
                    if (kd.prop.TryGetValue("BeatLifetime", out str))
                    {
                        vt.beatLifetime = int.Parse(str);
                    }
                    else
                    {
                        vt.beatLifetime = 2;
                    }
                    if (kd.prop.TryGetValue("NoAnim", out str))
                    {
                        if (str == "yes")
                        {
                            vt.noAnim = true;
                        }
                    }
                    break;

                default:
                    break;
                }
                OnBlockCreated?.Invoke(block);
            }
        }
    }