Esempio n. 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);
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
 /// <summary>
 /// 重置飞机状态
 /// </summary>
 public void Reset()
 {
     _planeStatus   = (int)EnumPlaneStatus.Home;
     _localPosition = PludoGameData.GetReadyId(CurColor, _id);
 }