예제 #1
0
        /// <summary>
        /// 根据飞机数据获取地图位置
        /// </summary>
        /// <param name="planeData">飞机数据</param>
        /// <param name="checkOnly">是否只是检测</param>
        public void GetMapPosByPlaneData(PludoPlaneData planeData, bool checkOnly = true)
        {
            var planeId = planeData.DataId;
            int curPosId;
            int tarGetPosId;

            switch ((EnumPlaneStatus)planeData.Status)
            {
            case EnumPlaneStatus.Finish:
            case EnumPlaneStatus.Home:
                curPosId = PludoGameData.GetReadyId(planeData.ItemColor, planeId);
                if (planeId == ConstantData.ValueLastPlaneId)
                {
                    tarGetPosId = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.IntValue);
                }
                else
                {
                    tarGetPosId = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.ValueReadyPosIndex);
                }
                break;

            case EnumPlaneStatus.Ready:
                curPosId    = PludoGameData.GetReadyId(planeData.ItemColor, ConstantData.ValueReadyPosIndex);
                tarGetPosId = _commonStartId;
                break;

            default:
                curPosId = planeData.LocalPosition;
                if (planeData.LocalPosition < ConstantData.ValueReadyMapItemColorBase)
                {
                    var findItem = _commomMapDic[planeData.LocalPosition];
                    if (findItem.EnumMapType == EnumMapItemType.End && findItem.Color == planeData.ItemColor)
                    {
                        tarGetPosId = SafeArea[ConstantData.IntValue].DataId;
                    }
                    else
                    {
                        tarGetPosId = (planeData.LocalPosition + 1) % PludoGameData.MapNormalLenth;
                    }
                }
                else
                {
                    var index = SafeArea.FindIndex(item => item.DataId == curPosId);
                    if (index > ConstantData.IntDefValue)
                    {
                        tarGetPosId = SafeArea[index + 1].DataId;
                    }
                    else
                    {
                        tarGetPosId = ConstantData.IntDefValue;
                        Debug.LogError("could not find such item in safeArea,local is:" + curPosId);
                    }
                }
                break;
            }
            Vector3 curPos       = GetMapItemPos(curPosId);
            Vector3 defTargetPos = GetMapItemPos(tarGetPosId);

            planeData.SetVector(curPos, defTargetPos);
        }
예제 #2
0
        IEnumerator TweenRotateWithCall(Vector3 targetPos, float rotateTime, AsyncCallback finishCall = null)
        {
            var targetRotate = PludoGameData.GetQuaternion(transform.localPosition, targetPos);
            var tweenRotate  = TweenRotation.Begin(RotateObj, rotateTime, targetRotate);

            tweenRotate.quaternionLerp = true;
            yield return(new WaitForSeconds(rotateTime));

            if (finishCall != null)
            {
                finishCall(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 飞机状态变化
        /// </summary>
        /// <param name="changeState"></param>
        public void PlaneStateChange(int changeState)
        {
            switch ((EnumPlaneStatus)changeState)
            {
            case EnumPlaneStatus.Home:
            case EnumPlaneStatus.Finish:
                _localPosition = PludoGameData.GetReadyId(CurColor, _id);
                break;

            case EnumPlaneStatus.Ready:
                _localPosition = PludoGameData.GetReadyId(CurColor, ConstantData.ValueReadyPosIndex);
                break;
            }
            _planeStatus = changeState;
        }
예제 #4
0
 /// <summary>
 /// 重置飞机状态
 /// </summary>
 public void Reset()
 {
     _planeStatus   = (int)EnumPlaneStatus.Home;
     _localPosition = PludoGameData.GetReadyId(CurColor, _id);
 }