コード例 #1
0
 public void Play()
 {
     State = lvlState.Play;
     SwipeControl.ResetFp();
     SwipeControl.BlockSwipeInput();
     StartPage.SetActive(false);
 }
コード例 #2
0
ファイル: MapData.cs プロジェクト: IpatovMA/BlockPavement
    private void Update()
    {
        if (LevelManager.State != LevelManager.lvlState.Play)
        {
            return;
        }

        if (DS.GetComponent <DarkScreenControl>().Dark&& Map != null && player == null)
        {
            DestroyMap();
        }
        if (Map == null)
        {
            LoadMap();
            player.SetActive(false);
            lvlPart++;
        }

        if (player == null)
        {
            return;
        }
        rt = player.transform.Find("playeralign");

        if (player.activeSelf == false)
        {
            player.SetActive(true);
        }
        if (TotalBlockCount == GetComponentInChildren <PlayerControl>().DoneBlockCount)
        {
            SwipeControl.BlockSwipeInput();
            Destroy(player);
            StartBaloons();
            if ((LevelManager.State != LevelManager.lvlState.Fin) && (lvlPart == 3))
            {
                LevelManager.State = LevelManager.lvlState.Fin;
                lvlPart            = 1;
            }
            else
            {
                DS.SetTrigger("Disappear");
            }
        }
    }
コード例 #3
0
    void FixedUpdate()
    {
        if (!IsInGame())
        {
            var map = GetComponentInParent <MapData>();
            SwipeControl.BlockSwipeInput();
            map.player = Instantiate(map.PlayerPrafab, map.PlayerPos, Quaternion.Euler(startEuler), map.transform);
            if (DoneBlockCount != 0)
            {
                map.player.GetComponent <PlayerControl>().DoneBlockCount = DoneBlockCount;
            }
            Destroy(this.gameObject);
        }
        velocity = GetComponent <Rigidbody2D>().velocity;
        if (velocity.magnitude < speed / 1000 || velocity.magnitude > speed * 2f)
        {
            velocity = Vector2.zero;
        }
        else
        {
            ChangeFactor(GetDistance(viewDir));
        }
        if (Mathf.Abs(velocity.x) > Mathf.Abs(velocity.y))
        {
            velocity.y = 0;
        }
        if (Mathf.Abs(velocity.y) > Mathf.Abs(velocity.x))
        {
            velocity.x = 0;
        }
        if (preVelocity != 0 && velocity.magnitude == 0 && SwipeControl.AllowSwipes)
        {
            RotationSkin.Find("playerscaler").GetComponent <Animator>().SetTrigger("hited");
            // ps.loop=false;
            var ps = CarParticles.transform.Find("FX_DirtSplatter").GetComponent <ParticleSystem>().emission;
            ps.enabled = false;

            // CarParticles.transform.Find("FX_DirtSplatter").GetComponent<ParticleSystem>().enableEmission = false;
            // CarParticles.transform.Find("FX_DirtSplatter").GetComponent<ParticleSystem>().Stop();

            Vibration.Vibrate(VibroMillis);
        }
        preVelocity = velocity.magnitude;


        if (velocity.magnitude > 0)
        {
            SwipeControl.ResetFp();
            // SwipeControl.BlockSwipeInput();
            UpdateVelocity(viewDir);
            GetComponent <Rigidbody2D>().velocity = velocity;
            return;
        }

        preViewDir = viewDir;

        if (Input.GetKeyDown("w") || SwipeControl.GetUpSwipe())
        {
            viewDir = Vector2.up;
            // RotationSkin.eulerAngles= Vector3.forward*90;
        }
        if (Input.GetKeyDown("s") || SwipeControl.GetDownSwipe())
        {
            viewDir = Vector2.down;
            // RotationSkin.eulerAngles= Vector3.forward*(-90);
        }
        if (Input.GetKeyDown("a") || SwipeControl.GetLeftSwipe())
        {
            viewDir = Vector2.left;
            // RotationSkin.eulerAngles= Vector3.forward*180;
        }
        if (Input.GetKeyDown("d") || SwipeControl.GetRightSwipe())
        {
            viewDir = Vector2.right;
            // RotationSkin.eulerAngles= Vector3.zero;
        }


        if (velocity.normalized != viewDir)
        {
            RotationSkin.eulerAngles = GetEulerToAlign();
            // Debug.Log(RotationSkin.eulerAngles+"  "+GetEulerToAlign());
            // Debug.DrawRay(RotationSkin.position,viewDir*10,Color.red,10);
            SetVelocity(viewDir);
        }
    }