Exemplo n.º 1
0
    //method 2.
    public void GenTestEntrance(int level = -1)
    {
        int     x      = Mathf.RoundToInt(PeCreature.Instance.mainPlayer.position.x);
        int     z      = Mathf.RoundToInt(PeCreature.Instance.mainPlayer.position.z + 15);
        int     y      = VFDataRTGen.GetPosHeight(x, z);
        Vector3 genPos = new Vector3(x, y, z);

        InstantiateEntrance(genPos, level);
    }
Exemplo n.º 2
0
 public bool IsTerrainAvailableForFeces(IntVector2 GenPos, out Vector3 pos)
 {
     pos = Vector3.zero;
     if (AIErodeMap.IsInErodeArea2D(new Vector3(GenPos.x, 0, GenPos.y)) != null)
     {
         return(false);
     }
     if (PeGameMgr.IsStory)
     {
         Vector3    checkPos = new Vector3(GenPos.x, s_maxHeight, GenPos.y);
         RaycastHit hit;
         if (Physics.Raycast(checkPos, Vector3.down, out hit, s_maxHeight, 1 << Pathea.Layer.VFVoxelTerrain))
         {
             pos = hit.point + new Vector3(0, 1, 0);
             if (!VFVoxelWater.self.IsInWater(pos))
             {
                 if (!mRandomItemsDic.ContainsKey(pos))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     else if (PeGameMgr.IsAdventure)
     {
         int height = VFDataRTGen.GetPosHeight(GenPos.x, GenPos.y, true);
         pos = new Vector3(GenPos.x, height, GenPos.y);
         bool inWater = VFDataRTGen.IsSea(height);
         if (!inWater)
         {
             RaycastHit hit;
             if (Physics.Raycast(pos + new Vector3(0, 2, 0), Vector3.down, out hit, a_maxHeight, 1 << Pathea.Layer.VFVoxelTerrain))
             {
                 pos = hit.point;
             }
             pos.y += 1;
             if (!mRandomItemsDic.ContainsKey(pos))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
    void RPC_S2C_CreateDiscoveryPos(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        float x         = stream.Read <float>();
        float y         = stream.Read <float>();
        int   targetid  = stream.Read <int>();
        int   missionId = stream.Read <int>();

        TypeSearchData data = MissionManager.GetTypeSearchData(targetid);

        if (data == null)
        {
            return;
        }

        data.m_DistPos    = new Vector3(x, VFDataRTGen.GetPosHeight(x, y), y);
        data.m_DistRadius = data.m_mr.radius2;
        if (IsOwner)
        {
            if (data.m_mr.refertoType == ReferToType.Transcript)
            {
                RandomDungenMgr.Instance.GenTaskEntrance(new IntVector2((int)data.m_DistPos.x, (int)data.m_DistPos.z), data.m_mr.referToID);
            }

            if (MissionManager.Instance.m_bHadInitMission)
            {
                for (int i = 0; i < data.m_CreateNpcList.Count; i++)
                {
                    Vector3 createpos = StroyManager.Instance.GetPatrolPoint(data.m_DistPos, 3, 8, false);
                    EntityCreateMgr.Instance.CreateRandomNpc(data.m_CreateNpcList[i], createpos);
                }
            }
            if (null != PlayerNetwork.mainPlayer)
            {
                PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_InGame_MissionDiscoveryPos, data.m_DistPos, targetid);
            }
        }
        UpdateMissionMapLabelPos(missionId, targetid, data.m_DistPos);
    }
Exemplo n.º 4
0
    public static Vector3 GetPosOnGround(IntVector2 GenPos)
    {
        int        y   = VFDataRTGen.GetPosHeight(GenPos, true);
        Vector3    pos = new Vector3(GenPos.x, y + 4, GenPos.y);
        RaycastHit hit;

        if (Physics.Raycast(pos, Vector3.down, out hit, 512, 1 << Pathea.Layer.VFVoxelTerrain))
        {
            if (hit.point.y > 0)
            {
                pos.y = hit.point.y;
            }
            else
            {
                pos.y = y;
            }
        }
        else
        {
            pos.y = y;
        }
        return(pos);
    }
Exemplo n.º 5
0
    public bool IsTerrainAvailable(IntVector2 GenPos, out Vector3 pos, out int boxId)
    {
        //--to do: 1.random the data
        int  height  = VFDataRTGen.GetPosHeight(GenPos.x, GenPos.y, true);
        bool inWater = VFDataRTGen.IsSea(height);
        bool inCave  = false;

        pos = new Vector3(GenPos.x, height - 2, GenPos.y);
        RaycastHit hitTest;

        if (Physics.Raycast(pos, Vector3.down, out hitTest, 512, 1 << Pathea.Layer.VFVoxelTerrain))
        {
            inCave = true;
        }
        RandomMapType type = VFDataRTGen.GetXZMapType(GenPos.x, GenPos.x);

        IntVector2    tileIndex = new IntVector2(GenPos.x >> VoxelTerrainConstants._shift, GenPos.y >> VoxelTerrainConstants._shift);
        VArtifactTown vaTown    = null;

        if (VArtifactTownManager.Instance != null)
        {
            for (int i = -4; i < 5; i++)
            {
                for (int j = -4; j < 5; j++)
                {
                    vaTown = VArtifactTownManager.Instance.GetTileTown(new IntVector2(tileIndex.x + i, tileIndex.y + j));
                    if (vaTown != null)
                    {
                        break;
                    }
                }
                if (vaTown != null)
                {
                    break;
                }
            }
        }



        List <int> genCondition = new List <int>();


        if (vaTown != null)
        {
            if (vaTown.type == VArtifactType.NpcTown)
            {
                genCondition.Add(BoxMapTypeInt.NEAR_TOWN);
            }
            else
            {
                genCondition.Add(BoxMapTypeInt.NEAR_CAMP);
            }
        }

        switch (type)
        {
        case RandomMapType.Desert:
            genCondition.Add(BoxMapTypeInt.DESERT);
            break;

        case RandomMapType.Redstone:
            genCondition.Add(BoxMapTypeInt.REDSTONE);
            break;

        default:
            genCondition.Add(BoxMapTypeInt.GRASSLAND);
            break;
        }

        if (inWater)
        {
            genCondition.Add(BoxMapTypeInt.IN_WATER);
        }

        if (inCave)
        {
            genCondition.Add(BoxMapTypeInt.IN_CAVE);
        }


        boxId = -1;
        List <RandomItemBoxInfo> boxInfoList = RandomItemDataMgr.GetBoxIdByCondition(genCondition, height);

        if (boxInfoList == null || boxInfoList.Count == 0)
        {
            return(false);
        }
        List <RandomItemBoxInfo> boxInfoAvailable = new List <RandomItemBoxInfo> ();

        foreach (RandomItemBoxInfo rib in boxInfoList)
        {
            if (IsBoxNumAvailable(rib.boxId, rib.boxAmount))
            {
                boxInfoAvailable.Add(rib);
            }
        }
        if (boxInfoAvailable.Count == 0)
        {
            return(false);
        }

        RandomItemBoxInfo boxInfo = boxInfoAvailable[new System.Random((int)System.DateTime.UtcNow.Ticks).Next(boxInfoAvailable.Count)];

        boxId = boxInfo.boxId;
        float deep = boxInfo.boxDepth;


        //2.check with boxId
        if (deep <= 0)
        {
            deep = -3;
        }
        else if (deep < 2)
        {
            deep = 2;
        }
        pos = new Vector3(GenPos.x, height - deep, GenPos.y);
        if (pos.y < 0)
        {
            pos.y = 0;
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(pos, Vector3.down, out hit, 512, 1 << Pathea.Layer.VFVoxelTerrain))
            {
                pos.y = hit.point.y - boxInfo.boxDepth;
            }
        }

        if (pos.y < 0)
        {
            return(false);
        }

        return(true);
    }