Пример #1
0
        public void HitBallEnd(object sender, GameEventArgs e)
        {
            //HitBallEndEventArgs ne = (HitBallEndEventArgs)e;

            GameEntry.HitBall.ShowFlightPath(GameEntry.GameData.pathBtnState);

            if (GameEntry.GameData.onLine)
            {
                golfballHitData currData = GameEntry.GameData.currGolfball[GameEntry.GameData.currGolfball.Count - 1];
                if (currData.rewardMapId != 0)
                {
                    DRRewardMap data = GameEntry.GameData.webRewardMap[currData.rewardMapId];
                    AddGoods(data.goodsId);
                }
            }

            //得分相关处理
            //ScoreFly();
            ScoreShine();
            Ballshine();
            if (GameEntry.GameData.currGolfball.Count >= GameEntry.GameData.MaxGolfballCount && GameEntry.GameData.onLine)
            {
                StartCoroutine(showResultForm());
            }
            else if ((GameEntry.HitBall.redisland.Count == 8 || GameEntry.HitBall.blueisland.Count == 8) && !GameEntry.GameData.onLine)
            {
                StartCoroutine(showResultForm());
            }
        }
        public void GameCameraFollowBall(golfballHitData currBall)
        //public void GameCameraFollowBall(CBall currBall)
        {
            //0,5,-4
            animator.enabled = false;

            //cameraTrans.SetParent(currBall.transform);
            //cameraTrans.transform.localPosition = Vector3.zero;
            //_camera.transform.localPosition = new Vector3(0, 5, -4);


            _camera.transform.localRotation = Quaternion.Euler(new Vector3(25, 0, 0));

            float height;

            if (currBall.maxHeight > 5)
            {
                height = currBall.maxHeight;
            }
            else
            {
                height = 5;
            }
            _camera.transform.DOLocalMove(_camera.transform.localPosition + new Vector3(0, height * 1.5f, -height * 1.2f), currBall.time * 6 / 10f).OnComplete(() =>
            {
                _camera.transform.DOLocalMove(currBall.endPoint + new Vector3(0, 15, -20), currBall.time * 6 / 10f);
                //_camera.transform.DOLocalMove(new Vector3(0, height * 1.5f, -6), currBall.time / 2f).OnComplete(() =>
                //{
                //	_camera.transform.DOLocalMove(currBall.endPoint + new Vector3(0, 15, -20), currBall.time / 2f);
                //});
            });
            _camera.transform.DOLocalRotate(new Vector3(35, 0, 0), currBall.time / 1f).SetEase(Ease.InQuad);
        }
Пример #3
0
        public void HitGolfBall(ref golfballHitData data)
        {
            CheckGolfballDestination(ref data);

            if (data.endPoint.z > 20)
            {
                //GameCameraManager.Instance.GameCameraFollowBall(currBall);
                GameCameraManager.Instance.GameCameraFollowBall(data);
            }
        }
Пример #4
0
        protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
        {
            golfballHitData data = GameEntry.GameData.currGolfball[GameEntry.GameData.currGolfball.Count - 1];

            base.OnUpdate(elapseSeconds, realElapseSeconds);
            m_time += Time.deltaTime;


            distance.text = Mathf.Lerp(0, new Vector2(data.endPoint.x, data.endPoint.z).magnitude, 1 / data.time * m_time).ToString("F1");
        }
Пример #5
0
        void repeat()
        {
            golfballHitData data = GameEntry.GameData.currGolfball[GameEntry.GameData.currGolfball.Count - 1];

            if (i <= data.speed)
            {
                speed.text       = i++.ToString();
                color.fillAmount = Mathf.Lerp(0, data.speed / 100, i / data.speed);
            }
            if (i > data.speed)
            {
                CancelInvoke();
                i = 0;
            }
        }
Пример #6
0
        public void OnPointerClick(PointerEventData eventData)
        {
            Vector3 vec = new Vector3(eventData.position.x, eventData.position.y, 0);

            vec   = GameEntry.Map._mapCameraManager.mapCamera.ScreenToWorldPoint(vec);
            vec.y = 5;
#if UNITY_EDITOR
            golfballHitData data = new golfballHitData();
            data.endPoint = vec;
            GameEntry.HitBall.CheckGolfballDestination(ref data);
            GameEntry.GameData.currGolfball.Add(data);
            GameEntry.Map._islandManager.Shine();
            //Debug.Log("得分地块:" + a);
            //GameEntry.Map._islandManager.Shine(a);
#endif
        }
Пример #7
0
        protected internal override void OnOpen(object userData)
        {
            base.OnOpen(userData);
            if (GameEntry.GameData.currGolfball.Count == 0)
            {
                OnClose(true);
            }
            m_time = 0;
            golfballHitData data = GameEntry.GameData.currGolfball[GameEntry.GameData.currGolfball.Count - 1];

            InvokeRepeating("repeat", 0f, 0.01f);
            distance.text        = new Vector2(data.endPoint.x, data.endPoint.z).magnitude.ToString("F1");
            yd.text              = "yd";
            maxHeight.text       = data.maxHeight.ToString("F1") + "m";
            speed.text           = data.speed.ToString("F1");
            km.text              = "km/h";
            launchAngle.text     = data.launchAngle.ToString("F1") + "°";
            horizontalAngle.text = data.horizontalAngle.ToString("F1") + "°";

            backSpin.text = data.backSpin.ToString("F0") + "\n" + "rpm";
            sideSpin.text = data.sideSpin.ToString("F0") + "rpm";
        }
Пример #8
0
        /// <summary>
        /// 落点检测.
        /// </summary>
        public void CheckGolfballDestination(ref golfballHitData data)
        {
            bool       hitIsland   = false;
            bool       hitscore    = false;
            int        rewardMapId = 0;
            GameObject rewardMap   = null;
            Vector3    rayStartPos = new Vector3(data.endPoint.x, data.endPoint.y + 10, data.endPoint.z);
            Ray        ray         = new Ray(rayStartPos, -transform.up);
            //检测分数
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("MapObject")))
            {
                // 如果射线与平面碰撞,打印碰撞物体信息
                Debug.Log("碰撞对象: " + hit.collider.name);
                if (hit.collider.tag == "score")
                {
                    hitscore    = true;
                    rewardMapId = int.Parse(hit.collider.name);
                    rewardMap   = hit.collider.gameObject;
                }
            }

            //检测地块
            RaycastHit hit2;

            if (Physics.Raycast(ray, out hit2, Mathf.Infinity, 1 << LayerMask.NameToLayer("Map")))
            {
                // 如果射线与平面碰撞,打印碰撞物体信息
                Debug.Log("碰撞对象: " + hit2.collider.name);

                if (hit2.collider.tag == "island")
                {
                    hitIsland = true;
                    if (!GameEntry.GameData.onLine && hitscore)
                    {
                        if (GameEntry.GameData.currGolfball.Count % 2 != 1)
                        {
                            Debug.Log(GameEntry.GameData.currGolfball.Count);
                            if (!redisland.Contains(hit2.collider.name))
                            {
                                redisland.Add(hit2.collider.name);
                            }
                            if (blueisland != null)
                            {
                                for (int i = 0; i < blueisland.Count; i++)
                                {
                                    if (blueisland[i] == hit2.collider.name)
                                    {
                                        blueisland.Remove(hit2.collider.name);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (!blueisland.Contains(hit2.collider.name))
                            {
                                blueisland.Add(hit2.collider.name);
                            }
                            if (redisland != null)
                            {
                                for (int i = 0; i < redisland.Count; i++)
                                {
                                    if (redisland[i] == hit2.collider.name)
                                    {
                                        redisland.Remove(hit2.collider.name);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (hitIsland)
            {
                data.rewardMapId = rewardMapId;
                data.rewardMap   = rewardMap;
            }
        }