예제 #1
0
        public override bool Setup(int difficulty)
        {
            if (cam == null)
            {
                cam = Camera.main;
            }
            base.Setup(difficulty);

            isPlaying = false;
            Vector3 babyStart = MinigameCommon.RandomPointOnScreen(cam, .25f).xy(Baby.BabyObject.transform.position.z);

            SpawnObjects(babyStart);
            Baby.Setup(difficulty, dangerousObjects, babyStart);
            Baby.OnDangerousObjectGrabbed = GameLost;
            return(true);
        }
예제 #2
0
        Vector3 RandomDangerObjectPosition(Vector3 babyPosition)
        {
            var point = MinigameCommon.RandomPointOnScreen(cam, 0f);

            point.z = Baby.BabyObject.transform.position.z;
            var moveAwayDist = babyBuffer - Vector3.Distance(babyPosition, point);

            if (moveAwayDist > 0f)
            {
                var movement = Vector3.Normalize(babyPosition - point) * (moveAwayDist + Random.Range(0f, 2f));
                point -= movement;
                var screenPoint = cam.WorldToScreenPoint(point);

                if (screenPoint.x < 0 || screenPoint.y < 0 || screenPoint.x > Screen.width || screenPoint.y > Screen.height)
                {
                    //recalculate?
                    point = RandomDangerObjectPosition(babyPosition);
                }
            }
            return(point);
        }