Пример #1
0
        public static void LoadData()
        {
            s_tblNaturalRes = new List <NaturalRes>();
            SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("resource");

            while (reader.Read())
            {
                NaturalRes naturalRes = new NaturalRes();
                naturalRes.m_id            = Convert.ToInt32(reader.GetString(reader.GetOrdinal("ID")));
                naturalRes.mLevel          = ToTexIdList(reader.GetString(reader.GetOrdinal("level")));
                naturalRes.mIllustrationId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("illustration")));
                naturalRes.m_type          = Convert.ToInt32(reader.GetString(reader.GetOrdinal("type")));
                naturalRes.m_duration      = Convert.ToSingle(reader.GetString(reader.GetOrdinal("durability")));
                naturalRes.m_itemsGot      = ToItemsGot(reader.GetString(reader.GetOrdinal("production")));
                naturalRes.m_extraGot      = ToExtraGot(reader.GetString(reader.GetOrdinal("production")));
                naturalRes.m_extraSpGot    = ToExtraSpGot(reader.GetString(reader.GetOrdinal("production")));
                naturalRes.mFixedNum       = Convert.ToSingle(reader.GetString(reader.GetOrdinal("fixed_num")));
                naturalRes.mSelfGetNum     = Convert.ToSingle(reader.GetString(reader.GetOrdinal("self_num")));
                naturalRes.mGroundEffectID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("ground_effect")));
                naturalRes.mGroundSoundIDs = PETools.Db.ReadIntArray(reader.GetString(reader.GetOrdinal("walk_sound")));
                naturalRes.mCastSkill      = Convert.ToInt32(reader.GetString(reader.GetOrdinal("gather_skill")));
                s_tblNaturalRes.Add(naturalRes);
            }
        }
Пример #2
0
 public static bool MatchId(NaturalRes iter, int id)
 {
     return(iter.m_id == id);
 }
Пример #3
0
    bool AttackVoxel(int vx, int vy, int vz, byte volumeDec)
    {
        // Tip: Switch between Voxels.Read and Voxels.SafeRead (with bounds check) to enabled/disable falling through the world.
        VFVoxel existingVoxel = Voxels.SafeRead(vx, vy, vz);

        NaturalResAsset.NaturalRes res = NaturalResAsset.NaturalRes.GetTerrainResData(existingVoxel.Type);
        if (res == null)
        {
            Debug.LogWarning("Failed to get NaturalRes !! ResType = " + existingVoxel.Type + " ---> position = " + vx + " " + vy + "" + vz);
            return(false);
        }

        float         curTimePoint = Time.time;
        IntVector3    voxelPos     = new IntVector3(vx, vy, vz);
        VoxelInAttack voxelInAtk   = null;

        if (listVoxelInAttack.TryGetValue(voxelPos, out voxelInAtk))
        {
            int volumeLeft = (curTimePoint < voxelInAtk.invalidTimePoint && existingVoxel.Type == voxelInAtk.type) ?
                             (int)(voxelInAtk.volume - volumeDec * res.m_duration) :
                             (int)(existingVoxel.Volume - volumeDec * res.m_duration);
            if (volumeLeft > 0)
            {
                voxelInAtk.invalidTimePoint = curTimePoint + atkActiveTime;
                voxelInAtk.volume           = (byte)volumeLeft;
                voxelInAtk.type             = existingVoxel.Type;
                return(false);
            }
            else
            {
                listVoxelInAttack.Remove(voxelPos);
                Voxels.SafeWrite(vx, vy, vz, new VFVoxel(0));
                //AlterVoxelInBuild()
                return(true);
            }
        }
        else
        {
            int volumeLeft = (int)(existingVoxel.Volume - volumeDec * res.m_duration);
            if (volumeLeft > 0)
            {
                voxelInAtk = new VoxelInAttack();
                voxelInAtk.invalidTimePoint = curTimePoint + atkActiveTime;
                voxelInAtk.volume           = (byte)volumeLeft;
                voxelInAtk.type             = existingVoxel.Type;
                List <IntVector3> keyList = new List <IntVector3>();
                for (int i = 0; i < listVoxelInAttack.Count; i++)
                {
                    KeyValuePair <IntVector3, VoxelInAttack> keyValue = listVoxelInAttack.ElementAt(i);
                    if (curTimePoint < keyValue.Value.invalidTimePoint)
                    {
                        break;
                    }

                    keyList.Add(keyValue.Key);
                }
                for (int i = 0; i < keyList.Count; i++)
                {
                    listVoxelInAttack.Remove(keyList[i]);
                }
                listVoxelInAttack.Add(voxelPos, voxelInAtk);
                return(false);
            }
            else
            {
                Voxels.SafeWrite(vx, vy, vz, new VFVoxel(0));
                return(true);
            }
        }

//		return false;
    }