void AddPlantAndAnimalModel(HomePosInfo plant, uint leftTime, uint seedID, EntityType type = EntityType.EntityType_Plant) { if (seedID != 0) { CreatureSmallState st = GetPlantStateByLandData(seedID, leftTime); SeedAndCubDataBase db = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID); if (db == null) { Log.Error("种子没找到"); return; } IEntity sen = HomeScene.Instance.AddEntity(plant.index.ToString(), type, db.indexID, (int)st); if (sen != null) { sen.SendMessage(EntityMessage.EntityCommand_SetPos, new Vector3(plant.posX, 2.97f, -plant.posZ)); HomeEntityInfo info = new HomeEntityInfo(); info.index = plant.index; info.state = (int)st; info.type = type; info.entityID = sen.GetUID(); AddHomeEntity(sen.GetUID(), info); AddPlantAndAnimalRemainTime(plant.index, leftTime); } } }
CreatureSmallState GetPlantStateByLandData(uint seedID, uint leftTime) { CreatureSmallState st = CreatureSmallState.Seed; SeedAndCubDataBase sdb = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID); if (sdb != null) { uint totalTime = sdb.growTime; if (leftTime > totalTime * 0.7f) //70% -- 100% 种子 { st = CreatureSmallState.Seed; } else if (leftTime > totalTime * 0.3 && leftTime < totalTime * 0.7) //30% -- 70% 幼苗 { st = CreatureSmallState.Seeding; } else if (leftTime < totalTime * 0.3f && leftTime > 0) // 0% -- 30% 成熟 { st = CreatureSmallState.Ripe; } else if (leftTime == 0) { st = CreatureSmallState.CanGain; //可收获 } } return(st); }